1. Save man-page asPDF file

For example, you want save the manpage of APT to PDF file.

man -t apt | ps2pdf – apt.pdf

2. Stamp a text line on top of the PDF pages

This command will add a stamp “This text gets stamped on the top of the pdf pages.” on top of each PDF pages.

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

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

4. Create a local compressed archive (tarball) from remote host directory

ssh user@host “tar -zcf – /path/to/dir” > dir.tar.gz

5. View a brief log over ssh

ssh -t remotebox “tail -f /var/log/remote.log”

6. Print diagram of user or group

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|dot -Tpng|display

7. Draw kernel module dependency graph

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

8. Generate strong password

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

9. Find all files larger than 500M and less than 1GB

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

10. Limit the cpu usage of a process

sudo cpulimit -p pid -l 50