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





Commands by sudopeople from sorted by
Terminal - Commands by sudopeople - 10 results
git log -i --grep='needle'
2015-08-11 23:07:55
User: sudopeople
Tags: git grep git-log

Normally, searching git log comments is case sensitive. The -i luckily applies to the --grep switch.

cat part1.avi part2.avi part3.avi > tmp.avi && mencoder -forceidx -oac copy -ovc copy tmp.avi -o output.avi && rm -f tmp.avi
2013-09-05 01:47:22
User: sudopeople
Functions: cat rm

Useful for when you download movies split into < 700mb parts.

Credit to rich @ http://superuser.com/questions/318640/merge-avi-files-without-recoding-in-mac-os-x-lion

mencoder is generally included with mplayer.


sudo port install mplayer
for i in */; do echo tar -cjf "${i%/}.tar.bz2" "$i"; done
2013-08-20 22:13:28
User: sudopeople
Functions: echo tar

Remove the "echo" to actually archive.

Many similar commands are found on commandlinefu but I end up needing this very specific one from time to time.

To extract any of them, use the standard tar.bz2 extract command:

tar xvjf folder1.tar.bz2
apt-cache search php5
2012-09-20 21:14:50
User: sudopeople
Functions: apt

Can't remember what that one package was called? Search for it!

It's also a good idea to run

apt-get update


ufraw-batch --out-type=jpeg --out-path=./jpg ./*.NEF
2009-04-15 09:03:59
User: sudopeople
Tags: photo photos

converts RAW files from a Nikon DSLR to jpg for easy viewing etc.

requires ufraw package

while true; do [ "$(ping -c1W1w1 server-or-ip.com | awk '/received/ {print $4}')" != 1 ] && beep; sleep 1; done
2009-03-31 20:47:56
User: sudopeople
Functions: sleep

pings a server once per second, and beeps when the server is unreachable.

Basically the opposite of:

ping -a server-or-ip.com

which would beep when a server IS reachable.

You could also substitute beep with any command, which makes this a powerful alternative to ping -a:

while true; do [ "$(ping -c1W1w1 server-or-ip.com 2>/dev/null | awk '/received/ {print $4}')" = 1 ] && date || echo 'server is down!'; sleep 1; done

which would output the date and time every sec until the ping failed, in which case it would echo.


Requires beep package.

May need to run as root (beep uses the system speaker)

Tested on Ubuntu which doesn't have beep out of the box...

sudo apt-get install beep
echo '!'whammy
2009-03-26 23:34:33
User: sudopeople
Functions: echo
Tags: literal bang

Seems obvious, but other seemingly simple ways to use it don't work:

echo !whammy


echo "!whammy"

both output:

-bash: !whammy: event not found

and this:

echo "\!whammy"



with the slash :(

you can also do any combinations of quotes for a complex string:

echo "It's great to be able to use a bang ("'!'") in a command"'!'


It's great to be able to use a bang (!) in a command!
php -r 'echo strtotime("2009/02/13 15:31:30")."\n";'
2009-03-24 19:38:46
User: sudopeople

Most people know that you can run a PHP script from the command line like so:

php ./my_script.php

But sometimes I just want to run a quick bit of code, the PHP Command Line Interface allows me to do so with the -r option.

Requires package php5-cli

rsync -vazuK --exclude "*.mp3" --exclude "*.svn*" * user@host:/path
2009-02-27 19:58:02
User: sudopeople
Functions: rsync
Tags: svn exclude

rsyncs files to a server excluding listed files

also a file can be used to exclude common exclude rules and/or to exclude a ton of files, like so:

rsync --exclude-from '~/.scripts/exclude.txt'

where exclude.txt has one rule per line:



cat /etc/*-release
2009-02-26 08:22:01
User: sudopeople
Functions: cat

Works for most distributions, tested on Ubuntu, Fedora, CentOS, Gentoo, SUSE, RedHat.

Debian and Slackware:

cat /etc/*version