Ubuntu 14.04 Aeroo Reports installation

Install Git:

#0      sudo apt-get install git

Install AerooLib:

#1      sudo apt-get install python-setuptools
#2      sudo apt-get install python-genshi python-cairo python-lxml
#3      sudo apt-get install libreoffice-script-provider-python
#4      sudo mkdir /opt/aeroo
#5      cd /opt/aeroo
#6      sudo git clone https://github.com/aeroo/aeroolib.git
#7      cd /opt/aeroo/aeroolib
#8      sudo python setup.py install

Installing Odoo 8.0 (OpenERP) on Debian-based Distribution

For Installation, first switch to root user
$ sudo su root

Execute the following commands as;
# mkdir /var/lib/odoo
# wget -O - https://nightly.odoo.com/odoo.key | apt-key add -
# echo "deb http://nightly.odoo.com/8.0/nightly/deb/ ./" >> /etc/apt/sources.list
# apt-get update && apt-get install odoo
# apt-get install wkhtmltopdf

To run Server, execute command as;
$ sudo service odoo restart 
  Restarting odoo: ok 

To view log, execute command as;
$ tailf /var/log/odoo/odoo-server.log

Finally, create a role odoo in postgresql to access odoo in browser (Firefox, Chrome, etc.);
$ su postgres
$ psql -d postgres
$ postgres=# CREATE USER odoo with PASSWORD 'admin' VALID UNTIL '2020-01-01' CREATEDB;

To enable excel Import/ Export, installl xlrd package as;
sudo apt-get install python-xlrd 

You have done:

Calculate Time Duration using Ubuntu Script

First create your script file

$ touch script.sh

$ chmod a+x script.sh

Copy below code to script.sh.

start=$(($(date +%s%N)/1000000))
echo "Hello, World"
sleep 5
end=$(($(date +%s%N)/1000000))
echo "Start: " $start
echo "End: "$end
echo "Time (Milliseconds): " $(($end-$start))
echo "Time (Seconds): " $((($end-$start)/1000))

Now run your script file.
$ ./script.sh

You have done

DbSchema Tool to generate ERD for Postgresql

Installing DbSchema on Linux

$ wget http://www.dbschema.com/DbSchema.zip
$ unzip DbSchema.zip
$ cd DbSchema
$ chmod +x DbSchema.sh

To run DbSchema

$ ./DbSchema.sh


To Enable Remote Computer Access:

Step 1: # vi /etc/postgresql/9.1/main/pg_hba.conf

. . . . add line for your host to give access to network. (Note: 0 = *)

. . . . host    all             all            trust

Step 2: # vi /etc/postgresql/9.1/main/postgresql.conf

. . . . Next set IP address(es) to listen on

. . . . listen_addresses='*'

. . . . Bind and open TCP/IP port by setting tcpip_socket to true

. . . .tcpip_socket = true

Step 3: Restart PostgesSQL Server
# /etc/init.d/postgresql restart

Step 4: Stop Firewall

# ufw disable


You have done..

General Commands


Linux Packages:

gedit .bashrc
source .bashrc
changing passowd of root
sudo passwd root

sudo apt-get update
sudo apt-get install abc

sudo apt-get install ssh
sudo apt-get install samba
sudo apt-get install samba-common

sudo rm /root/.ssh/known_hosts

sudo apt-get install gedit

Normal Copy
cp source destination
cp dir1 dir2
cp -option source destination
$ cp -r dir1 dir2
The -r option if you want to copy a directory with its contents. The -r means “copy recursively”
To Remove Data
rm dir1
rm -r dir1
The -r option if you want to remove a directory with its contents. The -r means “copy recursively”
To Move Data From On Place to Another or rename folder/file name

mv source destination
mv dir1 dir2
Secure Copy:

To copy File:
scp /home/local_username/mydroid remote_username@

To copy Folder:
scp -r /home/local_username/mydroid remote_username@
scp -r /home/local_username/mydroid remote_username@\ Data_/bahar

Checking 32 or 64 bit Operating System Ubuntu
getconf LONG_BIT
Android Source and Installing java6

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer
sudo update-java-alternatives -s java-6-oracle

These Fies will be created after Compilation
Go to Path = out/host/linux-x86/bin

cd android
make (used for compilation)
make -j 16 (used for compilation with 16 thread)

Subject: [android-building] _FORTIFY_SOURCE error when building “-b android-4.0.1_r1”

Go to


For Eclipse
cd /path/to/android/root

cd /path/to/android/root
cp development/ide/eclipse/.classpath .
chmod u+w .classpath

Increase Eclipse’s Memory Settings

For Error
!ENTRY org.eclipse.osgi 4 0 2012-04-15 21:05:47.885
!MESSAGE Application error
directory first and then run the link command:
For 32 bit:
ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86/
And on Ubuntu 12.04 64 bit:
ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64/
if An Error like
/bin/bash: build/core/find-jdk-tools-jar.sh: Permission denied
then do it.
chmod 777 -R /home/baharali/workspace/mydroid/

Run Emulator:
. build/envsetup.sh
lunch 1
build Log:

. build/envsetup.sh
lunch 1
adb logcat > android.log
View logs with filters:

$ tail -f android.log
sudo apt-get install x11proto-core-dev
sudo apt-get install libx11-dev


Making SD Card and attaches it with emulator

mksdcard 1024M sdcard.iso

emulator -sdcard path to sdcard .i.e.

emulator -sdcard /home/baharali/sdcard1.iso

adb install path to .apk file
i.e. adb install /home/baharali/calender.apk

Specifying Emulator.

adb -s emulator-5556 install helloWorld.apk

Specifying OS running on Virtual Machine install /home/baharali/workspace/ContactPicker.apk


How to make sdk from android source code

cd {Android Source Root Directory}

$ .build/envsetup.sh
$ lunch 1
$ make sdk

How to access emulator control from command prompt.

adb shell

Also if you want to view emulator memory etc
1. Go to Dev Tools
2. Select Terminal Emulator
3. Now you will see blue screen
4. write command ls (enter)

Copying Files to or from an Emulator/Device Instance

adb push fileName /sdcard/myfileName .i.e.
adb push foo.txt /sdcard/foo.txt

adb pull /data/fileName/ path where you want to copy .i.e.
adb pull /data/MyPolicy.txt /home/baharali/

View path where you are in command prompt.

If Permission is denied try this to pull or push file to/from emulator

sudo su
root@baharali-desktop:/home/baharali# PATH=$PATH:/home/baharali/android-sdk/tools/

adb pull /data/aaa.txt /home/a.txt


How to Make & Update Android Project From Command-Line

android create project \
–target 1 \
–name MyAndroidApp \
–path ./MyAndroidAppProject \
–activity MyAndroidAppActivity \
–package com.example.myandroid

android update project –name MyApp –target 2 –path ./MyAppProject

Building in debug mode
ant debug


baharali@baharali-desktop:~$ sudo su
[sudo] password for baharali:
root@baharali-desktop:/home/baharali# PATH=$PATH:/home/baharali/android-sdk/tools/
root@baharali-desktop:/home/baharali# adb pull /data/data/com.example.myandroid/files/MyPolicyfile.txt /home/baharali/Desktop/MyP.txt
137 KB/s (11467 bytes in 0.081s)

First Set Variable:


Then Set Variable value that is Path for variable


but remember path is not permanant, it is temperary.

To Show Path/Value


To Start and Stop Server:

root@baharali-desktop:/home/baharali/workspace/mydroid# adb kill-server
root@baharali-desktop:/home/baharali/workspace/mydroid# adb start-server
* daemon not running. starting it now *
* daemon started successfully *
root@baharali-desktop:/home/baharali/workspace/mydroid# adb devices
List of devices attached
HT94JLZ00002 device

root@baharali-desktop:/home/baharali/workspace/mydroid# fastboot devices
List of devices attached
HT94JLZ00002 device


First Enter NickName, Alternate Name.
for Registeration

/msg nickserv register
/msg nickserv register baharal sparlay_pk@hotmail.com or /msg NickServ@services.dal.net register baharal sparlay_pk@hotmail.com

Password will be sent to your email,

Random Server.

If you are register then:
/nickserv identify
/nickserv identify BaharIMS baharal

Now Go to Tool and select channel from channellist. i.e. android-dev, android, ….

Passoword for openpg:
default password: openpgpwd
but you can see passwords in openerp-server.conf file.
C:\Program Files (x86)\OpenERP AllInOne\Server\openerp-server.conf

User Name: Admin
Passowrd : admin


Openerp Commands

Error: Unable to find interpreter named: pydev. Available: /usr/bin/python2.6 (/usr/bin/python2.6) Unable to find interpreter named: pydev. Available: /usr/bin/python2.6 (/usr/bin/python2.6)
To Remove This Error, I right clicked on the project name and from the context menu chose Properties. In the Properties for dialog box I change the interpreter from “default” to “python” and the error is gone.

ps -aux | grep open //show me all the services starts with open
sudo kill -9 2895 //

How To Start OpenERP Server from command line.

./openerp-server.py -d bdb -r openerp -w openerp //
sudo /etc/init.d/openerp-server stop //
sudo /etc/init.d/openerp-server start //
sudo /etc/init.d/openerp-server restart //

How To Start OpenERP Web-Server from command line.

sudo /etc/init.d/openerp-server
sudo /etc/init.d/openerp-web

-d bdb -r openerp -w openerp // -d databasename -r username -w password

-d postgres -r openerp -w openerp db_host=localhost db_port=5432 // Arguments given in run

Python exes
Windows: c://Python2.7/python ….
Ubuntu: usr/bin/python2.6
changing password and creating username in postgres-sql.

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

…..:/var/lib/$ su postgres
…..:/var/lib/$ psql -d postgres
postgres=# DROP USER baharali;
postgres=# CREATE USER baharali with PASSWORD ‘baharal’ VALID UNTIL ‘2011-01-01’ CREATEDB;
postgres=# alter user postgres with password ‘baharal’;

You exit the connection with:::: \q

Try To Create A Server in Postgres with the username to which DB is concerned, As User only permitted to see DB which are created with the server having matched username.


Default Postgres-SQl
Maintenance DB: postgres
Username: Openerp
Password: openerp


Start / Stop / Restart Postgres-SQl
sudo /etc/init.d/postgresql start
sudo /etc/init.d/postgresql stop
sudo /etc/init.d/postgresql restart


Accessing Tables of  Postgres-SQl
sudo su postgress
psql -d cms
\dt *.mytable
\dt *
\dt mytable

tail -f /var/log/openerp/openerp.log
tail -f /var/log/messages

cd /usr/local/lib/python2.6/dist-packages/openerp-server/addons/base_report_designer/wizard/tiny_sxw2rml/

/usr/local/lib/python2.6/dist-packages/openerp-server/addons/base_report_designer/wizard/tiny_sxw2rml$ python tiny_sxw2rml.py attendance_session_program_semester_subject_report.sxw > attendance_session_program_semester_subject_report.rml

Command to Search inside file:
sudo grep -i -n -r ‘mytext’ /home/

will search ‘mytext’ in files of folder home.

DBAMP Project Commands Sequence

Goto /lib/modules/2.6.31-22-generic/kernel/drivers/char/tpm
1. sudo insmod tpmd_dev.ko (tpm starts)

2. tpmd -d -f
(if step 2 gives error then: sudo rm /var/run/tpm/tpmd_socket:0)
3. tcsd start. (Trouser Starts)
(tcsd status Checking for service tcsd z running )
4. cd /home/baharali/Desktop/tpm_emulator-0.7.1

C/C++ Compilation and execution

For C:
gcc MyProgram.c -o MyProgram

gcc -lpthread thrd-posix.c -o thrd-posix // In some cases you need to add -lpthread to compile the code correctly
gcc thrd-posix.c -o thrd-posix -lpthread // In some cases you need to add -lpthread to compile the code correctly

For C++:
g++ MyProgram.cpp -o MyProgram

To run it simply Enter Name of Program like.



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..

Registering SQL

Inter Process Communication

Aft upgrating ubuntu VirtualBox does not run OS properly to solve this problem

Add this line to .bashrc, this will run this command whenever Ubuntu is started.
/etc/init.d/./vboxdrv.dpkg-bak setup


run this command, but it will make VM to run OS only once.
/etc/init.d/./vboxdrv.dpkg-bak setup


How to findout IP of Anroid Phone.
Go to
Dev Tool -> Terminal

Enter the following commands
ifconfig eth0

How to view .trace file using Traceview: A Graphical Log Viewer

Go to
android-sdk -> tools
Enter command
./traceview /home/baharali/Desktop/ab/calc.trace


BluetoothChat – Bluetooth Chat Application

0 down vote

You can install the image from http://www.android-x86.org/ into a virtual machine (e.g. VMWare), find out it’s IP address, connect manually using
adb connect

adb connect // To Connect with VM
adb disconnect // To Disconnect From VM

And then launch your project from Eclipse by setting a “Manual” deployment target in your Debug/Run configuration.

The APIs for Creating Insecure RFCOMM is available only from API Level 10 (Android 2.3.3) and
The ActionBar API is available only from Android 3.0 or API Level 11


Using the Traceview graphical log viewer tool

The Traceview graphical log viewer tool is useful for viewing the execution logs of an application and for application performance profiling.
To use this tool effectively, select the program area or piece of code that you want to monitor or profile. Enclose the code with the following statements.

// start tracing to “/sdcard/mymethod.trace”

// … Code goes here

// stop tracing

These statements instruct Android to create the “tracefile” in the specified location.

$ traceview mymethod

How to view .trace file using Traceview: A Graphical Log Viewer
Go to
android-sdk -> tools
Enter command
./traceview /home/baharali/Desktop/ab/calc.trace


Installing Android Plugin for Eclipse
Installing Python Plugin for Eclipse

For Pydev


Help -> Install New Software -> Add Link
Name: PyDev
Location: http://pydev.org/updates

Uncheck X “Show only latest version of available software”
Now Select “PyDev for Eclipse: 2.8.2”

It’s done..

Good Luck.

Install remastersys on Ubuntu 10.04
sudo gedit /etc/apt/gedit sources.list

# Remastersys
deb http://www.geekconnection.org/remastersys/repository karmic/

sudo apt-get update
sudo apt-get install remastersys


Install remastersys on Ubuntu 12.04

Using the Synaptic Package Manager:

1. Open your browser, point it to the URL below and save it to your desktop.
2. In synaptic, go to Settings/Repositories; select “Authentication” tab and “Import Key File” just downloaded.
3. Still in synaptic, go to “Other Software” tab and click “Add”, then enter the apt line:
deb http://www.remastersys.com/ubuntu precise main
4. Leave the repositories tab and “Reload”.
5. Search for “remastersys” and select for install. Edit/Apply Marked Changes.

chown is used to change user and/or group ownership of files/directories.

To change the user ownership of the directory some-directory to baharali, type:
chown baharali addons/

To recursively change any sub-directories and their contents, type:

chown baharali -R addons/

Actually Ubuntu got a firewall it self named uncomplicated firewall. For any reason you have problem with the firewall means you can simply disable it by running:

sudo ufw disable

Tip: By adding a colon after the user, chown can be used to change the group and user ownership simultaneously, type:

chown user:group -R addons/
chown baharali:baharali -R addons/
sudo chown baharali:baharali -R /usr/local/lib/python2.6/dist-packages/

To recursively change permission to (read/write) any sub-directories and their contents, type:
chmod 777 -R addons/

sudo chmod 777 -R /usr/local/lib/python2.6/dist-packages/

chgrp is used to change group ownership of files/directories. For example:
To change the group ownership of the directory some-directory to group1, type:
chgrp group1 some-directory
To recursively change any sub-directories and their contents, type:
chgrp group1 -R some-directory/



sudo nano /etc/default/grub
Then look for “GRUB_TIMEOUT=…”. Does it have a number other than “10” next to the equal sign?

If so, change it to “10” or whatever suits you

sudo update-grub
Change Username

Run the commands create a new password for the root account.

sudo passwd root

Next, run the commands below to unlock the root account.
sudo passwd -u root

After unlocking it, log out and login as the root user from the logon screen.

When it opens run the commands below to change your username.
usermod -c “BaharAli” -l baharali khan

When you have done, lock the root account again and restart.
passwd -l root

Change Group of User
groupmod -n baharali khan


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

You can simply use Ubuntu CD itself. Read through askubuntu.com/a/6321/22272 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 System.map-2.6.35-31-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 System.map-2.6.35-30-generic 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.


Ubuntu Password Recovery
Step 1: Select Unbutu Load
Step 2: Press E
Step 3: Then write Single after ….
Step 4: Press Ctrl + X
Step 5: Start
Step 6: Select root, change it Password
Step 7: Now login using root [init to directly go to GUI of root]
How to Install Kernal And Make All Hardwares Working .i.e. (NVIDIA Card, Vedio Drivers…. etc)

Step 1: Download kernel from kernel.org
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….
Switch between console mode and GUI Mode

Ctrl + Alt + F7
Enter Command
OR Try
init 1, init 2, init 3, init 4, init 5(GUI Mode)
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 ./VBoxLinuxAdditions-x86.run

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


sudo mkdir /mnt/sharename\A0
sudo chmod 777 /mnt/sharename\A0
sudo mount -t vboxsf -o uid=1000,gid=1000 Example-Shared-Folder /mnt/sharename
ln -s /mnt/sharename $HOME/Desktop/sharename

Note1: ln -s /mnt/sharename $HOME/Desktop/sharename is used for creating shortcut on Desktop.

Note2: if you want to mount the folder as owned and writable only by root, omit the\A0 -o uid=1000,gid=1000\A0 option to the mount command.

For the above command if you get error as

mount: unknown filesystem type ‘vboxsf’

Then just change the\A0vboxsf\A0to\A0vboxfs

If error persist install virtualbox guest utils:

sudo apt-get install virtualbox-ose-guest-utils\A0

end reboot the virtual machine.

To ensure the shared folder is mounted whenever your virtual machine is booted, run the following command:\A0sudo nano /etc/rc.local\A0and enter the command you entered in the last step (without the sudo in front) into this file below the hashes (i.e., #’s) but above \93exit 0\94 (note that the arrow keys move the cursor and ctrl+x is used to exit which will prompt you to save first, answer Y, then hit Enter)

sudo mount -t vboxsf -o uid=1000,gid=1000 Example-Shared-Folder /mnt/sharename


Enable Apache Server : Localhost in Ubuntu

Step 1. sudo gedit /etc/apache2/sites-available/default
Setp 2. Change
Redirect / https://openerpweb.com/
Redirect /open https://openerpweb.com/

Step 3. sudo /etc/init.d/apache2 restart

Setp 4. Remove Secruity from folder.
sudo chmod 777 -R /var/www/data_migration/

chmod 777

0 = —
1 = –x
2 = -w-
3 = -wx
4 = r–
5 = r-x
6 = rw-
7 = rwx

To Find Folder Permissions.

stat -c %a /opt/

Git Setting

For Windows Download Git Bash

Generating rsa keys { Better to enter passphrase for securing your private key }

ssh-keygen -t rsa -C “baharali@imsciences.edu.pk”

Adding rsa public key
First View your private key with the command.
cat ~/.ssh/id_rsa.pub {~ used for active directory}

Go to your Git Account & In Profile Setting add your public key. {You can also view your public key directly from file you have your public key}

Adding your key (Private Key) to SSH
ssh-add /home/baharali/.ssh/id_rsa

View your key added to SSH
ssh-add -l

For Global Configuration enter theses commands
git config –global user.name “Bahar Ali”
git config –global user.email “baharali@imsciences.edu.pk”

To see the git configuration, enter.

git config --list

Then Clone The repository you want to work on. example is given below.
git clone git@dev.imsciences.edu.pk:cms-core/documentation.git. {Clone is getting source code for first time,
Thus host Authentication will be done, For
Authentication your Passphrase will be required}
To show all directory and file in origion

Go to specific directory (linux commands are used)
cd /documentation

vi README {Do some changes in file; for changes press i key from keyboard.
then exit from edit mode by pressing Esc key from keyboard.
Then exit from vi editor by entering command wq: }

To View changed you made in file use command
git diff

Add file first
git add README.txt

Then Commit changes you made by
git commit -m ‘Here Message what you are going to commit’ {First you have to stage file status,
thus change file to stage and then commit use below command}
git commit -a -m ‘Here Message what you are going to commit’

Command used to show you differ status of your file
git status README

To commit change to master use command
git push origin master

To replace remote branch with local brach ( Just init repo, make changes, commit changes and then)
git push -f origin master


To view remote repositories you have added for fetch and push.
git remote -v

To remove remote repositories.
git remote rm origin

To add remote repositories.
git remote add origin git@dev.imsciences.edu.pk:baharali/oseaf.git

For Fresh Setting
Remove these folders
sudo rm -R /home/baharali/.ssh
sudo rm -R /home/baharali/documentation
Then make your setting as above..

To add remote repositories and starting git/ Start git in an existing directory, which is not empty.

git init

git remote add origin git@github.com:inovtec-solutions/opencampus.git

git fetch (not necessary)

git checkout master -f (-f is used to force checkout master branch)

git reset –hard


Git reset branch, back to specific commit.

git reset --hard <commit_id>

Adding commits of your choice to a specific branch.

git cherry-pick <commit_id>

To restore back file after  changes.

git checkout — <path to file>

Git Setting for .gitignore file.

git rm -rf --cached .
git add .


Android Source download Commands

mkdir ~/bin
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
sudo apt-get install curl
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
mkdir android
cd android
repo init -u https://android.googlesource.com/platform/manifest
git –version
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
repo sync

You can simply disable Firewall
sudo ufw disable

Connecting to Server using SSH:
ssh baharali@
Mounting Network Drive:
Before mounting install nfs
sudo apt-get install nfs-common
sudo mount.nfs /mnt/nas-drive

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

wget http://nightly.openerp.com/7.0/nightly/src/openerp-7.0latest.tar.gz

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)


Cron Jobs:

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

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

# m h  dom mon dow   command
53 12,13 * * 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” — engr.baharali@gmail.com < /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.

Searching previous Command, containing some text.

To search command (tailf /var/log/openerp-server/erp.log)

Command contain “.log” text, thus to search it, command will be;

baharali@baharali:~$ history | grep .log