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.


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:



2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.




All commands from sorted by
Terminal - All commands - 11,847 results
type C:\WINNT\system32\inetsrv\MetaBase.xml | find "DEBUG"
type C:\WINNT\system32\inetsrv\MetaBase.xml | find "400" | find "CustomError"
while [ 1 ]; do curl -s -u username:password http://twitter.com/statuses/friends_timeline.rss|grep title|sed -ne 's/<\/*title>//gp' | head -n 6 |festival --tts; sleep 300;done
2009-02-20 20:20:21
User: tomwsmf
Functions: head sleep

Pump up the chatter, run this script on a regular basis to listen to your twitter timeline.

This is a rough first cut using several cli clips I have spotted around. There is no facility to not read those things already read to you. This could also easily be put in a loop for timed onslaught from the chatterverse, though I think it might violate several pointsof the Geneva Convention

UPDATE - added a loop, only reads the first 6 twits, and does this every 5 mins.

say -v Vicki "Hi, I'm a mac"
2009-02-20 20:17:00
User: chrisclymer

Very entertaining when run on someone elses machine remotely ;)

date "+The time is %H:%M" | say
2009-02-20 20:14:53
User: las3rjock
Functions: date

On other systems, replace 'say' with the name of another text-to-speech engine, e.g. espeak ( http://espeak.sourceforge.net ) or festival ( http://www.cstr.ed.ac.uk/projects/festival )

rsync -Pz user@remotehost:/path/file.dat .
touch balls
sed 's/[ \t]*$//' < emails.txt | tr 'A-Z' 'a-z' | sort | uniq > emails_sorted.txt
iptables -nL -v --line-numbers
netstat -tap | grep mysql
fortune -o | espeak
2009-02-20 19:46:23
User: danlangford

or replace "espeak" with "festival --tts" if you like festival better

when your buddy leaves his computer unlocked use "crontab" or "at" to play at some time that would be most embarassing (during his next sales presentation)

echo "fortune -o | espeak" | at now + 30 minutes

of course you can exclude the "-o" for non offensive fortunes, or if you don't have offensive fortunes installed

netstat -alnp | grep ::80
find . -type d -execdir du -sh '{}' ';' | grep -E "[0-9]+K" | sed 's/^[0-9\.]\+K[\t ]\+//' | tr "\n" "\0" | xargs -0 rm -rf
last reboot
ps -eo stat,pid,user,command | egrep "^STAT|^D|^R"
2009-02-20 19:00:17
User: jyoder
Functions: egrep ps

Want to know why your load average is so high? Run this command to see what processes are on the run queue. Runnable processes have a status of "R", and commands waiting on I/O have a status of "D".

On some older versions of Linux may require -emo instead of -eo.

On Solaris: ps -aefL -o s -o user -o comm | egrep "^O|^R|COMMAND"

2009-02-20 18:07:03
User: jcgam69

Only a few characters of the previous command are necessary.

tcpdump -nn -v -i eth0 -s 1500 -c 1 'ether[20:2] == 0x2000'
2009-02-20 18:02:27
User: spif
Functions: tcpdump

This gives you lots of nifty Cisco network information like VLAN tag, port and switch information.

2009-02-20 17:38:49
User: betsubetsu

If you typed 'sl', put the cursor on the 'l' and hit ctrl-t to get 'ls'.

yes 'Y'|gdb -ex 'p close(1)' -ex 'p creat("/tmp/output.txt",0600)' -ex 'q' -p pid
2009-02-20 17:36:57
User: adminzim
Functions: yes

This command uses the debugger to attach to a running process, and reassign a filehandle to a file.

The two commands executed in gdb are

p close(1) which closes STDOUT


p creat("/tmp/filename",0600)

which creates a file and opens it for output. Since file handles are assigned

sequentially, this command opens the file in place of STDOUT and once the process continues, new output to STDOUT will instead be written to our capture file.

who am i
2009-02-20 16:26:11
User: ozymandias
Functions: who

In my work environment, we log onto the servers as our user ('user', in the sample ouput), and 'sudo su - root' to other accounts. This trick allows us to return the account name we logged in as -- and not the account name we currently are ('root', in this example).

Using this trick, you can build other commands:

Set your CVSROOT env variable to your account name:

CVSROOT=$(who am i | awk '{print $1}')@cvs.server.example.com:/cvsroot

SCP a file to another server:

scp file.txt $(who am i | awk '{print $1}')@some.other.server.com:.

This works out great in my environment, as we can include this in our documentation and make the comands more easy to copy/paste for different users, and not have to set all sorts of variables, or modify the docs for each user.

whoami gives you the name of the user you currently are, not the user you logged on originally as.

who gives you a listing of every single person logged onto the server.

who am i gives you the name of the user you logged on as, and not who you changed to with su.

Look at the following scenario:



su -

# whoami


# who am i

user pts/51 2009-02-13 10:24 (:0.0)

whoami != who am i

curl -u USERNAME:PASSWORD -d "" http://twitter.com/friendships/create/NAMEOFNEWFRIEND.xml?follow=true
2009-02-20 14:30:57
User: reklis

replace username, password, and nameofnewfriend with proper values. Remember to escape things like ! or & in your password

echo "hello world" | festival --tts
2009-02-20 14:00:50
Functions: echo

The Festival Speech Synthesis System converts text into sound.

Or: links -dump http://youfavoritewebsite.com | festival --tts

ctrl + r
2009-02-20 13:28:19
User: sixtus

This is not actually a command, it's just a keyboard shortchut. But a very useful one.

find / -name *~ -delete
pushd +2; pushd -2
2009-02-20 12:26:18
User: betsubetsu

'pushd +1' is equivalent to 'pushd'. Can be 'pushd +3' or more generaly 'pushd +N'. Can also be 'pushd -N'.

More description in 'man bash'.