11 条Linux/Unix 管理员常用命令

1-保存man-page 为pdf文件

man -t awk | ps2pdf - awk.pdf

2-Duplicate installed packages from one machine to the other (RPM-based systems)

ssh root@remote.host "rpm -qa" | xargs yum -y install

3-Stamp a text line on top of the pdf pages to quickly add some remark, comment, stamp text, … on top of (each of) the pages of the input pdf file

echo "This text gets stamped on the top of the pdf pages." | enscript -B -f Courier-Bold16 -o- | ps2pdf - | pdftk input.pdf stamp - output output.pdf

4-Display the number of connections to a MySQL Database

mysql -u root -p -BNe "select host,count(host) from processlist group by host;" information_schema

5-Create a local compressed tarball from remote host directory

ssh user@host "tar -zcf - /path/to/dir" > dir.tar.gz

6-tail a log over ssh

ssh -t remotebox "tail -f /var/log/remote.log"

7-Print diagram of user/groups

awk 'BEGIN{FS=":"; print "digraph{"}{split($4, a, ","); for (i in a) printf "\"%s\" [shape=box]\n\"%s\" -> \"%s\"\n", $1, a[i], $1}END{print "}"}' /etc/group|display

8-Draw kernel module dependancy graph.

lsmod | perl -e 'print "digraph \"lsmod\" {";;while(){@_=split/\s+/; print "\"$_[0]\" -> \"$_\"\n" for split/,/,$_[3]}print "}"' | dot -Tpng | display -

9-Create strong, but easy to remember password

read -s pass; echo $pass | md5sum | base64 | cut -c -16

10-Find all files larger than 500M and less than 1GB

find / -type f -size +500M -size -1G

11-Limit the cpu usage of a process

sudo cpulimit -p pid -l 50

很有“一行帝”风范啊~~

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/22783.html