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





All commands from sorted by
Terminal - All commands - 12,230 results
ssh -g -L 8080:localhost:80 root@$HOST
2009-10-24 20:56:00
User: kayowas
Functions: ssh

Forward connections to $HOSTNAME:8080 out to $HOST:80

for file in ./*; do cat "$file"; sleep 0.3
2011-11-28 20:10:57
User: DopeGhoti
Functions: cat file sleep

Original submitted version would break if any filenames had whitespaces in them. The command is a Bad Idea anyhow, because you will end up `cat`ing a binary or something else specacularly bad.

ls | while read line; do ln -s "$(pwd)/$line" "/usr/bin/$line"; done
cd /path/to/pmwiki/wiki.d;/bin/ls -1 | perl -ne 'my ($group,$name)=split(/\./);$counts{$group}++;' -e 'END { foreach $group (sort keys %counts) {printf("%d\t%s\n",$counts{$group},$group);} }'|sort -rn
2011-09-14 19:33:39
User: tamouse
Functions: cd perl sort
Tags: sort perl pmwiki

PmWiki stores wiki pages as Group.Name. Simply split the directory listing and count frequency of group occurances.

php -i|grep -i max
2009-02-20 03:29:11
User: rjamestaylor

Show the maximum settings in effect for PHP at the command line.

rm -rf `find . -name .svn`
2010-02-23 08:35:06
User: jfcalvo
Functions: rm

Recursively remove .svn directories from the current location.

wget http://www.whatismyip.org --quiet -O - | cat
ntfsresize --size X[k,M.G] /dev/hda1
2011-07-02 17:47:05
User: 0disse0
Tags: ntfs

With this command you can resize an NTFS partition by specifying the new size (X) in Kbytes, Mbytes or Gbytes. If you plan to do this it is advisable to precede --no-action parameter to size

see more:




ldapsearch -xLLL -b "cn=schema" "(objectclass=*)" \ \* objectclasses attributetypes | perl -p0e 's/\n //g'
2012-04-04 13:31:31
User: ioggstream
Functions: perl

Dump 389ds schema, putting "\n " on one line with perl.

You have to specify the objectclasses, attributetypes operational attributes too, otherwise they won't be dumped!

find path/to/folder/ -type f -print0 | xargs -0 -n 1 md5sum | awk '{print $1}' | sort | md5sum | awk '{print $1}'
2009-02-16 19:39:37
User: mcover
Functions: awk find md5sum sort xargs

For quick validation of folder's file-contents (structure not taken into account) - I use it mostly to check if two folders' contents are the same.

nmap -sS -O -v -oS -
alias mux='clear && cd ~/Music/ && ls && echo -n "File> " && read msi && mplayer ~/Music/$msi'
2009-03-23 10:45:27
User: Noxn
Functions: alias cd echo ls read

An alias i made for myself to play music in a faster way.

Works great when you have Guake / Tilda installed (Console that drops down like in the game QUAKE)


I put this in my bash_alias file (I'm on ubuntu, the bash_alias file does autostart with the right config) but it works putting it in bashrc too. Or anything that autostarts when the console is opened.


Needs Mplayer and music files to work. With out music theres nothing to play!

Oh, and also, without modification, this alias will try to play stuff from your ~/Music folder! (case sensitive). Make sure that folder exists and has music OR edit this alias to fit your needs.

sed 's/$'"/`echo \\\r`/"
lynx --dump "http://checkip.dyndns.org"
w3m miip.cl | grep ip
2009-10-26 01:40:37
User: Cont3mpo
Functions: grep

See external ip with w3m, simple and fast.

On a web site from Chile (spanish).

echo "Starting Daemon"; ( while :; do sleep 15; echo "I am still running =]"; done ) & disown -h $!
2010-02-23 19:17:05
User: daleki
Functions: echo sleep

You don't want the -ar parameters in this case. The man page for BASH_BUILTINS(1) states:

"-a option means to remove or mark all jobs" and

"-r option without a jobspec argument restricts operation to running jobs"

In this case we are supplying the process id of the job to disown so neither of these should be used.

cat /usr/share/dict/words | grep -P ^[a-z].* | grep -v "'s$" | grep -Pv ^.\{1,15\}$ | shuf -n4 | tr '\n' ' ' | sed 's/$/\n/'
2011-08-15 01:03:48
User: bugmenot
Functions: cat grep sed tr
Tags: tr xkcd shuf

The first grep rejects capitalised words since the dict has proper nouns in it that you mightn't want to use. The second grep rejects words with ending in apostrophe s, and the third forces the words to be at least 15 characters long.

alias cdc='cd `pwd -P`'
w3m http://amit-agarwal.co.in/mystuff/getip_txt.php will return the ip in text format.
wodim foo.iso
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
2009-04-04 01:41:48
User: peterc
Functions: grep sudo tcpdump

Replace "en1" with your network interface (on OS X, usually en0, en1, eth0, etc..)

umount -t smbfs
2012-02-23 10:46:44
User: Velenux
Functions: umount
Tags: samba

smbfs or cifs, depends on which you are using

< /dev/urandom tr -dc A-Za-z0-9_ | head -c $((1024 * 1024)) | tee >(gzip -c > out.gz) >(bzip2 -c > out.bz) > /dev/null