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:



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.

Top Tags



All commands from sorted by
Terminal - All commands - 12,070 results
curl http://en.wikipedia.org/wiki/List_of_programming_languages | grep "<li>" | awk -F"title=" '{ print $2 }' | awk -F\" '{ print $2 }'
2013-01-09 21:40:11
User: sxiii
Functions: awk grep

Requirements: curl, grep, awk, internet connection with access to wikipedia

Loaded page: http://en.wikipedia.org/wiki/List_of_programming_languages

If you can make shorter version of this listgetter, you are welcome to paste it here :)

puttygen my_ssh_key.ppk -O private-openssh -o my_openssh_key.ssh
2013-03-10 12:35:31
User: motopig

1.use puttygen command convert .ppk file to .ssh file

tar cfp - file-to-be-archived | gzip > archive.tar.gz
find . -type f | perl -ne 'chop(); $ext = substr($_, rindex($_, ".") + 1); print "$ext\n";' | sort | uniq --count | sort -n
2013-09-26 07:45:19
User: t3o
Functions: find perl sort uniq

When trying to find an error in a hosted project it's interesting to find out how the source is organized: Are there .inc files? Or .php files only? Or .xml files that probably contain translated texts?

for i in */; do echo $(find $i -type f -regextype posix-extended -regex ".*\.(mp3|ogg|wav|flac)" | wc -l) $i ; done
wget -r -nd -q -A "*.ext" http://www.example.org/
rsync -avz -e ssh username@hostname:/path/to/remote/dir/ /path/to/local/dir/
seq 10 |xargs -n1 echo Printing line
2009-10-15 11:05:35
User: Waldirio
Functions: echo seq xargs
Tags: echo xargs seq

Nice command to create a list, you can create too with for command, but this is so faster.

x11vnc -display :0 -scale 6/7 -rfbauth vncpass -forever
2009-11-12 21:32:45

This will start the x11vnc server, scale it at 6/7, will use the vncpass file to authenticate and wont shut down as soon as a client disconnects

{ echo -e "$body"; uuencode "$outfile" "$outfile"; } | mail -s "$subject" "$destaddr" ;
2009-12-10 18:08:59
User: glaudiston
Functions: echo mail uuencode
Tags: cat mail

on this way we can define the body too

:.,$!perl -pne 'for $i ("0001".."0004"){ s/XXXX/$i/ if($i == $.) }'
2010-02-11 03:56:26
User: bartonski

given lines of the form




each 'XXXX' will be replaced with a serial number between 0001 and 0004.

portnum() { egrep "[[:space:]]$*/" /etc/services; }
free -g
sudo find foldername -type f -exec chmod 644 {} ";"
apt-file --package-only search /lib/firmware
echo "main(i){for(i=0;;i++)putchar(((i*(i>>8|i>>9)&46&i >>8))^(i&i>>13|i>>6));}" | gcc -x c - && ./a.out | aplay
2013-01-09 21:48:23
User: r0nd0n
Functions: echo gcc

Something I pulled off 4chan, it plays a tune.

ssh user@remote "tar cfp - /path/to/log/* | gzip" > local.tar.gz
set +e +u; dd if=/dev/urandom of="/media/usb1/$$";sync;sync
2013-12-22 14:35:53
User: warkruid
Functions: dd set

I sometimes have use an usb stick to distribute files to several standalone "internet" pc's. I don't trust these machines period. The sticks I have do not have a write protection. So as a added security measure I fill the unused space on the (small) usb stick with a file with randomly generated bits. Any malware that tries to write to this stick will find no space on it.

Tested on slackware 14

Note: you may need root access to write to the device. This depends on your mount options.

ruby -run -e httpd . -p 8000
git log master...feature-a | grep -o -E '\b([A-Z]+)-[0-9]+\b' | sort | uniq
2014-07-07 18:51:01
User: westonruter
Functions: grep sort

To get the list of tickets in a comma-separated list, pipe the above into:

sort | uniq | perl -pe 's/\n/, /' | sed 's/, $//'
find . -name *.png | xargs optipng -nc -nb -o7 -full
srchpymod() { python -c "import $1; print filter(lambda x: x.find('$2') >= 0, dir($1))"; };
2009-02-16 02:47:13
User: jyro
Functions: python


for e.g.

srchpymod cairo Surface

['ImageSurface', 'PDFSurface', 'PSSurface', 'SVGSurface', 'Surface', 'SurfacePattern', 'XlibSurface']

cp ./* .[!.]* ..?* /path/to/dir
2009-03-16 13:27:36
User: ako
Functions: cp

./* is for copying files starting with -

.[!.]* is for copying hidden files and avoiding copying files from the parent directory.

..?* is for copying files starting with .. (avoids the directory ..)

/path/to/dir the path to the directory where the files should be copied

Can also be used as a script. Input argument is /path/to/dir

in tcsh, replace .[!.]* with .[^.]*

xmlstarlet fo "http://www.google.com/ig/api?weather=$(curl -s api.hostip.info/get_html.php?ip=$(curl -s icanhazip.com)... SEE SAMPLE OUTPUT
2010-02-11 06:32:44
User: o0110o

This command will determine an individuals local weather, based on their I.P. address. I had to learn a lot about SED and a little about XMLStarlet in order to achieve this. This command is my original work and there is much room for improvement; I look forward to any constructive feedback.