What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Commands using watch from sorted by
Terminal - Commands using watch - 132 results
watch -d -n 5 df
2011-08-24 19:45:36
User: pcphillips
Functions: watch

If you add the -d flag each difference in the command's output will be highlighted.

I also monitor individual drives by adding them to df. Makes for a nice thin status line that I can shove to the bottom of the monitor.

watch -n 2 -d '/sbin/ifconfig eth0'
watch -n 1 "/usr/sbin/lsof -p PID |awk '/TCP/{split(\$8,A,\":\"); split(A[2],B,\">\") ; split(B[1],C,\"-\"); print A[1],C[1],B[2], \$9}' | sort | uniq -c"
2011-08-12 19:16:38
User: ideivid
Functions: watch

Maybe this will help you to monitor your load balancers or reverse proxies if you happen to use them. This is useful to discover TIME OUTS and this will let you know if one or more of your application servers is not connected by checking.

watch !!
watch vmstat -sSM
watch -n 2 netstat -antu
watch 'netstat -anptu |egrep "^Proto|:80 "'
2011-05-18 15:05:52
User: Mozai
Functions: egrep watch

Shows updated status in a terminal window for connections to port '80' in a human-friendly form. Use 'watch -n1' to update every second, and 'watch -d' to highlight changes between updates.

If you wish for status updates on a port other than '80', always remember to put a space afterwards so that ":80" will not match ":8080".

watch "cat `ls -rcA1 | tail -n1`"
2011-03-25 01:22:05
User: donnoman
Functions: watch

Great for watching things like Maildir's or any other queue directory.

> /tmp/psup.log; watch "ps up $(pgrep -d, -x nginx) | grep -v STAT | awk '{print $8}' | grep -c [ZUTD] >> /tmp/psup.log; tail -n 22 /tmp/psup.log"
2011-03-16 17:49:23
User: donnoman
Functions: watch
Tags: nginx

This command counts the number of blocked NGINX processes every 2 seconds and shows the last 22 measurements

You should have at least the number of cpu's in a non-blocked state.

The command up to the first ; truncates the log file.

watch -n 1 :
2011-02-16 13:38:37
User: daniele
Functions: watch

Clock will appear in the top-right corner

watch -t -n1 'date "+%r %F %A"'
2011-02-16 03:05:48
User: oracular
Functions: watch
Tags: date clock watch

Shows a simple clock in the console

-t param removes the watch header

Ctrl-c to exit

watch -n1 'date "+%T"'
2011-02-16 00:33:51
User: DaveQB
Functions: watch

A console clock with the current time.

watch -n1 echo
watch -n 1 'date "+obase=2; print %H,\":\",%M,\":\",%S" |bc'
2011-02-02 00:01:48
User: smax
Functions: watch

Binary clock with separate H:M:S.

watch --interval 1 "cat /proc/acpi/thermal_zone/THRM/*; cat /proc/cpuinfo | grep MHz; cat /proc/acpi/processor/*/throttling"
2010-12-09 19:47:25
Functions: watch

This is maybe helpfull from system overheat on your linux box

watch -n 900 "notify-send -t 10000 'Look away. Rest your eyes'"
2010-10-05 09:39:31
User: b_t
Functions: watch


1) -n option of watch accepts seconds

2) -t option of notify-send accepts milliseconds

3) All quotes stated in the given example are required if notification

message is more than a word.

4) I couldn't get this to run in background (use of & at the end fails). Any

suggestions/improvements welcome.

watch -n <time_interval> "du -s <file_or_directory>"
watch 'ls -tough --full-time *.vmdk'
2010-08-20 17:28:28
User: vRobM
Functions: watch

To monitor .vmdk files during snapshot deletion (commit) on ESX only (ESXi doesn't have the watch command):

1. Navigate to the VM directory containing .vmdk files.

# watch "ls -tough --full-time *.vmdk"


-t sorts by modification time

-o do not list group information (to narrow the output)

-u sorts by access time

-g only here for the purpose to easily remember the created mnemonic word 'tough'

-h prints sizes in human readable format (e.g., 1K 234M 2G)

--full-time sets the time style to full-iso and does not list user information (to narrow the output)

optionally useful parameters to the watch command:

-d highlight changes between updates

-n seconds to wait between updates (default is 2)

-t turn off printing the header

watch -tn1 'date -u +%T -d @$(expr $(date -d HH:MM +%s) - $(date +%s)) | toilet -f bigmono12'
2010-06-26 11:56:11
User: prayer
Functions: date expr watch
Tags: date time

Change HH:MM with your target time.

This is for a Debian/Ubuntu GNU system. You need bash (package bash), date (package coreutils) and toilet (package toilet). Install with:

# apt-get install bash coreutils toilet toilet-fonts

watch -tn1 'date +%r | figlet'
2010-06-22 10:59:16
User: SuperFly
Functions: watch

Figlet is easy to find for download on the internet, and works for any text. Quite cool.

watch 'find -maxdepth 1 -mindepth 1 -type d |xargs du -csh'
2010-05-19 13:13:57
User: shadycraig
Functions: du watch xargs

This command shows the size of directories below here, refreshing every 2s.

It will also track directories created after running the command (that what the find bit does).

watch -n 1 "sudo asterisk -vvvvvrx 'core show channels' | grep call"
2010-03-26 15:42:13
User: mheadd
Functions: watch

Show active calls as the happen on an Asterisk server. Note that the Asterisk command (in single quotes) is formatted for Asterisk 1.6. Use the -n flag on the watch command to modify the refresh period (in seconds - default is 2 seconds).

watch -n1 'ifconfig eth0|grep bytes'
2010-03-20 03:24:26
User: qiaomuf
Functions: grep watch

-n means refresh frequency

you could change eth0 to any interface you want, like wlan0

watch -n1 snmptable -v2c -c public localhost diskIOTable
2010-03-19 11:31:52
User: oernii2
Functions: watch

Show a simple table with disk IO for the specified host. you monitor a LOT of different thing. Mostly used for MRTG and similar, but this is nice for a quick look, which disk is busy.

"public" is your SNMP community

ensure that snmpd is running on the host which you intend to monitor

watch "netstat -plan|grep :80|awk {'print \$5'} | cut -d: -f 1 | sort | uniq -c | sort -nk 1"
2010-03-15 09:27:43
User: ik_5
Functions: watch

It's not my code, but I found it useful to know how many open connections per request I have on a machine to debug connections without opening another http connection for it.

You can also decide to sort things out differently then the way it appears in here.