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.

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



Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

All commands from sorted by
Terminal - All commands - 12,362 results
ping -c 1 www.google.com | /usr/bin/awk '{print $7}' | /usr/bin/awk 'NR > 1' | /usr/bin/awk 'NR < 2' | /usr/bin/awk -F"=" '{print $2}'
2010-12-15 08:50:52
User: ackers
Functions: ping

Does one ping to a URL or host, and echo out just the response time. I use this on, with MRTG to monitor the connections to various hosts.

for f in ~/.mcabber/histo/*; do a=`egrep "^(MR|MS)" $f | wc -l`; echo $f: $a | awk -F\/ '{print $6}'; done
dd bs=1 if=/dev/zero of=/path/to/imagename.raw seek=50G count=1 conv=notrunc
jmap -dump:live,format=b,file=o.hprof pid ; jstack -l pid > /oracle/ora_app1/p.tdump
update-alternatives --config x-terminal-emulator
ipcalc $(ifconfig eth0 | grep "inet addr:" | cut -d':' -f2,4 | sed 's/.+Bcast:/\//g') | awk '/Network/ { print $2 } '
ldd path_to_executable
echo "John's" | grep -Po '\b\w+(?<!s)\b'
function ldd(){ objdump -p $1 | grep -i need; }
2010-09-07 02:44:59
User: jyf
Functions: grep objdump
Tags: ldd

use this to avoid executing the target app

sudo ifconfig wlan0 | grep inet | awk 'NR==1 {print $2}' | cut -c 6-
2013-02-18 14:10:07
User: mouths
Functions: awk cut grep ifconfig sudo

On wired connections set 'eth0' instead of 'wlan0'

sqlite3 $HOME/.dropbox/config.db "select value from config where key like '%dropbox_path%'"
2011-06-05 08:26:02
User: mobilediesel

Newer versions of Dropbox let you choose the location for your Dropbox folder. If you use script to put things into your Dropbox folder (todo list, screenshots, torrents etc.) but have the Dropbox folder in different locations on your other computers this lets you use the same script on all systems without having to tell it where the Dropbox folder is.

script -qf | tee >(nc -l -p 5000)
ct find -avobs -nxname -element 'brtype(branch_name)' -print 2>/dev/null
for f in *.ogg ; do mplayer -quiet -vo null -vc dummy -ao pcm:waveheader:file="$f.wav" "$f" ; done
CLASSPATH=.; export CLASSPATH=$CLASSPATH$(find "$PWD" -name '*.jar' -type f -printf ':%p\n' | sort -u | tr -d '\n'); echo $CLASSPATH
openssl req -new -x509 -extensions v3_ca -days 1100 -subj "/C=CA/ST=CA/L=SomeCity/O=EXAMPLE Inc./OU=Web [email protected]" -nodes -keyout web.key -out web.crt
tar cf - . | (cd /new/dir; tar xvf -)
2009-03-09 20:30:34
User: jauderho
Functions: cd tar

Add z to the flags to enable compression.

head -n X | tail -n 1
2010-07-08 22:06:39
User: infinull
Functions: head tail

using tail first won't do it because tail counts from the bottom of the file. You could do it this way but I don't suggest it

export PATH=$PATH$(find "$PWD" -name '.*' -prune -o -type f -a -perm /u+x -printf ':%h\n' | sort -u | tr -d '\n'); echo $PATH
2011-03-11 19:31:17
User: dexterhu
Functions: echo export find sort tr

(1) don't run twice, or the same folder will occur in $PATH.

(2) otherwise you need to start a new terminal

dpkg -l | sed '/^rc/!d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/' | xargs -r sudo apt-get -y purge
nl <filename>
2010-01-06 16:14:43
User: SuperFly
Functions: nl

Works in RHEL5 and derivatives.

route -n | grep "^0\." | awk '{print "Gateway to the World: "$2", via "$NF""}'
add "ssh $1@$2" in /usr/sbin/connect with executable permission, now use commad "connect user"
2012-01-27 12:50:20

I will ssh to ip address with user name user.

"connect user" is same as "ssh [email protected]"

tail -f logfile | logtop
2012-06-24 19:18:30
User: Sizeof
Functions: tail
Tags: tail

logtop show number of lines per second, also classify them so you can show a "top" of every aspect of your logfile :

tail -f access.log | awk '{print $1; fflush();}' | logtop

lsof -p <process_id> | wc -l