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 -n 0.5 ssh [user]@[host] mysqladmin -u [mysql_user] -p[password] processlist | tee -a /to/a/file
2009-08-19 14:21:27
User: lunarblu
Functions: ssh tee watch

Locally watch MySQL process list update every 5s on a remote host. While you watch pipe to a file. The file out put is messy though but hey at least you have a history of what you see.

watch -n1 'cat /proc/interrupts
watch -n 10 'du -sk testfile'
2009-08-14 12:35:21
User: ianux
Functions: watch

watch is a command especially designed for doing this job

watch "ps auxw | grep [d]efunct"
2009-08-12 08:11:16
User: alvinx
Functions: watch

to omit "grep -v", put some brackets around a single character

watch "ps auxw | grep 'defunct' | grep -v 'grep' | grep -v 'watch'"
2009-08-11 12:22:13
Functions: watch

Shows all those processes; useful when building some massively forking script that could lead to zombies when you don't have your waitpid()'s done just right.

watch -n 1 nc localhost 80 '<<EOF GET / HTTP/1.1 Host: tux-ninja Connection: Close EOF'
2009-08-06 23:20:31
User: JustinHop
Functions: watch

Use the command watch, which is really hard to pass nested quotes to, and insert newlines where they are supposed to go in the HTTP request. that is after 1.1 after the host and two newlines at the end before the EOF.

i use this all day

what? no support for HEREDOCs on commandlinefu's interface? need more fu.

watch lsof -i :80
watch 'netstat -aniv'
watch -t -n1 "date +%T|figlet"
2009-06-21 01:02:37
User: dennisw
Functions: watch

This command displays a clock on your terminal which updates the time every second. Press Ctrl-C to exit.

A couple of variants:

A little bit bigger text:

watch -t -n1 "date +%T|figlet -f big"

You can try other figlet fonts, too.

Big sideways characters:

watch -n 1 -t '/usr/games/banner -w 30 $(date +%M:%S)'

This requires a particular version of banner and a 40-line terminal or you can adjust the width ("30" here).

watch -d -n 3 "iw dev wlan0 station dump; iwconfig wlan0"
watch '/home/mm/bash/keypress.sh |/home/mm/bash/evento.sh'
2009-06-07 20:57:49
User: m33600
Functions: watch

evento.sh needed for awk syntax

the aplay command makes a camera sound. It takes a picture of who looked at the display


# evento.sh: deteta evento e fala

awk '{print}' | espeak -v pt -stdin

awk '/e/{print "emergencia"}' | espeak -v pt -stdin

aplay -q /home/mm/bash/camera.wav # -q inibe verbose do comand aplay

exit 0

watch "dmesg |tail -15"
2009-04-14 03:13:17
User: Buzzcp
Functions: watch

Other logs can be monitored similarly, e.g.

watch "tail -15 /var/log/daemon.log"
watch -n 1 "netstat -tpanl | grep ESTABLISHED"
watch -tn1 'bc<<<"`date -d'\''friday 21:00'\'' +%s`-`date +%s`"|perl -ne'\[email protected]=gmtime($_);printf("%dd %02d:%02d:%02d\n",@p[7,2,1,0]);'\'
2009-03-29 19:53:36
User: penpen
Functions: perl watch
Tags: Linux unix date

An improved version of http://www.commandlinefu.com/commands/view/1772/simple-countdown-from-a-given-date that uses Perl to pretty-print the output. Note that the GNU-style '--no-title' option has been replaced by its one-letter counterpart '-t'.

watch --no-title -d -n 1 'echo `date -d "next Thursday" +%s` "-" `date +%s` | bc -l'
2009-03-29 06:53:09
User: jnash
Functions: bc watch

Might be more useful if you were able to print it in Days HH:MM:SS format as:

perl -e [email protected]=gmtime(234234);printf("%d Days %02d:%02d:%02ds\n",@p[7,2,1,0]);'

But I'm not exactly sure how to replace the 234234 with the output of the countdown time. (Having some problems with nested quoting/command substitution). Help would be appreciated :)

watch -n 10 "wget -q http://www.brillig.com/debt_clock -O - | grep debtiv.gif | sed -e 's/.*ALT=\"//' -e 's/\".*//' -e 's/ //g'"
2009-03-26 19:32:57
User: matrtsmiller
Functions: watch

The idea was originally stolen from Linux Journal. 'wget' pulls the debt clock and 'sed' reformats it for general consumption. Prefacing the command with 'watch' simply sets an interval - in this case every 10 seconds.

watch -n1 --differences cat /proc/meminfo
watch -n 1 :
2009-03-25 23:00:28
User: penpen
Functions: watch
Tags: Linux unix

'watch' repeatedly (default every 2 seconds, -n 1 => every second) runs a command (here ':', a shorthand for 'true'), displays the output (here nothing) and the date and time of the last run.

I thought it to be obvious but it seemingly is not: to exit use Ctrl-C.

watch -n 7 -d 'uptime | sed s/.*users,//'
2009-03-25 02:52:36
User: detert
Functions: sed watch

helps you keep watch on the load of a system, without having to stare constantly at the terminal. The -d argument to watch highlights the difference from the last run, making it easier to note how the load is fluctuating. The sed command just strips off the information about how long the box has been up, and how many users are logged in.

watch ethtool eth0
2009-03-24 20:03:25
User: israel
Functions: watch

verifry if link detected or no and speed of network.

watch -n 1 uptime\;myqladmin --user=<user> --password=<password> --verbose processlist
2009-03-21 18:29:28
User: root
Functions: watch
Tags: mysql

Useful for monitoring both MySQL and the server load at the same time.

watch 'iptables -vL'
2009-03-20 14:49:12
User: alanr723
Functions: watch

Watch the number of packets/bytes coming through the firewall. Useful in setting up new iptables rules or chains. Use this output to reorder rules for efficiency.

watch -n 5 -d cat /proc/mdstat
watch -n 1 df
2009-02-18 21:34:06
User: joem86
Functions: watch

While copying a large file that may take up a good chunk of your hard drive, start the copy and run this command concurrently. It will print out the disk information every second. It's pretty handy when you have a large copy with nothing to monitor the progress.

watch -d "free -mt"