tar cf - * | (cd new_dir; tar xpf - )
To extract clean man pages(hardway, produces a .ps file)
cat /usr/local/man/man1/fooo.1 | gtbl | groff -mandoc > foo.ps
To extract clean man pages(easyway, produces a .ps file)
man foo | col -b > man.foo
(but this command fails sometimes with a message:
System command (cd /usr/local/man ; (echo -e ".pl 11i"; \
/bin/cat /usr/local/man/man1/mgquery.1) | /usr/bin/gtbl | \
/usr/bin/groff -Tlatin1 -mandoc | /usr/bin/less -isr) \
exited with status 141.
)
How to see who opened file /var/log/messeage
lsof /var/log/messages
How do I see what files a program opened
lsof -p progra_process_id
How do I see what process opened what network connection
netstat -na -p
A sample output:
[root@localhost root]# netstat -na -p | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:1024 0.0.0.0:* LISTEN 492/
tcp 0 0 127.0.0.1:1025 0.0.0.0:* LISTEN 609/xinetd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 479/
tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 785/
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 594/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 667/cupsd
tcp 0 0 0.0.0.0:7100 0.0.0.0:* LISTEN 709/
tcp 0 1 192.168.1.12:1193 66.218.77.68:80 LAST_ACK -
tcp 0 0 192.168.1.12:1199 66.218.77.68:80 CLOSE_WAIT 966/opera
tcp 0 0 192.168.1.12:1197 64.215.172.97:80 ESTABLISHED 966/opera
udp 0 0 0.0.0.0:1024 0.0.0.0:* 492/
udp 0 0 0.0.0.0:668 0.0.0.0:* 492/
udp 0 0 0.0.0.0:111 0.0.0.0:* 479/
udp 0 0 0.0.0.0:631 0.0.0.0:* 667/cupsd
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 1266 412/pump /var/run/pump.sock
unix 2 [ ACC ] STREAM LISTENING 2322 791/
So, let's use lsof command to see what files sshd(594) has opened:
[root@localhost root]# lsof -p 594
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
sshd 594 root cwd DIR 3,5 4096 2 /
sshd 594 root rtd DIR 3,5 4096 2 /
sshd 594 root txt REG 3,6 278744 681948 /usr/sbin/sshd
sshd 594 root mem REG 3,5 104560 360444 /lib/ld-2.3.2.so
sshd 594 root mem REG 3,6 28452 276127 /usr/lib/libwrap.so.0.7.6
sshd 594 root mem REG 3,5 30448 359811 /lib/libpam.so.0.75
sshd 594 root mem REG 3,5 15900 360253 /lib/libdl-2.3.2.so
sshd 594 root mem REG 3,5 76572 360263 /lib/libresolv-2.3.2.so
sshd 594 root mem REG 3,5 12716 359795 /lib/libutil-2.3.2.so
sshd 594 root mem REG 3,6 52616 275940 /usr/lib/libz.so.1.1.4
sshd 594 root mem REG 3,5 91624 360255 /lib/libnsl-2.3.2.so
sshd 594 root mem REG 3,5 969116 360266 /lib/libcrypto.so.0.9.7a
sshd 594 root mem REG 3,6 385220 600643 /usr/kerberos/lib/libkrb5.so.3.1
sshd 594 root mem REG 3,6 63880 600637 /usr/kerberos/lib/libk5crypto.so.3.0
sshd 594 root mem REG 3,6 5572 600598 /usr/kerberos/lib/libcom_err.so.3.0
sshd 594 root mem REG 3,6 73724 600604 /usr/kerberos/lib/libgssapi_krb5.so.2.2
sshd 594 root mem REG 3,5 52492 360258 /lib/libnss_files-2.3.2.so
sshd 594 root mem REG 3,5 1536292 245282 /lib/tls/libc-2.3.2.so
sshd 594 root 0u CHR 1,3 181068 /dev/null
sshd 594 root 1u CHR 1,3 181068 /dev/null
sshd 594 root 2u CHR 1,3 181068 /dev/null
sshd 594 root 3u IPv4 1963 TCP *:ssh (LISTEN)
How do I disable a service coming up at startup?
List all the services by issuing:
/sbin/chkconfig --list
Trun off services by issuing:
/sbin/chkconfig service_name off
To be runlevel specific (e.g., level 3, 4, 5):
/sbin/chkconfig --level 345 service_name off
Or just use (text-based command to select scripts to run
at startup):
/usr/sbin/ntsysv