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,604 results
git svn --authors-file=some-authors-file clone svn://address/of/svn/repo new-git-dir
git diff HEAD..rev | git apply --index; git commit
2009-02-06 17:29:46
User: Pistos
Functions: diff

Use this to make a new commit that "softly" reverts a branch to some commit (i.e. squashes the history into an inverse patch). You can review the changes first by doing the diff alone.

convert -resize 50%x50% image{,_resize}.jpg
git daemon --reuseaddr --verbose --export-all --base-path=/parent/of/bare/git/repos
2009-02-06 17:25:04
User: Pistos

Use this to start git daemon serving all git repos under a path.

tail -f <filename> | grep -C <# of lines to show above and below> <text>
alias scd='dirs -v; echo -n "select number: "; read newdir; cd -"$newdir"'
cflow file.c | grep ':$' | sed 's/ <.*//'
tar -cvzf - /source/path | ssh <targethostname> -l <username> dd of=/destination/path/backupfile.tgz
2009-02-06 15:52:09
User: smm
Functions: dd ssh tar

Creates a quick backup with tar to a remote host over ssh.

mysqlcheck -a --auto-repair -c -o -uroot -p [DB]
2009-02-06 15:49:16
User: michelem

A useful way to do a full check and auto repair damaged databases

pg_dump -U postgres [nomeDB] > db.dump
file !$
2009-02-06 15:41:08
User: leprasmurf
Functions: file

Bash shortcut to work with the last argument of your last command

pidof () { ps acx | egrep -i $@ | awk '{print $1}'; }
perl -e "use SOAP::Lite"
2009-02-06 15:26:37
User: leprasmurf
Functions: perl

Quick command to check if Perl library is installed on your server.

perl -pe 's/.+;//' ~/.zsh_history | sort | uniq -c | sort -r|head -10
alias rot13='perl -pe "y/A-Za-z/N-ZA-Mn-za-m/;"'
guid(){ lynx -nonumbers -dump http://www.famkruithof.net/uuid/uuidgen | grep "\w\{8\}-" | tr -d ' '; }
perl -le 'print join ", ", map { chomp; $_ } <>'
2009-02-06 12:50:43
User: jozef
Functions: join perl

joins multiple lines to create single line with comma separated values. for example if we have an email addresses one per line (copy&paste from spreadsheet) it will oputput one line with comman separated addresses to put it to email client.

gsed -e :a -e 's/\(<\/[^>]*>\)/\1\n/g;s/\(<br>\)/\1\n/g' page2.txt | sed -n '/<cite>/p;s/<cite>\(.*\)<\/cite>/\1/g' >> output
2009-02-06 12:45:20
User: shrimphead
Functions: sed

From a saved page of google search results, split out all of the links for the results. Useful for creating apache rewrite rules from.

perl -MHTML::Entities -ne 'print encode_entities($_)' /tmp/subor.txt
2009-02-06 12:44:24
User: jozef
Functions: perl

Encodes HTML entities from input (file or stdin) so it's possible to directly past the result to a blog or HTML source file.

find ~ -name '*.mp4' | xargs mplayer
rsync -av --progress ./file.txt user@host:/path/to/dir
2009-02-06 11:51:51
User: aoiaoi
Functions: rsync

transfer files from localhost to a remotehost.

sed "s/^ABC/+ABC/" <file | sed "s/DEF$/DEF+/" | tr "\n" "~" | tr "+" "\n" | grep "^ABC" | tr "~" "\n"
2009-02-06 11:29:29
User: poboxy
Functions: grep sed tr

If the file content is :


Blah blah blah


hello blah blah blah

bloh bloh bloh


Bah bah bah


You'll get:



hello blah blah blah

bloh bloh bloh


find . -exec grep "test" '{}' /dev/null \; -print
fuman(){ lynx -width=$COLUMNS -nonumbers -dump "http://www.commandlinefu.com/commands/using/$1" |sed '/Add to favourites/,/This is sample output/!d' |sed 's/ *Add to favourites/----/' |less -r; }
ssh -N -L2001:localhost:80 -o "ProxyCommand ssh someuser@hubmachine nc -w 5 %h %p" someuser@destinationmachine
2009-02-06 09:58:08
Functions: ssh

this is handy when the hubmachine is the only machine that can connect to the destination machine (allowed on ip by firewall) and you want to access it from your laptop.