Thursday, September 24, 2015

Object Oriented Daemon implementation in Python3

1.What is a daemon?

A daemon is program that runs in the background and does some work. It does not need any user interaction to do its work.

Features of a daemon

  • It does not have access to the terminal, i.e. it cannot read or write to the terminal.
  • Only one instance of  it can be created.
  • It works without user interaction.
Example:  sshd is a daemon that services incoming SSH connections.

 2. My python daemon module:

The OO daemon module provided a simple implementation on a daemon which can be used as a base class to create daemon processes. All one needs to do to create a daemon using the daemon module as bellow.
  1. Import the daemon module
  2. Create a child class of the daemon
  3. Override the run method. This is were the business logic for your daemon goes. It should be implemented inside an infinite loop as shown in the example.
  4. Create and instance of the child daemon with daemon name and log directory path as parameters.
  5. Call the startDaemon method  the daemon.  

3. Example: Backup your clip board every 10 seconds.

Clipboard archiver daemon (

4. Running the daemon

  $ [status|restart|stop]

$ ./
clipcopy: started at 24.09.2015 / 22:22:58
clipcopy: log directory is '/tmp/clipcopy'
clipcopy: going into background........
$ ./ status
$ ./ restart
clipcopy: started at 24.09.2015 / 22:23:15
clipcopy: log directory is '/tmp/clipcopy'
clipcopy: going into background........
$ ./ stop

5. Daemon Module code

6. References

Monday, May 25, 2015

Install Linux on Virtualbox with command line

Table of Contents

1. Install virtual box

On an Arch machine

Update arch before installing
$ pacman -Syu $ pacman -S virtualbox Install other optional dependencies for virtualbox
  • qt4: GUI support
  • vde2: Virtual Distributed Ethernet support
  • virtualbox-guest-iso: Guest Additions CD image
  • virtualbox-ext-vnc: VNC server support
  • virtualbox-sdk: Developer kit
  • virtualbox-host-dkms: Build kernel modules with DKMS
  • net-tools: Host-only or bridged networking support [installed]
Install VirtualBox extention pack
$ wget ""
$ sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.26.vbox-extpack

2. Download Arch Installer

Go to and download from one of the links
$ wget -p ~/Downloads ""

3. Arch instalation on virtualbox

3.1 List all installed vms on our virtualbox

This currently returns nothing as there are no installed vms
$ VBoxManage list vms

3.2 List ostypes recognised by virtualbox

$ VBoxManage list ostypes | grep -i -A4 arch
ID:          ArchLinux
Description: Arch Linux (32 bit)
Family ID:   Linux
Family Desc: Linux
64 bit:      false

ID:          ArchLinux_64
Description: Arch Linux (64 bit)
Family ID:   Linux
Family Desc: Linux
64 bit:      true 

3.3 Create and register a virtual machine with name 'vm-arch-home' with ostype ArchLinux_64

$ VBoxManage createvm –name 'vm-arch-home' –ostype ArchLinux64 –register
Virtual machine 'vm-arch-home' is created and registered.
UUID: 17bf6520-2c03-4542-830f-2d335669ccd4
Settings file: '/home/younus/VirtualBox VMs/vm-arch-home/vm-arch-home.vbox'

3.4 Modify vm to setup memory, cpus, bridgeadaptor, clipboard, etc..

Bridge adaptor can be optained by ifconfig command as shown bellow
$ VBoxManage modifyvm 'vm-arch-home' –memory 3048 –cpus 2 –pae on –acpi on –hpet on –ioapic on –hwvirtex on –vtxvpid on –accelerate3d off –audio none –chipset ich9 –nic1 bridged –bridgeadapter1 wlp2s0 –nictype1 82543GC –vrde on –vrdeport 5555 –clipboard bidirectional

3.5 Create a sata controller named storage for the virtual disk

$ VBoxManage storagectl 'vm-arch-home' –name storage –add sata –controller IntelAHCI –portcount 4 –hostiocache off

3.6 Create and add storage as virtual disk of size 10Gb and setup permisions

$ sudo VBoxManage createhd –filename /storage/soft/vbox/vm-arch-home/root-sda.vdi –size 10240
Disk image created. UUID: 7ee167ba-0157-46a4-b3a2-12cd3702f81c
$sudo chmod 777 /storage/soft/vbox/vm-arch-home/root-sda.vdi Attach the hardisk to sata controller on port 1
$ VBoxManage storageattach 'vm-arch-home' –storagectl storage –port 1 –medium /storage/soft/vbox/vm-arch-home/root-sda.vdi –type hdd

3.7 Attach the arch dual boot instaler iso file to port 2 of the sata controller

$ VBoxManage storageattach 'vm-arch-home' –storagectl storage –port 2 –medium archlinux-dual.iso –type dvddrive

3.8 Set vm to boot from dvd

$ VBoxManage modifyvm 'vm-arch-home' –boot1 dvd

3.9 Boot the newly created vm

$ VBoxHeadless -s 'vm-arch-home' &

3.10 Remotely access the desktop of the vm

$ rdesktop-vrdp localhost:5555

4 Other usefull commands

4.1 Listing extention packs installed on virtualbox

$ sudo VBoxManage list extpacks