Saturday, August 30, 2008

How to change internet ip under ubuntu

The fast way should be
$cd /etc/networks/
$sudo vi interface
then you can add your ip address to this file
$sudo /etc/init.d/networking restart
This is restarting your network using new ip address.

dual boot vista and ubuntu

If you install vista first, then you can install ubuntu directly. Ubuntu can add vista system to the Grub boot loader automatically.
If you install ubuntu first and want to get vista, you should be careful . Because vista dont add ubuntu to its bootloader.
Before install vista, you should save your boot information. It's in /boot/grub/menu.lst.

To save that file just let you remember the partition of the hard drive, for example, I install ubuntu in the 6th partition on the first hard disk (ONLY ONE) and vista in the 2th partition on the same disk. It should like:

title Ubuntu 8.04.1, kernel 2.6.24-19-generic
root (hd0,6)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=3ee4ca11-0ceb-4071-8854-b43f86bf25f8 ro quiet splash
initrd /boot/initrd.img-2.6.24-19-generic

title Ubuntu 8.04.1, kernel 2.6.24-19-generic (recovery mode)
root (hd0,6)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=3ee4ca11-0ceb-4071-8854-b43f86bf25f8 ro single
initrd /boot/initrd.img-2.6.24-19-generic

title Ubuntu 8.04.1, memtest86+
root (hd0,6)
kernel /boot/memtest86+.bin


# This is a divider, added to separate the menu items below from the Debian
# ones.
title Other operating systems:

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda3

Because vista rewrite the MBR which is a headfile in the disk. MBR will tell computer whereis the booter. Vista will erase the MBR, so it can not find ubuntu. So we need write boot information in MBR by Ubuntu's boot loader :"grub".
So we do:
1,put in your ubuntu cd
2,restart from cd
3,choose "try ubuntu without any change to your computer"
4,open a terminal
5, in the comand line ,type:
$sudo grub
grub>root (hd0,6) //here you need know which partition is your ubuntu stand.
grub>setup (hd0) //here setup MBR file.
6,after reboot computer, you will go into the ubuntu system, now do:
$cd /boot/grub
$vi menu.lst
then add follow code to the last line of menu.lst

title Windows Vista/Longhorn (loader)
root (hd0,2)
chainloader +1

then restart...

Friday, August 29, 2008

Host key changed by using ssh

When you use ssh to connect the host, the host should give its hostkey (in /etc/ssh/ to you, and your computer will check "$HOME/.ssh/known_hosts",compare their hostkey, if it can not find this host in "known_hosts",it will ask you if you want to add it. If you are sure this key is correct, then you can add it.
If it find the matched name in known_hosts, but the host key is not matching with that key the host has gived. It will failed to connect. If you are sure the hostkey has been changed and want to use new hostkey, then you can delete the old hostkey in "known_hosts",and do "$ssh username@ip" again, this time you have choice to add new hostkey to file.

In the "" and "known_hosts", the key is writen in unreadable format. If you want to see it or regenerate new key, you should use command "ssh-keygen". For example, you can use "ssh-keygen -l -f /etc/ssh/" to see the readable format of the key. For detail information ,do "man ssh-keygen".

There are three different key file, rsa,rsa1 and dsa. You can choose different protocal to connect host. But normally, it should use rsa.

Thursday, August 28, 2008

Suspend problem for ubuntu hardy

A great guy gets the solution for this problem ,just run :

#echo SUSPEND_MODULES=\"ehci_hcd\" > /etc/pm/config.d/WORKAROUND

I don't know why,but it works...

Monday, August 18, 2008

How to log in Linux remote and copy files

$:ssh [username]@[ip]
then if it ask you yes or no,just say yes, type your password.
If you want get x-window, use:
$ ssh -x [username]@[ip]

If you want to copy file from another computer:
$scp [username]@[ip]: /from/file1 /to/file2
If it's a directory,then use:
$scp -r [username]@[ip]: /from/directory1 /to/direcotry2

Friday, August 15, 2008

Two weeks playing on debian

It's awfull to play on debian etch..

I spent almost two weeks to solve debian system problems and upgrade the kernel from 2.6.8 to 2.6.18.

It's first time for me to play linux as a root, also first time for me to touch the heart of computer-kernel...

The first problem is no higher resolution for my new LCD.

The second problem is no mouse been found.

The third problem is ungrade failed.

I write the problem and solution here for me and other guys who have same problem.

1,for higher resolution.

All x-server information was setted in /etc/X11/xorg.conf. Before you want to change it ,you should save it in a copy file,like xorg.conf_old.

First you should know your graphic card information, of couse ,sometimes you don't know ,becouse you are not the guy who build it. If you want to know it ,the best way should be to look /var/log/Xorg.log.0. There you can see many information about the xserver. 

From log file ,I see my graphic card is nVidia, which need nv driver. And I see the best resolution 1280*1024..You also can see why some mode of resolution can not be used by xserver..(such as frequence much more than maxmimum 144MHz). For Lcd, YOu don 't need big frequence, 60Hz is ok. If there is no right mode , you can add modeline in xorg.conf by yourself. 

For example:

Section "Monitor"
 DisplaySize 380 300
 HorizSync 31-64
 Identifier "Monitor[0]"
 ModelName "P19-1"
 Option "DPMS"
 VendorName "FUS"
 VertRefresh 59-76
 UseModes "Modes[0]"

Section "Modes"
 Identifier "Modes[0]"
 Modeline "1280x1024" 108.88 1280 1360 1496 1712 1024 1025 1028 10
 Modeline "1280x1024" 106.97 1280 1360 1496 1712 1024 1025 1028 10
 Modeline "1280x1024" 105.15 1280 1360 1496 1712 1024 1025 1028 10

In fact , my problem is that I choose wrong driver "vesa" for gcard. 

I do :(# as root)

#dpkg-reconfigure -phigh xserver-xorg

It show me to choose driver,so I choose "nv". Now restart x server by type "startx" in shell or CTL+ALT+BACKSPACE.

This time I can not use mouse anymore.

I use old input setting for the mouse and restartx. This time it works. I can see the higher resolution in Desktop->preference->screen resolution. Then I choose higher resolution. I get it.

2, no sound .

Old kernel version is 2.6.8, but my debian is etch which should be has 2.6.18 or newer version . 

In linux ,alsa is a tool to manage the sound setting.

For 2.6.8, alsa is a part of kernel. But in etch ,it need more modules .

I install alsa-base and alsa-util by "apt-get install alsa-base alsa-util". 

Now it works.

3,update you kernel in etch.

Fisrt you should update package database and install all needed package:

#apt-get update

#apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 build-essential

(1)download the kernel souce, two way :

   one way is from debian kernel, you can do:

   #apt-get install linux-souce-2.6.18

   If you want to know the new version of linux-souce, you can do "#apt-get search      linux-souce".

   Another way is to download from

   #cd /usr/src/


   I use second method.

(2), After download , unpack the souce code:

   #cd /usr/src/

   #tar -xjf linux-2.6.18.tar.bz2

   #ln -s /usr/src/linux.2.6.18 linux

   #cd linux

   #make clean && make mrproper

   Then copy old configure file to here if you want to use old configure file, otherwise    skip this. 'uname -r 'is your old kernel version,for me it's 2.6.8-386

   #cp /boot/.config-'uname -r' ./.config   


    This command will show a menu, you need choose "Load an alternate configuration file" and it will show you ./config, choose it and type "yes","exit".If it ask you if save the configure file ,you choose "yes".


   #make-kpkg clean

   #fakeroot make-kpkg --append-to-version=-custom kernel_image kernel_headers

    wait about one or two hours.

    After it finish, if there is no errors:

    #cd /usr/src

    Now install these deb file, as it's deb file ,so somebody call it's in debian way.

    #dpkg -i linux-image-2.6.18-custom_2.6.18-custom-10.00.Custom_i386.deb

     #dpkg -i linux-headers-2.6.18-custom_2.6.18-custom-10.00.Custom_i386.deb

   After that, do:

    #cd /boot

    #apt-get install module-init-tools initrd-tools procps

    #mkinitrd -o /boot/initrd.img-2.6.18-custom 2.6.18-custom

    #cd /boot/grub

    #vi menu.lst

     Add "initrd /boot/initrd.img-2.6.18-custom" in the file like this:

       ## ## End Default Options ##

title Debian GNU/Linux, kernel 2.6.18-custom
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-custom root=/dev/sda1 ro
initrd /boot/initrd.img-2.6.18-custom

title Debian GNU/Linux, kernel 2.6.18-custom (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-custom root=/dev/sda1 ro single
initrd /boot/initrd.img-2.6.18-custom

title Debian GNU/Linux, kernel 2.6.8-2-386
root (hd0,0)
kernel /boot/vmlinuz-2.6.8-2-386 root=/dev/sda1 ro
initrd /boot/initrd.img-2.6.8-2-386

title Debian GNU/Linux, kernel 2.6.8-2-386 (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.8-2-386 root=/dev/sda1 ro single
initrd /boot/initrd.img-2.6.8-2-386

Now congratulation ,we finish upgrade.

#shutdown -r now

You will see new kernel and old kernel when you start the computer. You can choose anyone whatever.

When I update the kernel to 2.6.24, it tell me that it can not find sda1.

I go to /lib/modules/2.6.24-custom, there I didn't see ata_piix sata_via libata sd_mod scsi_mod etc modules which were needed by SATA.

I get answers from google, that because the configure file is different between 2.6.8 and 2.6.24. 

For 2.6.8, in configure file it like:


But in 2.6.24,it likes:


So if you use old configure file for 2.6.8 to configure 2.6.24, you should notice this difference.

Before you copy ,first you should change the name from CONFIG_SCSI_SATA to CONFIG_SATA.("m" is modules loaded by kernel, "y" is built in the kernel)

Monday, August 11, 2008

Don't fear death

"Why should I fear death? If I am, death is not. If death is, I am not. Why should I fear that which can only exist when I do not?"
-- Epicurus

the difference between .bashrc and .bash_profile

When you "man bash", debian will show you the difference between bashrc and bash_profile. But one word make me confuse, what's the login? Login the xwindows or terminal ?

When I log in the xWindow , I change the environment "PATH" IN .bash_profile, but it doesn't work. If I change the "PATH" in .bashrc, it works..It's suprising .

After google,,I find that the "log in" is login the termainal ,not the xwindow. So the .bash_profile does not work when you login the xwindow.

In fact .bashrc can work whatever you login termainal or xwindow.
The reason is you will find follow command in .bash_profile:

# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
. ~/.bashrc

So if you want create or add the environment variable ,it should be better to change .bashrc.

For example:

export PATH=$PATH:/home/username/lib:/usr/lib

Install firefox 3 on debian

Debian always support icewheal.. When I type firefox on the terminal , it show me icewheal windows. At the beginning , I don't know what' wrong.

When I do :

$ whereis firefox
firefox: /usr/bin/firefox /usr/lib/firefox /usr/X11R6/bin/firefox /usr/bin/X11/firefox /usr/share/man/man1/firefox.1.gz

I go to /usr/bin/
$ ls -al firefox
firefox -> ../lib/iceweasel/iceweasel

Now I get it..The problem is Debian build a soft link from firefox to iceweasel.

So we need build a new soft link to the real firefox .

I do:
$ mv firefox firefox.old
# ln -s " /home/my/firefox/directory/firefox"

so let 's see what happen in /usr/lib

$ls -al firefox
firefox -> /home/my/firefox/directory/firefox

When I run firefox ,it turn out "need gtk2,10"
Debian just has gtk2.8.

I goolgle it and download gtk2.10 ..It' s deb file , so I just need

$dpkg-deb -x libgtk2.0-0_2.10.13-2~bpo.1_i386.deb ~/lib/gtk2-10

As deb is a specil file, you just need extract it by dpkg and it will install by itself.

If you download the tar.gz file ,you need configure and make install manually.

Now we need tell firefox where is the gtk 2.10.

go to ~/firefox/
$vi firefox


export LD_LIBRARY_PATH="/home/panda/lib/gtk2-10/usr/lib"

Now restart the firefox, you can use it now..

I also want to get icon on the debian panel.

So I go to

Use this tool to add new icon. Highlight the "Internets"column
File/new items/

But after I do this, I still can't see new icon on my Application/Internet

I don't know why.

But I find that I can change the old icon,such as iceweales and opera..

So I change iceweales to firefox and save it.

Now the iceweales icon become firefox icon..

How to find the shared library

Sometimes after you install the software on linux, when you run it,, it will warn you

cannot open shared object file: No such file or directory

For example , I can not find the opencv library "", so I type:

~$ whereis /usr/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/

~$ locate

you can open "/etc/"
if you can not find /usr/local/lib in that file, you should add this file as root.
else if you see it in , you can do:
~# /sbin/ldconfig
you run ldconfig to update share library link.

Maybe you worry about if the opencv library work because you see old version in /usr/lib, the new version in /usr/local/lib,and the contain two directory .

Don't worry about that, because the linux 's shared library is linked dynamically.
You can go to /usr/lib and type:

~$ ls -al libcv*
You will find:

lrwxrwxrwx 1 root root 28 2006-07-23 16:21 -> /usr/local/lib/
lrwxrwxrwx 1 root root 25 2006-07-23 16:16 -> /usr/local/lib/

so they link with each other now. Linux can find the new version automatically (by name ).

We learn that after we install shared library, we should update dynamic link in the system by "ldconfig". Before do this , you should check if the shared library's route in the "/etc/"

Tuesday, August 5, 2008

How to change the resolution under Debian system

Now i have a new computer which has debian system ,a kind of Linux system but has some different aspects with suse and red hat.
The nice thing is I have right to do everything on the computer, not like just a user.
Original screen resolution is 1024*768, but I get a better Lcd screen which need 1280*1024 to show image .

First I google many method to do it.
Second I want to know which Gcard I am using .
lspci to see the pci card.

Also you can check module which your system load :


go to /etc/X11,and find xorg.conf. here you can set the x server system ,such as mouse ,monitor,screen etc..

If you want to see what's wrong when the system is doing by this xorg.conf, you can go to

to see what happen ..

if you just want to check error and warning things , you can add
egrep '^\(EE\)|\(WW\)' /var/log/Xorg.0.log

In fact , I install the wrong driver for my graphic card
I reconfigure the x server.. and choose nv instead of vesa..

Now I can get higher resolution, but I can't use the mouse. I copy old file's mouse setting to new xorg.conf. So it works..Although I get some warning information in my log file ..

some thing about motor encoder

A new word is odometry , which is geometry parameter you can get from robot control, such as x and y position after robot moving.

If you want to calculate odometry automatic , you should need encoder on motor .\

Encoder Resolution=PI*Diameter/PulsePerRotation/gearRatio.

First time , I didn't get what gear ratio mean, so I get the wrong encoder resolution.