6、mkfifo 是最酷的一个,你一定知道如何创建管道 输送grep的结果到LESS,可能甚至perl。但是你知道如何使2个命令通过1个命名管道沟通?看下图,创建管道,开始写到它。
然后读取它:
7、ldd, 想知道java链接到哪个Linux线程库?
# ldd /usr/java/jre1.5.0_11/bin/java
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00bd4000)
libdl.so.2 => /lib/libdl.so.2 (0x00b87000)
libc.so.6 => /lib/tls/libc.so.6 (0x00a5a000)
/lib/ld-linux.so.2 (0x00a3c000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00bd4000)
libdl.so.2 => /lib/libdl.so.2 (0x00b87000)
libc.so.6 => /lib/tls/libc.so.6 (0x00a5a000)
/lib/ld-linux.so.2 (0x00a3c000)
8、col, 想保存帮助页面为纯文本?
# PAGER=cat
# man less | col -b > less.txt
# man less | col -b > less.txt
9、xmlwf, 需要知道一个XML文档或许是配置文件是否合理?
# curl -s 'http://bashcurescancer.com' > bcc.html
# xmlwf bcc.html
# perl -i -pe 's@<br/>@<br>@g' bcc.html
# xmlwf bcc.html
bcc.html:104:2: mismatched tag
# xmlwf bcc.html
# perl -i -pe 's@<br/>@<br>@g' bcc.html
# xmlwf bcc.html
bcc.html:104:2: mismatched tag
10、lsof 列出打开文件,你可以用它做很多很cool的事情,比如查找哪个接口是开放的?
# lsof | grep TCP
portmap 2587 rpc 4u IPv4 5544 TCP *:sunrpc (LISTEN)
rpc.statd 2606 root 6u IPv4 5585 TCP *:668 (LISTEN)
sshd 2788 root 3u IPv6 5991 TCP *:ssh (LISTEN)
sendmail 2843 root 4u IPv4 6160 TCP badhd:smtp (LISTEN)
vsftpd 9337 root 3u IPv4 34949 TCP *:ftp (LISTEN)
cupsd 16459 root 0u IPv4 41061 TCP badhd:ipp (LISTEN)
sshd 16892 root 3u IPv6 61003 TCP badhd.mshome.net:ssh->kontiki.mshome.net:4661 (ESTABLISHED)
Note: OpenBSD 101 pointed out that “lsof -i TCP” a better way to obtain this same information. Thanks!Or find the number of open files a user has. Very important for running big applications like Oracle, DB2, or WebSphere:
# lsof | grep ' root ' | awk '{print $NF}' | sort | uniq | wc -l
179
portmap 2587 rpc 4u IPv4 5544 TCP *:sunrpc (LISTEN)
rpc.statd 2606 root 6u IPv4 5585 TCP *:668 (LISTEN)
sshd 2788 root 3u IPv6 5991 TCP *:ssh (LISTEN)
sendmail 2843 root 4u IPv4 6160 TCP badhd:smtp (LISTEN)
vsftpd 9337 root 3u IPv4 34949 TCP *:ftp (LISTEN)
cupsd 16459 root 0u IPv4 41061 TCP badhd:ipp (LISTEN)
sshd 16892 root 3u IPv6 61003 TCP badhd.mshome.net:ssh->kontiki.mshome.net:4661 (ESTABLISHED)
Note: OpenBSD 101 pointed out that “lsof -i TCP” a better way to obtain this same information. Thanks!Or find the number of open files a user has. Very important for running big applications like Oracle, DB2, or WebSphere:
# lsof | grep ' root ' | awk '{print $NF}' | sort | uniq | wc -l
179
提示,匿名评论者指出应该用“sort -u”代替sort | uniq,本人忘记了-u flag,谢谢!