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





Ping sweep without NMAP

Terminal - Ping sweep without NMAP
(prefix="10.59.21" && for i in `seq 254`; do (sleep 0.5 && ping -c1 -w1 $prefix.$i &> /dev/null && arp -n | awk ' /'$prefix'.'$i' / { print $1 " " $3 } ') & done; wait)
2014-04-02 11:20:57
User: smoky
Functions: arp awk ping sleep
Ping sweep without NMAP

Waits for all pings to complete and returns ip with mac address


There are 2 alternatives - vote for the best!

Terminal - Alternatives
for i in {1..254}; do ping -c 1 -W 1 10.1.1.$i | grep 'from'; done
2010-04-07 16:57:53
Functions: grep ping
Tags: ping

Usefull for when you don't have nmap and need to find a missing host.

Pings all addresses from to, modify for your subnet.

Timeout set to 1 sec for speed, if running over a slow connection you should raise that to avoid missing replies.

This will clean up the junk, leaving just the IP address:

for i in {1..254}; do ping -c 1 -W 1 10.1.1.$i | grep 'from' | cut -d' ' -f 4 | tr -d ':'; done

for i in `seq 1 255`; do ping -c 1 10.10.10.$i | tr \\n ' ' | awk '/1 received/ {print $2}'; done
2009-08-22 09:34:27
User: hemanth
Functions: awk ping tr
Tags: ping

Ping sweep without NMAP

prefix="169.254" && for i in {0..254}; do echo $prefix.$i/8; for j in {1..254}; do sh -c "ping -m 1 -c 1 -t 1 $prefix.$i.$j | grep \"icmp\" &" ; done; done
2012-07-25 12:07:15
User: tempelorg
Functions: echo sh
Tags: ping

This version combines the best of the other suggestions and adds these features:

1. It scans a /16 subnet

2. It is very fast by running the ping commands in the background, running them in parallel.

3. Does not use the "-W" option as that's not available in older ping versions (I needed this for OS X 10.5)

prefix="10.0.0" && for i in `seq 25`; do ping -c 1 $prefix.$i &> /dev/null && echo "Answer from: $prefix.$i" ; done
2010-04-07 17:17:21
User: xeor
Functions: echo ping
Tags: ping

Not really an easier solution. But an example using && for (if last command returned 0). You can use || for (if last command returned other than 0)..

Know a better way?

If you can do better, submit your command here.

Your point of view

You must be signed in to comment.