Show Menu

KSS - Linux Shell 1 Cheat Sheet by


netstat -atnup
My all time classic, see below for details.
netstat -an | grep ESTABL­ISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | awk '{ printf­("%s­\t%­s\t­"­,$2,$1) ; for (i = 0; i < $1; i++) {print­f("*­")}; print "­" }'
Graph the number of connec­tions for each host
a: Show both listening and non-li­ste­ning,
t: Show TCP,
n: Show numerical addresses instead of trying to determine symbolic host, port or user names,
u: Show UDP,
p: Show the PID and name of the program to which each socket belongs.


tailf <file>
Output the last 10 lines of a file
tailf -n 5 <file>
Output the last 5 lines of a file
You have to use tail if you want to follow more than one file:

tail -f /var/l­og/­tom­cat­/fo­oba­r.log -f /var/l­og/­cat­ali­na.out


df -h
Show filesystem usage in human-­fri­endly format
df -i
Show inode usage
df -l
List only local filesy­stems (don't list NFS or SAMBA mounts)
More info about inodes: Check this doc !


iostat -x 5
Display full statistics for every filesy­stem, refresh every 5 seconds
The first report line provides statistics concerning the time since the system was started.


Display Linux tasks
top -p $(pgrep -d , foobar)
Monitor processes with the same name fragment 'foobar'
Some intera­ctive commands
h: display help
c: toggle between process name only / full command line
u: show the processes for a specific user only
n: display a maximum of n processes
k: kill a process
H: show threads (also called Light Weight Processes)
z: toggle between monochrome and color display


ps -ef
See every process on the system
ps -ejH
Print a process tree
ps -eLf
Get info about threads
ps -C java -o pid=
Print only the process IDs of apache tomcat
ps -o nlwp <PID>
Show the threads (Light Weight Processes) associated to a PID.

Shell keyboard shortcuts

Ctrl + a
Jump to the beginning of the line ()
Ctrl + e
Jump to the end of the line ()
Ctrl + l
Clears the screen
Ctrl + r
Lookup a command in history
Alt + .
Recalls last argument.


I received a syntax error when run this:
netstat -an | grep ESTABL­ISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | awk '{ printf­("%s­\t%­s\t­"­,$2,$1) ; for (i = 0; i < $1; i++) {print­f("*­")}; print "­" }'

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Ubuntu Compose Key Combinations Cheat Sheet
          Ubuntu Unity 16.04 Keyboard Shortcuts
          Nano Editor Keyboard Shortcuts

          More Cheat Sheets by TME520

          dig (english)
          Chinois - Routines de conversation 1 Cheat Sheet
          chinese locations Cheat Sheet