Tuesday, January 27, 2009

Bazaar Merge - How to

Updating your branch from the main branch

While you commit changes to your branch, it's likely that other people will also continue to commit code to the parent branch.

To make sure your branch stays up to date, you should merge changes from the parent into your personal branch:

$ bzr merge Merging from saved parent location: http://bazaar.launchpad.net/~bzr/bzr-gtk/trunk All changes applied successfully.

Check what has changed:

$ bzr diff

If you're happy with the changes, you can commit them to your personal branch:

$ bzr commit -m "Merge from main branch" Committed revision 295.

Merging your work into the parent branch

After you've worked on your personal branch of bzr-gtk, you may want to send your changes back upstream to the project. The easiest way is to use a merge directive.

A merge directive is a machine-readable request to perform a particular merge. It usually contains a patch preview of the merge and either contains the necessary revisions, or provides a branch where they can be found.

Replacing mycode.patch, create your merge directive:

$ bzr send -o mycode.patch Using saved parent location: http://bazaar.launchpad.net/~bzr/bzr-gtk/trunk

You can now email the merge directive to the bzr-gtk project who, if they choose, can use it merge your work back into the parent branch.

Learning more

To learn about Bazaar on the command-line:

$ bzr help

To learn about Bazaar commands:

$ bzr help commands

To learn about the ''foo'' topic or command:

$ bzr help foo

Friday, January 23, 2009

Linux Network configuration (Ubuntu)

Linux Network configuration (Ubuntu)

In ubuntu we can easily configure the network using graphical interface. Here we briefly look over the command line configuration.

Determining Your IP Address

When Linux is installed, the ethernet device is called eth0

For wireless interface it will be called wlan0

The ifconfig command.

sahab@sahab:~$ ifconfig

eth0 Link encap:Ethernet HWaddr 00:1d:7d:f8:26:74

inet addr: Bcast: Mask:

inet6 addr: fe80::21d:7dff:fef8:2674/64 Scope:Link


RX packets:173544 errors:0 dropped:0 overruns:0 frame:0

TX packets:98648 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:197413652 (188.2 MB) TX bytes:10905457 (10.4 MB)

Interrupt:20 Base address:0x8000

eth0:1 Link encap:Ethernet HWaddr 00:1d:7d:f8:26:74

inet addr: Bcast: Mask:


Interrupt:20 Base address:0x8000

lo Link encap:Local Loopback

inet addr: Mask:

inet6 addr: ::1/128 Scope:Host


RX packets:5320 errors:0 dropped:0 overruns:0 frame:0

TX packets:5320 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:1101301 (1.0 MB) TX bytes:1101301 (1.0 MB)

IP Address changing

#sudo ifconfig eth0 netmask up

Configuration file of netwok looks like

# vim /etc/netwok/interfaces

The file looks like

auto lo #For loopback address

iface lo inet loopback

iface eth0 inet static #static ip for eth0




iface eth0:1 inet static #secondary ip



auto eth0 #auto enable on boot time

auto eth0:1

Adding secondary ip

#sudo ifconfig eth0:0 netmask up

Start and stop - Network

#sudo ifup eth0

#sudo ifdown eth0

#sudo /etc/init.d/networking stop

#sudo /etc/init.d/networking start

#sudo /etc/init.d/networking restart

Default gateway configuration

sahab@sahab:~$sudo route add default gw eth0

Configuring the DNS server


Vim /etc/resolve.conf

search example.com


Checking the current routing table

sahab@sahab:~$ sudo netstat -nr

Kernel IP routing table

Destination Gateway Genmask Flags MSS Window irtt Iface U 0 0 0 eth0 U 0 0 0 eth0 U 0 0 0 eth0 UG 0 0 0 eth0

Mii-tool and ethtool - Checking network card status and speed

sahab@sahab:~$ sudo mii-tool -v

eth0: negotiated 100baseTx-FD flow-control, link ok

product info: vendor 00:07:32, model 17 rev 2

basic mode: autonegotiation enabled

basic status: autonegotiation complete, link ok

capabilities: 1000baseT-HD 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD

advertising: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control

link partner: 1000baseT-HD 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control

sahab@sahab:~$ sudo ethtool eth0

Settings for eth0:

Supported ports: [ TP ]

Supported link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full


Supports auto-negotiation: Yes

Advertised link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full


Advertised auto-negotiation: Yes

Speed: 100Mb/s

Duplex: Full

Port: Twisted Pair


Transceiver: internal

Auto-negotiation: on

Supports Wake-on: pumbg

Wake-on: g

Current message level: 0x00000033 (51)

Link detected: yes

Thursday, January 22, 2009

Run level - linux

Run Level Numbers

Run Level

A run level is a state of init and the whole system that defines what system services are operating. Run levels are identified by numbers.

Run level numbers (init 0 to init 6)

0 Halt the system.

1 Single-user mode (for Troubleshooting).

2 Local Multiuser with Networking but without network service (like NFS)

3 Full Multiuser with Networking

4 Not Used

5 Full Multiuser with Networking and X Windows(GUI) – Graphical mode

6 Reboot.

Edit Run Level on boot time and services (Redhat)

In redhat /etc/inittab configuration we can modify the default run level on bootime.

id:3:initdefault: l3:3:wait:/etc/rc.d/rc 3

From the first line, we know that init is going to end up at a runlevel of 3 after the system boots.

For services (like network, apache etc) “chkconfig” is used to change the service level.

#chkconfig [--level ]  

For example, if we decide to disable crond for runlevel 2, the #chkconfig --level 2 crond off command (executed by root) would turn off crond for the runlevel of 2

Running a user scripts to runlevel

For example Oracle 10G scripts can be started with the “start” argument and terminated with the “stop” argument. This meets the minimum requirements of an initscript that can be used in conjunction with the launch script /etc/rc.d/rc.

Place the script in /etc/rc.d/init.d and run (as root)

chmod +x /etc/rc.d/init.d/oracle

to make the script executable. If you are concerned about normal users seeing the script, you could try more restrictive file permissions, as long as the script is executable by root as a standalone script.

Notice the two comments lines in the script:

#chkconfig: 2345 80 05 #description: Oracle 10G Server

These lines are needed by chkconfig to determine how to establish the initial runlevels to add the service as well as set the priority for the start-and-stop script execution order. These lines denote the script will start Oracle 10G server for the runlevels 2, 3, 4 and 5. In addition, the start priority will be set to 80 while the stop priority will be 05.

Now that the script is in place with the appropriate execute permissions and the required chkconfig comments are in place, we can add the initscript to the chkconfig configuration by typing, as root, chkconfig --add oracle.

Using chkconfig's query feature, we can verify our addition:

[root]# chkconfig --list | grep oracle oracle        0:off     1:off   2:on   3:on   4:on   5:on  6:off 

Changing Service run level – Ubuntu:

#sudo apt-get install sysv-rc-conf #sudo sysv-rc-conf Using sysv-rc-conf we can easily manage the services in runlevel.

File delete in tmp folder after restart - Ubuntu

When ever we copy the file in /tmp folder it will deleter automatically when we restart the computer.

If we want more some days means edit the following configuration file

vim /etc/default/rcS


Wednesday, January 21, 2009

Grub Fix - Windows

Uninstall Grub (fix bootMBR) to restore Windows xp bootmbr

For old PCs, just use Windows XP install disk to repair it by use fixboot and fixmbr commands.

For PCs with SATA disks, the windows XP install disk can not fix the boot problem. You need use Windows Vista install DVD to fix the Grub problem.

How to use Windows Vista install DVD to fix the boot problem?

1. Put the Windows Vista installation disc in the disc drive, and then start the computer (set to boot from CD in BIOS).
2. Press a key when you are prompted.
3. Select a language, a time, a currency, a keyboard or an input method, and then click Next.
4. Click Repair your computer.
5. Click the operating system that you want to repair (Vista in this case), and then click Next.
6. In the System Recovery Options dialog box, click Command Prompt.
7. Once in the command prompt, type exactly Bootrec.exe /FixMbr and then press ENTER. You will see "operation completed successfully."
8. Reboot and set BIOS to boot from the HDD again.

GRUB will be overwritten in step 7 and your old bootloader (windows xp, windows vista) will once again take control of loading your OS(s).

Grub Fix - Ubuntu

Grub Fix – Ubuntu

Installing Windows After Ubuntu

Normally when Windows is installed after Ubuntu the master boot record will be overwritten. This means that you would have to boot off a LiveCD and re-install grub. The steps are

#sudo grub

From the grub


grub> find /boot/grub/stage1 (If you installed a /boot partition, do find /grub/stage1)



It dispay partition which contains your grub files. I have two linux OS installed.

Then run the following command

>root (hd0,1)
>setup (hd0)

(hd0) = the MBR for the hard disk which is where grub needs to install itself too for it to load on bootup.

How-to-encrypt and dycrypt -file-with-passphrase

How to encrypt and dycrypt file with passphrase.


Mcrypt is a simple crypting program, a replacement for the old unix crypt(1). When encrypting or ecrypting a file, a new file is created with the extension .nc and mode 0600. The new file keeps the modification date of the original. The original file may be deleted by specifying the -u parameter. If no files are specified, the standard input is encrypted to the standard output.


sahab@sahab:~$ sudo mcrypt -uz testing

Enter the passphrase (maximum of 512 characters)

Please use a combination of upper and lower case letters and numbers.

Enter passphrase:

Enter passphrase:

File testing was encrypted.

sahab@sahab:~$ ls



sahab@sahab:~$ sudo mcrypt -d testing.gz.nc

Enter passphrase:

File testing.gz.nc was decrypted.

sahab@sahab:~$ mcrypt --help

Mcrypt encrypts and decrypts files with symmetric encryption algorithms.

Usage: mcrypt [-dFusgbhLvrzp] [-f keyfile] [-k key1 key2 ...] [-m mode] [-o keymode] [-s keysize] [-a algorithm] [-c config_file] [file ...]

-g, --openpgp Use the OpenPGP (RFC2440) file format.

--openpgp-z INTEGER Sets the compression level for openpgp

packets (0 disables).

-d, --decrypt decrypts.

-s, --keysize INTEGER Set the algorithm's key size (in


-o, --keymode KEYMODE Specify the keyword mode. Use the

--list-keymodes parameter to view all


-f, --keyfile FILE Specify the file to read the keyword


-c, --config FILE Use configuration file FILE.

-a, --algorithm ALGORITHM

Specify the encryption and decryption

algorithm. Use the --list parameter to

see the supported algorithms.

--algorithms-directory DIRECTORY

Set the algorithms directory.

-m, --mode MODE Specify the encryption and decryption

mode. Use the --list parameter to see

the supported modes.

--modes-directory DIRECTORY

Set the modes directory.

-h, --hash HASH Specify the hash algorithm to be used.

Use the --list-hash parameter to view

the hash algorithms.

-k, --key KEY1 KEY2...KEYN

Specify the key(s)

--noiv Do not use an IV.

-b, --bare Do not keep algorithm information in

the encrypted file.

-z, --gzip Use gzip to compress files before


-p, --bzip2 Use bzip2 to compress files before


--flush Immediately flush the output

-l, --doublecheck Double check passwords.

-u, --unlink Unlink the input file after encryption

or decryption.

--nodelete Do not delete the output file if

decryption failed.

-t, --time Prints timing information.

-F, --force Forces output to stdout.

--echo Echo asterisks when entering the


-r, --random Use real random data (if your system

supports it).

--list Prints a list of the supported

algorithms and modes.

--list-keymodes Prints a list of the supported key


--list-hash Prints a list of the supported hash


-V, --verbose More information is displayed.

-q, --quiet Suppress some non critical warnings.

--help Prints this help

-v, --version Prints the version number

-L, --license Displays license information.

Report bugs to mcrypt-dev@lists.hellug.gr.

Sunday, January 18, 2009

Mysql community server table limitation

The effective maximum table size for MySQL databases is usually determined by operating system constraints on file sizes, not by MySQL internal limits. The following table lists some examples of operating system file-size limits.

Operating System

File-size Limit

Win32 w/ FAT/FAT32


Win32 w/ NTFS

2TB (possibly larger)

Linux 2.2-Intel 32-bit

2GB (LFS: 4GB)

Linux 2.4+

(using ext3 filesystem) 4TB

Solaris 9/10


MacOS X w/ HFS+


NetWare w/NSS filesystem


Here is the fix:

alter table_name MAX_ROWS = 10000000; (this can take a while)

To fix it for new tables, add this to you /etc/my.cnf:


This will allow tables to have up to a 256TB size limit. The default value is 4 which allows up to 4GB.

Friday, January 2, 2009

Package management - Debian and ubuntu

Debian and Ubuntu


update the local list of packages, enter in a Terminal:

#sudo apt-get update

To install all available updates:

#sudo apt-get upgrade

To install a package:

#sudo apt-get install package

To remove a package:

#sudo apt-get remove package

To permanently remove the package

#sudo apt-get purge package

To list other apt commands and options:

#apt-get help


To search for a package:

#apt-cache search package

eg) apt-cache search mp3

This will search for packages that have "mp3" in the name or description.


It is a simple command to add CDROMs to apt's sources.list file. Its syntax is a variation on this basic command line

#apt-cdrom add


It is a tool to read apt's apt.conf file and is very useful to dump it to screen. Its syntax is a variation of these basic options:

#apt-config [options] shell

Shell mode
#apt-config [options] dump
Show the configuration options in the screen
If you are behind proxy server means follow this steps

Add the following lines to /etc/apt/apt.conf (might be empty) file worked for me while the instructions above did not.

http::proxy “http://xx.xx.xx.xx:8080/”

If you need to authenticate use

http::proxy “http://DOMAIN\username:Password@FQDN.or.IP:8080/”