Saturday, August 30, 2008
How to change internet ip under ubuntu
$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 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
quiet
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
quiet
### END DEBIAN AUTOMAGIC KERNELS LIST
# This is a divider, added to separate the menu items below from the Debian
# ones.
title Other operating systems:
root
# 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.
grub>quit
$reboot
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)
savedefault
makeactive
chainloader +1
then restart...
Friday, August 29, 2008
Host key changed by using ssh
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 "ssh_host_rsa_key.pub" 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/ssh_host_rsa_key.pub" 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
#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]"
EndSection
Section "Modes"
Identifier "Modes[0]"
Modeline "1280x1024" 108.88 1280 1360 1496 1712 1024 1025 1028 10
60
Modeline "1280x1024" 106.97 1280 1360 1496 1712 1024 1025 1028 10
59
Modeline "1280x1024" 105.15 1280 1360 1496 1712 1024 1025 1028 10
59
EndSection
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 kernel.org:
#cd /usr/src/
#wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.bz2
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
#makemenuconfig
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".
And
#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
savedefault
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
savedefault
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
savedefault
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
savedefault
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:
CONFIG_SCSI_SATA=y
CONFIG_SCSI_SATA_SVW=m
CONFIG_SCSI_ATA_PIIX=m
CONFIG_SCSI_SATA_NV=m
CONFIG_SCSI_SATA_PROMISE=m
CONFIG_SCSI_SATA_SX4=m
CONFIG_SCSI_SATA_SIL=m
CONFIG_SCSI_SATA_SIS=m
CONFIG_SCSI_SATA_VIA=m
CONFIG_SCSI_SATA_VITESSE=m
CONFIG_SCSI_BUSLOGIC=m
But in 2.6.24,it likes:
CONFIG_ATA=m
# CONFIG_ATA_NONSTANDARD is not set
CONFIG_ATA_ACPI=y
CONFIG_SATA_AHCI=m
CONFIG_SATA_SVW=m
CONFIG_ATA_PIIX=m
CONFIG_SATA_MV=m
CONFIG_SATA_NV=m
CONFIG_PDC_ADMA=m
CONFIG_SATA_QSTOR=m
CONFIG_SATA_PROMISE=m
CONFIG_SATA_SX4=m
CONFIG_SATA_SIL=m
CONFIG_SATA_SIL24=m
CONFIG_SATA_SIS=m
CONFIG_SATA_ULI=m
CONFIG_SATA_VIA=m
CONFIG_SATA_VITESSE=m
CONFIG_SATA_INIC162X=m
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
-- Epicurus
the difference between .bashrc and .bash_profile
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
fi
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
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/
and
$ 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/
do:
$vi firefox
add
#!/bin/sh
#
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
Applications/Debian/App/System/KMenuEdit
Use this tool to add new icon. Highlight the "Internets"column
type
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
cannot open shared object file: No such file or directory
For example , I can not find the opencv library "libcv.so.1", so I type:~$ whereis libcv.so.1
libcv.so: /usr/lib/libcv.so.0 /usr/local/lib/libcv.so.0 /usr/local/lib/libcv.so.1 /usr/local/lib/libcv.so
~$ locate libcv.so.1
/usr/local/lib/libcv.so.1
/usr/local/lib/libcv.so.1.0.0
you can open "/etc/ld.so.conf"
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 ld.so.conf 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 libcvaux.so.0 -> /usr/local/lib/libcvaux.so.0
lrwxrwxrwx 1 root root 25 2006-07-23 16:16 libcv.so.0 -> /usr/local/lib/libcv.so.0
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/ld.so.conf"
Tuesday, August 5, 2008
How to change the resolution under Debian system
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 :
lsmod
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
#var/log/Xorg.0.log
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
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.