Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts

Monday, August 18, 2008

How to log in Linux remote and copy files

login:
$: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

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

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

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

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 :

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