From Christophe Demarey

Tech: Linux

How to set up an SSH tunnel?

ssh -L [tunnel-in-port]:[client-host]:[tunnel-out-port] [user@host-to-reach]

Example:

ssh -L 13306:localhost:3306 user@server.org

It will forward all incoming data from localhost:13306 to server.org:3306.

ssh-tunneling

Some web servers are only available through a gateway. To access it from your computer, you can also use a SSH tunnel:

ssh -L 8080:webserver:80 gw

How to search a pattern in a set of files

The best option is to use find to construct the set of files and then use grep.

find . -name Makefile | xargs grep pattern

List open ports

netstat -lnptu

Find big folders in a file system

du -hms /* | sort -nr | head

It will give the top ten of big folders sorted by size (in Mb) descending.

Find big files

find /-size +4000k -exec ls -lia {} \;

It will list files having a size > 4000k in /.

List installed packages

dpkg -l | grep '^ii'

Top 10 process using the most memory

ps aux --sort=-%mem | awk 'NR<=10{print $0}'
Retrieved from http://chercheurs.lille.inria.fr/~demarey/Tech/Linux
Page last modified on January 11, 2018, at 12:16 PM