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,847 results
convert input.png -pointsize 32 -gravity center -annotate 45 "hello, world" output.png
find $(locate hello) -type f -executable -print|grep -E "hello\$"
2012-08-18 07:51:53
Functions: find grep locate

This command allow you quick find any executable by keyword(s) in your system.

NOTE: Sometime this command will output like this:

`hello.py.launch': No such file or directory

this is normal behaviour

find -type f -printf '%P\000' | egrep -iz '\.(avi|mpg|mov|flv|wmv|asf|mpeg|m4v|divx|mp4|mkv)$' | sort -z | xargs -0 ls -1
/sbin/ifconfig | grep inet | cut -f 2 -d ":" | cut -f 1 -d " " |egrep -v "^$"
for i in `seq 254`;do ping -c 1 192.168.10.$i > /dev/null && echo "$i is up"||echo "$i is down";done
cls && ipconfig | findstr -R "[ IPv4 | adapter ]"
mdfind "tag:data" > /tmp/data.txt ; zip -r9@ ~/Desktop/data.zip < /tmp/data.txt
2009-02-24 14:49:50
User: vranx
Tags: Os X

finding all files with the metadata tag "data" using the metadata find command mdfind , writing the list to a temporary file, reading the input for the .zip file from this temporary file.

echo $X | egrep "^[0-9]+$"
find . -iname \*.[ch] -exec indent "{}" \;
2010-09-10 13:25:10
User: putnamhill
Functions: find

This version uses the indent C formatting utility. Doesn't appear to be included with ubuntu. But CentOS and MacOS have it.

flipf(){ if [ -f "$1" -a -f "$2" ]; then mv "$1" "$1.$$" && mv "$2" "$1" && mv "$1.$$" "$2" || echo "$!"; else echo "Missing a file: $!"; fi; }
for file in "* *"; do mv "${file}" "${file// /_}"; done
ls /var/log/sa/sa[0-9]*|xargs -I '{}' sar -u -f {}|awk '/^[0-9]/&&!/^12:00:01|RESTART|CPU/{print "%user: "$4" %system: "$6" %iowait: "$7" %nice: "$5" %idle: "$9}'|sort -nk10|head
cls && ipconfig | findstr -R "[ IPv4 | adapter ]"
egrep -ie "<*HREF=(.*?)>" index.html | awk -F\" '{print $2}' | grep ://
caff <keyid>
2009-02-18 14:09:03
User: raphink
Tags: GPG

Requires: signing-party (on Debian).

Note: you need a working MTA on your machine.

curl queip.tk/ip
alias :q='tput setaf 1; echo >&2 "this is NOT vi(m) :/"; tput sgr0'
2009-12-08 12:59:44
User: sputnick
Functions: alias echo tput
Tags: vim alias vi tput

For vi(m) users :

Add it in your ~/.bashrc

Add an "exit" @ the end if you are masochist ;)

tune2fs -l /dev/XXXX | grep -w ^"Block size:"
2011-02-10 16:39:14
User: ncaio
Functions: grep tune2fs

the result of the command helped a check the Maximum file size and Maximum file system size.

EXT3 Exemple:

Block size; MAX File size; Maximum file system size

1 KiB; 16 GiB ; 2 TiB

2 KiB ; 256 GiB ; 8 TiB

4 KiB ; 2 TiB ; 16 TiB

8 KiB[limits 1]; 2 TiB; 32 TiB

for i in $(wget -O- -U "" "http://wallbase.cc/random/23/e..." --quiet|grep wallpaper/|grep -oe 'http://wallbase.cc[^"]*'); do wget $(wget -O- -U "" $i --quiet|grep -oe 'http://[^"]*\.jpg');done
watch -n -0.1 fbcmd stream timeline
2013-04-20 17:36:18
User: hako
Functions: watch

Streams your timeline on the commandline, required fbcmd


function ends_in_y() { case $(date +%A) in *y ) true ;; * ) false ;; esac } ; ends_in_y && echo ok
2010-04-06 22:18:52
Functions: date echo false true

The shell has perfectly adequate pattern matching for simple expressions.

VARNAMES='ID FORENAME LASTNAME ADDRESS CITY PHONE MOBILE MAIL' ; cat customer.csv | while read LINE ; do COUNT=1 ; for VAR in $VARNAMES ; do eval "${VAR}=`echo $LINE | /usr/bin/awk {'print $'$COUNT''}`" ; let COUNT=COUNT+1 ; done ; done
2009-05-19 11:23:00
User: GeckoDH
Functions: cat eval read


cat customer.csv | while read LINE ; do


for VAR in $VARNAMES ; do

eval "${VAR}=`echo $LINE | /usr/bin/awk {'print $'$COUNT''}`"




Maybe you have a CSV-File with addresses, where you have to process each contact (one per line, write each value to own variable). Of course you can define every variable, but this way is more simple and faster (to write).

VARNAMES includes the variable names. Pay attention: the number of names in VARNAMES have to be the same than in the CSV-file the fields. If the CSV is not seperated with ";", you can set the seperator after the awk-binary with -F"_" for example.

svn co http://simile.mit.edu/repository/crowbar/trunk&& cd ./trunk/xulapp/ xulrunner --install-app && Xvfb :1 && DISPLAY=:1 xulrunner application.ini 2>/dev/null 1>/dev/null && wget -O- ""
2010-10-16 05:12:11
User: argv
Functions: cd wget

some other options:



much more with piggybank as scraper

works well with your favourite curses or non-curses http clients

VBoxManage storageattach "volpedimongibello" --storagectl "fighetto" --port 1 --device 0 --type dvddrive --medium "/tanto/mipaghi/tutto.iso
2012-01-31 14:42:54
User: 0disse0

was inspired by http://www.commandlinefu.com/commands/view/8936/boot-from-a-block-device-without-giving-root-privilege-to-virtual-box

volpedimongibello= virtual machine name

fighetto= controller name

tutto.iso= DVD iso image

How to remove the DVD:

VBoxManage storageattach "volpedimongibello" --storagectl "fighetto" --port 1 --device 0 --type dvddrive --medium none

2009-02-13 21:58:42
User: Aldiansblog

When you need to work a long time in the same directory, which prompt is of the type:


it is better to hide all this with the command PS1='$'

To retrieve a normal prompt, type: PS1='$PWD$ '