How to Add cron job and how to send an email, when cron job is successfully configured

Step 1: For email sending
sudo apt-get install mutt

Step 2: To update Crontab
sudo crontab -e (Note: This will open crobtab of root user)

1. /bin/ed
2. /bin/nano <—- easiest
3. /usr/bin/vim.tiny

Select your editor.
(Note: To update editor later, used command; sudo select-editor)

Add these lines in crontab file
First line is just dumping while
Second other is dumping & mailing….

# m h dom mon dow command
43 15 * * * PGUSER=postgres && PGPASSWORD=postgres && export PGUSER && export PGPASSWORD && pg_dump -h localhost -p 5432 –format custom –blobs cms -f /media/backups/db-backup-“$(date +\%d-\%m-\%Y)”

53 12 * * * 1-5 PGUSER=postgres && PGPASSWORD=postgres && export PGUSER && export PGPASSWORD && pg_dump -h localhost -p 5432 –format custom –blobs cms -f /media/backups/ERP-Backups/db-backup-`date ‘+\%d-\%m-\%y-\%T’` && mutt -s “Database Backup” — < /etc/backupmail # JOB_ID_1

Step 3: Restart crob job service.
sudo service cron restart

For /media/backups/ERP-Backups/
baharali@baharali:~$ cd /media/
baharali@baharali:/media$ mkdir backups

baharali@baharali:/media$ sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe99f0667

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
/dev/sda2 206848 204802047 102297600 7 HPFS/NTFS/exFAT
/dev/sda3 204804094 512002047 153598977 5 Extended
/dev/sda4 512002048 976771071 232384512 7 HPFS/NTFS/exFAT
/dev/sda5 204804096 237029375 16112640 82 Linux swap / Solaris
/dev/sda6 237031424 512002047 137485312 83 Linux

baharali@baharali:/media$ sudo mount /dev/sda4 /media/backups
Mount /media/backups on each restart
Step 1: Open mtab
sudo vi /etc/mtab

Step 2: Copy this line
/dev/sda4 /media/backups fuseblk rw,nosuid,nodev,allow_other,blksize=4096 0 0

Step 3: Open fstabl
sudo vi /etc/fstab

Step 3: Add line
/dev/sda4 /media/backups fuseblk rw,nosuid,nodev,allow_other,blksize=4096 0 0

You have done.

Insatlling OpenERP 7.0 on Ubuntu 12.04

Step 1. Update
sudo apt-get update
sudo apt-get dist-upgrade

Step 2. Install and configure the database server, PostgreSQL
sudo apt-get install postgresql

createuser –createdb –username postgres –no-createrole –no-superuser –pwprompt openerp

Enter New passowrd 4 username in postgres.

sudo passwd postgres // if you don’t remember password then first change password…

/var/lib/$ su – postgres
/var/lib/$ psql -d postgres
postgres=# CREATE USER baharali with PASSWORD ‘baharal’ VALID UNTIL ‘2011-01-01’ CREATEDB;
You exit the connection with:::: \q

Step 3. Install the necessary Python libraries for the server
sudo apt-get install python-docutils
sudo apt-get install python-gdata
sudo apt-get install python-mako
sudo apt-get install python-dateutil
sudo apt-get install python-feedparser
sudo apt-get install python-lxml
sudo apt-get install python-libxslt1
sudo apt-get install python-ldap
sudo apt-get install python-reportlab
sudo apt-get install python-pybabel
sudo apt-get install python-pychart
sudo apt-get install python-openid
sudo apt-get install python-simplejson
sudo apt-get install python-psycopg2
sudo apt-get install python-vobject
sudo apt-get install python-tz
sudo apt-get install python-vatnumber
sudo apt-get install python-webdav
sudo apt-get install python-xlwt
sudo apt-get install python-werkzeug
sudo apt-get install python-yaml
sudo apt-get install python-zsi

sudo apt-get install python-psutil
sudo apt-get install python-pydot
sudo apt-get install python-pyparsing
sudo apt-get install python-unittest2
sudo apt-get install python-jinja2
sudo apt-get install python-mock

Step 4. Install the OpenERP server


Now install the code where we need it: cd to the /opt/openerp directory and extract the tarball there.

cd /opt/openerp
sudo tar xvf ~/openerp-7.0-latest.tar.gz

Next we need to change the ownership of all the the files to the OpenERP user and group we created earlier.

sudo chown -R openerp: *

Step 5. Configuring the OpenERP application
sudo cp /home/baharali/openerp/install/openerp-server.conf /etc/
sudo chown openerp: /etc/openerp-server.conf
sudo chmod 640 /etc/openerp-server.conf

sudo nano /etc/openerp-server.conf

One other line we might as well add to the configuration file now, is to tell OpenERP where to write its log file. To complement my suggested location below add the following line to the openerp-server.conf file:

logfile = /var/log/openerp/openerp-server.log

Once the configuration file is edited and saved, you can start the server just to check if it actually runs.


Step 6. Installing the boot script
sudo cp /home/baharali/openerp/install/openerp-server.init /etc/init.d/openerp-server

sudo chmod 755 /etc/init.d/openerp-server
sudo chown root: /etc/init.d/openerp-server

In the configuration file there’s an entry for the server’s log file. We need to create that directory first so that the server has somewhere to log to and also we must make it writeable by the openerp user:

sudo mkdir /var/log/openerp
sudo chown openerp:root /var/log/openerp

Create Log file
touch /var/log/openerp/openerp-server.log

Step 7. Testing the server

To start the OpenERP server type:
sudo /etc/init.d/openerp-server start

You should now be able to view the logfile and see that the server has started.
less /var/log/openerp/openerp-server.log

Now it’s time to make sure the server stops properly too:
sudo /etc/init.d/openerp-server stop

Step Note.
Run this command
/home/baharali/openerp/openerp-server -s

This will save configuration to file ~/.openerp_serverrc

go to
gedit ~/.openerp_serverrc
Now Make sure db_port is Ok.


For a many2many field, a list of tuples is expected. Here is the list of tuple that are accepted, with the corresponding semantics

(0, 0, { values }) link to a new record that needs to be created with the given values dictionary

(1, ID, { values }) update the linked record with id = ID (write values on it)

(2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)

(3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)

(4, ID) link to existing record with id = ID (adds a relationship)

(5) unlink all (like using (3,ID) for all linked records)

(6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

Android Source download Commands

mkdir ~/bin
curl > ~/bin/repo
sudo apt-get install curl
curl > ~/bin/repo
chmod a+x ~/bin/repo
mkdir android
cd android
repo init -u
git –version
repo init -u -b android-4.0.1_r1
repo sync

Install Guest Addition for Ubuntu when installed on VirtualBox

Step 1: Device -> Install Guest Addition
Guest Addition CD, will be inserted

Step 2: cd /media/VBOXADDITIONS_3.2.6_63112/

Step 3: /media/VBOXADDITIONS_3.2.6_63112$ sudo ./

For Unbuntu 12.04: also Enter this command

sudo apt-get install virtualbox-guest-x11 virtualbox-guest-dkms virtualbox-guest-utils

Note: For Ubuntu 14.04, to enable full screen view, the guest additions works only with VirtualBox 5.0.2

How to Install Kernal And Make All Hardwares Working .i.e. (NVIDIA Card, Vedio Drivers…. etc)

Step 1: Download kernel from
Step 2: copy it to /usr/src/
Step 3: extract it #tar xvf
Step 4: cd
Step 5: sudo apt-get install ncurses-dev
Step 6: make menuconfig
Step 7: make -7
Step 8: make modules_install
Step 9: make install
Step 10: update-initramfs -c -k
Step 11: Modify grub config file accordingly // Copy and Entry and Change it like below with
Step 11(a): cd /boot/grub/
Step 11(b): sudo gedit grub.cfg

menuentry ‘Ubuntu, with Linux 3.7.1′ –class ubuntu –class gnu-linux –class gnu –class os {
insmod ext2
set root='(hd0,7)’
search –no-floppy –fs-uuid –set 0d3c9bdf-5e48-4940-9dbe-0b1e4f2282cf
linux /boot/vmlinuz-3.7.1 root=UUID=0d3c9bdf-5e48-4940-9dbe-0b1e4f2282cf ro quiet splash
initrd /boot/initrd.img-3.7.1

Step 12: sudo reboot
Step 13: hal-device //To see Hardwares Details….

Recovering grub after installing windows 7 / Windows 8 ….?

You can simply use Ubuntu CD itself. Read through as it is already answered there. \96 wisemonkey

You can re-install grub in the Master Boot Record using the LiveCD for you distribution version,

It goes like this:

Step1: Boot from LiveCD ? please try to use a LiveCD that has the same version of Grub2 as the installed version
Step2: Mount the root of the installed Ubuntu at /mnt
Step3: Change root
Step4: Update grub
Step5: Install grub
Step6: Reboot

baharali@baharali:~$ sudo fdisk -l

Disk /dev/sde: 300.1 GB, 300089646592 bytes
255 heads, 63 sectors/track, 36483 cylinders, total 586112591 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3f5ebeb

Device Boot Start End Blocks Id System
/dev/sda2 138464296 586110975 223823340 5 Extended
/dev/sda3 * 2048 138463231 69230592 83 Linux
/dev/sda5 138464298 313460279 87497991 7 HPFS/NTFS/exFAT
/dev/sda6 313460736 317650943 2095104 82 Linux swap / Solaris
/dev/sda7 317652992 581922815 132134912 83 Linux
/dev/sda8 581924864 586110975 2093056 82 Linux swap / Solaris

Partition table entries are not in disk order

baharali@baharali:~$ sudo mount /dev/sda7 /mnt/ // sda7 Linux Partition

This is assuming that you do not have a separate /boot partition. If you do, you will need to also mount it by typing sudo mount /dev/sd\B7\B7 /mnt/boot, where sd\B7\B7 is the partition where you installed the separate boot directory.

baharali@baharali:~$ sudo ls /mnt/ //just checking to see if I got it right
bin cdrom etc initrd.img lib media opt root sbin srv tmp var vmlinuz.old
boot dev home initrd.img.old lost+found mnt proc run selinux sys usr vmlinuz

baharali@baharali:~$ sudo ls /boot/
abi-2.6.35-30-generic initrd.img-2.6.35-30-generic
abi-2.6.35-31-generic initrd.img-2.6.35-31-generic vmcoreinfo-2.6.35-30-generic
config-2.6.35-30-generic memtest86+.bin vmcoreinfo-2.6.35-31-generic
config-2.6.35-31-generic memtest86+_multiboot.bin vmlinuz-2.6.35-30-generic
grub vmlinuz-2.6.35-31-generic

Type in: // Note if not working with sudo, then remove sudo from command

baharali@baharali:~$ for i in /dev/ /dev/pts/ /proc/ /sys/; do sudo mount -B $i /mnt/$i; done
baharali@baharali:~$ sudo chroot /mnt
baharali@baharali:~$ sudo update-grub
Generating grub.cfg …
Found linux image: /boot/vmlinuz-3.0.0-13-generic
Found initrd image: /boot/initrd.img-3.0.0-13-generic
Found linux image: /boot/vmlinuz-3.0.0-12-generic
Found initrd image: /boot/initrd.img-3.0.0-12-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows XP Professional on /dev/sdc1

Now to re-install grub in the MBR. You will need to know which disk your system boots from, and find it in the fdisk -l listing you have already done. Then type in sudo grub-install /dev/sd\B7 replacing sd\B7 with the disk you will boot from.

baharali@baharali:~$ sudo grub-install /dev/sda

Then type in Crtl-D to exit chroot.

baharali@baharali:~$ sudo for i in /sys/ /proc/ /dev/pts/ /dev/; do sudo umount /mnt/$i; done

baharali@baharali:~$ sudo umount /mnt/boot //If you mounted a separate /boot partition, type in sudo umount /mnt/boot
baharali@baharali:~$ sudo umount /mnt
baharali@baharali:~$ sudo reboot //Then type in sudo reboot to restart he system (remember to remove the LiveCD).
Hopefully, grub will be installed.
Good Luck.

Getting apikey for using Google Map in Android


keytool -list -alias androiddebugkey -keystore C:\Users\BaharAli\.android\debug.keystore -storepass android -keypass android
Certificate fingerprint (MD5): AF:29:B7:3E:4A:DF:E3:5C:63:43:99:03:D2:5C:DC:28

keytool -list -alias androiddebugkey -keystore /home/baharali/.android/debug.keystore -storepass android -keypass android
Certificate fingerprint (MD5): 1E:B0:EA:DF:B1:3D:0F:5C:B0:FB:74:A5:61:79:33:6B

Now Go to
and Enter MD5, Accept it, And You will get apikey..