my 3rd week in Den Haag, Nederland for 3 months business trip. the weather is freaking cold here that made me so lazy to go out. but on the 1st weekend i went to Amsterdam and got a chance to see the best part :)
hopefully i'll enjoy my stay here, like my buddy said for a few times, nice place!
Sunday, February 12, 2006
Wednesday, February 08, 2006
unix tip: ssh - get rid of yes/no message
normally when you ssh to a new unix/linux box, you'll be prompted with yes/no message like below:
$ ssh hostname1
The authenticity of host 'hostname1 (ip_address_hostname1)' can't be established.
RSA key fingerprint is be:eb:c6:2f:0e:d9:56:38:8c:f7:17:cd:96:f9:3c:f5.
Are you sure you want to continue connecting (yes/no)?
most of the time you just type yes, key in your password and you are in the box. but how about you need to create a script to ssh to a few servers to run some commands? then this option become handy:
$ ssh -o StrictHostKeyChecking=no hostname1
username@hostname1's password:
key in your password and you are in and of course you can use ssh-agent to get rid of the password prompt as well :)
$ ssh hostname1
The authenticity of host 'hostname1 (ip_address_hostname1)' can't be established.
RSA key fingerprint is be:eb:c6:2f:0e:d9:56:38:8c:f7:17:cd:96:f9:3c:f5.
Are you sure you want to continue connecting (yes/no)?
most of the time you just type yes, key in your password and you are in the box. but how about you need to create a script to ssh to a few servers to run some commands? then this option become handy:
$ ssh -o StrictHostKeyChecking=no hostname1
username@hostname1's password:
key in your password and you are in and of course you can use ssh-agent to get rid of the password prompt as well :)
Friday, January 13, 2006
unix tip: ps - tree hierarchy view
linux ps command provides a nice process-tree hierarchy view when invoked with the -f or --forest
eg:
$ ps auxw --forest | less
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 3 0.0 0.0 0 0 ? SW 2005 0:00 [migration/1]
root 2 0.0 0.0 0 0 ? SW 2005 0:00 [migration/0]
root 1 0.0 0.0 1508 508 ? S 2005 0:38 init [3]
root 4 0.0 0.0 0 0 ? SW 2005 0:00 [keventd]
root 5 0.0 0.0 0 0 ? SWN 2005 0:00 [ksoftirqd/0]
root 6 0.0 0.0 0 0 ? SWN 2005 0:00 [ksoftirqd/1]
root 9 0.0 0.0 0 0 ? SW 2005 0:00 [bdflush]
root 7 0.0 0.0 0 0 ? SW 2005 0:30 [kswapd]
root 8 0.0 0.0 0 0 ? SW 2005 0:32 [kscand]
root 10 0.0 0.0 0 0 ? SW 2005 1:26 [kupdated]
root 11 0.0 0.0 0 0 ? SW 2005 0:00 [mdrecoveryd]
root 21 0.0 0.0 0 0 ? SW 2005 2:29 [kjournald]
root 86 0.0 0.0 0 0 ? SW 2005 0:00 [khubd]
root 3677 0.0 0.0 0 0 ? SW 2005 0:00 [kjournald]
root 3893 0.0 0.0 3972 1556 ? S 2005 0:29 /usr/sbin/sshd
root 25443 0.0 0.0 8744 3148 ? S 2005 0:00 \_ sshd: usercchx [priv]
usercchx 25529 0.0 0.0 8744 3360 ? S 2005 0:02 | \_ sshd: usercchx@pts/1
usercchx 25532 0.0 0.0 1812 728 pts/1 S 2005 0:00 | \_ -ksh
root 4540 0.0 0.0 8756 3184 ? S 2005 0:00 \_ sshd: userdju0 [priv]
userdju0 4648 0.0 0.0 8904 3484 ? S 2005 0:02 | \_ sshd: userdju0@pts/6
userdju0 4660 0.0 0.0 1808 716 pts/6 S 2005 0:00 | \_ -ksh
root 30124 0.0 0.0 8756 3184 ? S 2005 0:00 \_ sshd: userkyo1 [priv]
userkyo1 30321 0.0 0.0 8756 3404 ? S 2005 0:01 | \_ sshd: userkyo1@pts/12
userkyo1 30342 0.0 0.0 1808 700 pts/12 S 2005 0:00 | \_ -ksh
root 28994 0.0 0.0 8756 3160 ? S 2005 0:00 \_ sshd: user3 [priv]
user3 29237 0.0 0.0 8756 3376 ? S 2005 0:00 | \_ sshd: user3@pts/7
user3 29240 0.0 0.0 1804 696 pts/7 S 2005 0:00 | \_ -ksh
root 23316 0.0 0.0 8516 2500 ? S 2005 0:00 \_ sshd: root@pts/20
root 23322 0.0 0.0 4348 1348 pts/20 S 2005 0:00 | \_ -bash
root 13179 0.0 0.0 8676 2572 ? S 2005 0:00 \_ sshd: root@notty
root 7398 0.0 0.0 8748 3184 ? S 2005 0:00 \_ sshd: userdba5 [priv]
userdba5 7446 0.0 0.0 8896 3424 ? S 2005 0:01 | \_ sshd: userdba5@pts/28
userdba5 7454 0.0 0.0 1808 704 pts/28 S 2005 0:00 | \_ -ksh
or just use:
$ ps auxwf | less
but this option not available for other unix ps.
option.eg:
$ ps auxw --forest | less
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 3 0.0 0.0 0 0 ? SW 2005 0:00 [migration/1]
root 2 0.0 0.0 0 0 ? SW 2005 0:00 [migration/0]
root 1 0.0 0.0 1508 508 ? S 2005 0:38 init [3]
root 4 0.0 0.0 0 0 ? SW 2005 0:00 [keventd]
root 5 0.0 0.0 0 0 ? SWN 2005 0:00 [ksoftirqd/0]
root 6 0.0 0.0 0 0 ? SWN 2005 0:00 [ksoftirqd/1]
root 9 0.0 0.0 0 0 ? SW 2005 0:00 [bdflush]
root 7 0.0 0.0 0 0 ? SW 2005 0:30 [kswapd]
root 8 0.0 0.0 0 0 ? SW 2005 0:32 [kscand]
root 10 0.0 0.0 0 0 ? SW 2005 1:26 [kupdated]
root 11 0.0 0.0 0 0 ? SW 2005 0:00 [mdrecoveryd]
root 21 0.0 0.0 0 0 ? SW 2005 2:29 [kjournald]
root 86 0.0 0.0 0 0 ? SW 2005 0:00 [khubd]
root 3677 0.0 0.0 0 0 ? SW 2005 0:00 [kjournald]
root 3893 0.0 0.0 3972 1556 ? S 2005 0:29 /usr/sbin/sshd
root 25443 0.0 0.0 8744 3148 ? S 2005 0:00 \_ sshd: usercchx [priv]
usercchx 25529 0.0 0.0 8744 3360 ? S 2005 0:02 | \_ sshd: usercchx@pts/1
usercchx 25532 0.0 0.0 1812 728 pts/1 S 2005 0:00 | \_ -ksh
root 4540 0.0 0.0 8756 3184 ? S 2005 0:00 \_ sshd: userdju0 [priv]
userdju0 4648 0.0 0.0 8904 3484 ? S 2005 0:02 | \_ sshd: userdju0@pts/6
userdju0 4660 0.0 0.0 1808 716 pts/6 S 2005 0:00 | \_ -ksh
root 30124 0.0 0.0 8756 3184 ? S 2005 0:00 \_ sshd: userkyo1 [priv]
userkyo1 30321 0.0 0.0 8756 3404 ? S 2005 0:01 | \_ sshd: userkyo1@pts/12
userkyo1 30342 0.0 0.0 1808 700 pts/12 S 2005 0:00 | \_ -ksh
root 28994 0.0 0.0 8756 3160 ? S 2005 0:00 \_ sshd: user3 [priv]
user3 29237 0.0 0.0 8756 3376 ? S 2005 0:00 | \_ sshd: user3@pts/7
user3 29240 0.0 0.0 1804 696 pts/7 S 2005 0:00 | \_ -ksh
root 23316 0.0 0.0 8516 2500 ? S 2005 0:00 \_ sshd: root@pts/20
root 23322 0.0 0.0 4348 1348 pts/20 S 2005 0:00 | \_ -bash
root 13179 0.0 0.0 8676 2572 ? S 2005 0:00 \_ sshd: root@notty
root 7398 0.0 0.0 8748 3184 ? S 2005 0:00 \_ sshd: userdba5 [priv]
userdba5 7446 0.0 0.0 8896 3424 ? S 2005 0:01 | \_ sshd: userdba5@pts/28
userdba5 7454 0.0 0.0 1808 704 pts/28 S 2005 0:00 | \_ -ksh
or just use:
$ ps auxwf | less
but this option not available for other unix ps.
Monday, December 26, 2005
unix tip: find - limit the depth
by default find will search all subdirectories under the parent directory. but you can limit the depth by using maxdepth option.
eg:
- to limit it only to the current directory and not search through any subdirectories, use the -maxdepth 1 option.
$ find . -maxdepth 1 -name test
./test
- to search one level below of the directory use the -maxdepth 2 option.
$ find . -maxdepth 2 -name test
./scripts/test
./test
./tmp/test
- if not using -maxdepth option.
$ find . -name test
./scripts/test
./test
./tmp/test
./.snapshot/hourly.2/test
./.snapshot/hourly.2/tmp/test
./.snapshot/hourly.1/test
./.snapshot/hourly.1/tmp/test
./.snapshot/hourly.0/test
./.snapshot/hourly.0/tmp/test
eg:
- to limit it only to the current directory and not search through any subdirectories, use the -maxdepth 1 option.
$ find . -maxdepth 1 -name test
./test
- to search one level below of the directory use the -maxdepth 2 option.
$ find . -maxdepth 2 -name test
./scripts/test
./test
./tmp/test
- if not using -maxdepth option.
$ find . -name test
./scripts/test
./test
./tmp/test
./.snapshot/hourly.2/test
./.snapshot/hourly.2/tmp/test
./.snapshot/hourly.1/test
./.snapshot/hourly.1/tmp/test
./.snapshot/hourly.0/test
./.snapshot/hourly.0/tmp/test
Wednesday, December 21, 2005
unix tip: one-liner find files with different regex
instead of we type find a few times, we can use -o option.
eg:
$ find . -name "*ksh" -o -name "*txt"
./.mozilla/default/nxdv20h2.slt/cookies.txt
./scripts/sham.ksh
./scripts/java.txt
./scripts/ii.ksh
./scripts/aa.ksh
./scripts/input.txt
./scripts/output.txt
./scripts/test.ksh
./scripts/tiktok.ksh
./scripts/file.txt
./download/firefox-installer/license.txt
./sample.txt
eg:
$ find . -name "*ksh" -o -name "*txt"
./.mozilla/default/nxdv20h2.slt/cookies.txt
./scripts/sham.ksh
./scripts/java.txt
./scripts/ii.ksh
./scripts/aa.ksh
./scripts/input.txt
./scripts/output.txt
./scripts/test.ksh
./scripts/tiktok.ksh
./scripts/file.txt
./download/firefox-installer/license.txt
./sample.txt
Subscribe to:
Posts (Atom)