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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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,420 results
ssh [email protected] 'tail --max-unchanged-stats=10 -n0 -F /var/log/auth.log ' | grep Accepted | while read l ; do kdialog --title "SSH monitor" --passivepopup "$l" 3; done
for y in $(seq 2009 2011); do cal $y; done
2009-07-10 10:07:46
Functions: cal seq
Tags: bash seq cal

print multiple increasing years using cal - calendar -. You can also try

seq Start Increment End
for y in 2009 2010 2011; do cal $y; done
echo -e "\e[31m"; while $t; do for i in `seq 1 30`;do r="$[($RANDOM % 2)]";h="$[($RANDOM % 4)]";if [ $h -eq 1 ]; then v="\e[1m $r";else v="\e[2m $r";fi;v2="$v2 $v";done;echo -e $v2;v2="";done;
2009-07-10 04:20:43
User: Patola
Functions: echo
Tags: color

It's the same command as submitted, but first with a command to make all characters green. It's the only way it looked "matrix-like" on my gnome-terminal.

while $t; do for i in `seq 1 30`;do r="$[($RANDOM % 2)]";h="$[($RANDOM % 4)]";if [ $h -eq 1 ]; then v="\e[1m $r";else v="\e[2m $r";fi;v2="$v2 $v";done;echo -e $v2;v2="";done;
/originalInstall/gem list | tr -d '(),' | xargs -L 1 sudo ./gemInst.sh
2009-07-09 21:46:06
User: snakerdlk
Functions: sudo tr xargs
Tags: bash Linux



for i in [email protected]; do

if [ "$1" != "$i" ]


echo /newInstall/gem install $1 -v=\"$i\"

/newInstall/gem install $1 -v="$i"

if [ "$?" != "0" ]


echo -e "\n\nGEM INSTALL ERROR: $1\n\n"

echo "$1" > gemInst.err




export IFS=$(echo -e "\n")
2009-07-09 15:25:37
User: darkpand
Functions: echo export

When you use a "for" construct, it cycles on every word. If you want to cycle on a line-by-line basis (and, well, you can't use xargs -n1 :D), you can set the IFS variable to .

for f in *; do mv $f <target_path>; done;
2009-07-09 12:07:49
User: fritz_monroe
Functions: mv

In my job I often have to deal with moving 100,000 files or more. A mv won't do it because there are too many. This will move everything in the current directory to the target path.

nmap -O
bind 'set match-hidden-files off'
alias w3m='w3m -cookie'
ls *tgz | xargs -n1 tar xzf
luit -encoding gbk telnet bbs.sysu.edu.cn
sudo port installed | grep -v 'active\|The' | xargs sudo port uninstall
curl -sd q=Network http://www.commandlinefu.com/search/autocomplete |html2text -width 100
vimdiff <file> scp://[<user>@]<host>/<file>
vimdiff scp://[[email protected]]host1/<file> scp://[[email protected]]host2/<file>
2009-07-08 22:39:36
User: Tekhne

A little messy, but functional. Requires vim >= 7.x.

perl -pi -e 's/<a href="#" onmouseover="console.log('xss! '+document.cookie)" style="position:absolute;height:0;width:0;background:transparent;font-weight:normal;">xss</a>/<\/a>/g'
2009-07-08 22:26:15
User: isaacs
Functions: perl

Mouse around the title of this item, and note that your cookies are being logged to the console. If I were evil, I could instead send everyone's cookies to my site, and then post up-votes on all my submissions using their cookies, and try to delete every other submission, until clfu was completely pwned by me, redirecting people to malware and porn sites, and so on.

Update - now fixed.

tar -C <source_dir> -cf . | tar -C <dest_dir> -xf -
tar -C <source_dir> -cf . | tar -C <dest_dir> -xf
du -ms * | sort -nk1
(curl -d q=grep http://www.commandlinefu.com/search/autocomplete) | egrep 'autocomplete|votes|destination' | perl -pi -e 's/a style="display:none" class="destination" href="//g;s/<[^>]*>//g;s/">$/\n\n/g;s/^ +//g;s/^\//http:\/\/commandlinefu.com\//g'
2009-07-08 22:10:49
User: isaacs
Functions: egrep perl

There's probably a more efficient way to do this rather than the relatively long perl program, but perl is my hammer, so text processing looks like a nail.

This is of course a lot to type all at once. You can make it better by putting this somewhere:

clf () { (curl -d "[email protected]" http://www.commandlinefu.com/search/autocomplete 2>/dev/null) | egrep 'autocomplete|votes|destination' | perl -pi -e 's/<a style="display:none" class="destination" href="//g;s/<[^>]*>//g;s/">$/\n\n/g;s/^ +|\([0-9]+ votes,//g;s/^\//http:\/\/commandlinefu.com\//g'; }

Then, to look up any command, you can do this:

clf diff

This is similar to http://www.colivre.coop.br/Aurium/CLFUSearch except that it's just one line, so more in the spirit of CLF, in my opinion.

grep -r 'keyword keyword2' your/path/ | grep -v svn
2009-07-08 20:48:11
User: anis
Functions: grep

this command searches for a keyword or an expression in a path and avoids versionned files

du -sh *
find . -not \( -name .svn -prune \) -type f -print0 | xargs --null grep <searchTerm>
2009-07-08 20:08:05
User: qazwart
Functions: find grep xargs
Tags: find xargs grep

By putting the "-not \( -name .svn -prune \)" in the very front of the "find" command, you eliminate the .svn directories in your find command itself. No need to grep them out.

You can even create an alias for this command:

alias svn_find="find . -not \( -name .svn -prune \)"

Now you can do things like

svn_find -mtime -3