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.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

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.

Universal configuration monitoring and system of record for IT.

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



Set audible alarm when an IP address comes online

Terminal - Set audible alarm when an IP address comes online
ping -i 60 -a IP_address
2009-03-04 06:21:22
User: haivu
Functions: ping
Set audible alarm when an IP address comes online

Waiting for your server to finish rebooting? Issue the command above and you will hear a beep when it comes online. The -i 60 flag tells ping to wait for 60 seconds between ping, putting less strain on your system. Vary it to your need. The -a flag tells ping to include an audible bell in the output when a package is received (that is, when your server comes online).


There are 5 alternatives - vote for the best!

Terminal - Alternatives
until ping -c1 ADDRESS;do true;done;zenity --warning --text "ADDRESS is back"
2011-09-26 18:51:38
User: marcusrp
Functions: ping
Tags: Network zenity

I'd rather this one on Gnome, as I'm used to be listening some music while working. I've even created a bash function which receives ADDRESS as parameter.

Know a better way?

If you can do better, submit your command here.

What others think


ping -i 60 -A IP

Instead of a bell you can have OSX tell you (this one will check every 30 seconds for 5 minutes)

ping -i 30 -c 10 IP && say -v vicki 'Server is back online'
Comment by vaporub 377 weeks and 4 days ago

Pinging your system isn't putting any "strain" on it at all. 'ping -f' that sucker, and the only "strain" you're putting anywhere is your network.

Comment by atoponce 377 weeks and 4 days ago


that will say 'Server is back online' no matter what, regardless of whether or not the ping actually works, and after all pings are done. You are essentially doing:

sleep 300; say -v vicki 'Server is back online'

albeit with ping working in the mean time.

I think you may have missed the concept.

Comment by sudopeople 377 weeks and 4 days ago


No, from the man page:

> If ping does not receive any reply packets at all it will exit with

> code 1. If a packet count and deadline are both specified, and fewer

> than count packets are received by the time the deadline has arrived,

> it will also exit with code 1. On other error it exits with code 2.

> Otherwise it exits with code 0. This makes it possible to use the exit

> code to see if a host is alive or not.

Only problem is it will always wait the whole 5 minutes before telling you.

Comment by porges 377 weeks and 3 days ago

Remember about "visual bell" (http://www.faqs.org/docs/Linux-mini/Visual-Bell.html). If you use "visual bell" in your xterm, try:

xset b; ping -a IP; xset -b

turn off "visual bell" before ping, and turn it on after ping.

Comment by unixmonkey2039 377 weeks and 3 days ago

@vaporub: good point, it still misses the mark though. Like you said, it will wait 5 min before telling you if it is up. It would work like this:

sleep 300; ping -c1 IP && say "server is up"

this is a better solution:

while true; do [ "$(ping -c1W1w1 server-or-ip.com | awk '/received/ {print $4}')" = 1 ] && say -v vicky "Server is back online" || echo; sleep 1; done

It would be annoying as hell, but you'd know it was up.

More info: http://www.commandlinefu.com/commands/view/1815/beep-when-a-server-goes-offline

Comment by sudopeople 373 weeks and 5 days ago

The ping command with -o option will exit successfully after receiving one reply packet (at least on Mac OS X):

ping -o $ip && say "Server is back online"

Comment by jh12z 113 weeks and 4 days ago

Your point of view

You must be signed in to comment.