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,925 results
metascore(){ curl -s "http://www.metacritic.com/$@" | sed -rn 's|\t*<!-- metascore --><div id="metascore" class=".*">([^<]*)</div>|\1|p'; }
2010-03-18 21:49:13
User: matthewbauer
Functions: sed

This will fetch a metascore from metacritic.com.

It requires a url from metacritic without the http://www.metacritic.com/


metascore games/platforms/wii/supermariogalaxy


metascore tv/shows/marriageref


metascore video/titles/newmoon

Would be cool to use this in some sort of a graph.

rsync --delete -az -e 'ssh -c blowfish -i /your/.ssh/backup_key -ax' /path/to/backup remote-host:/dest/path/
while read line; do pais=$(whois "$line" | grep -E '[Cc]ountry') echo -n "IP=$line Pais=$pais" && echo done <listaip
(pv -n long_running > output) 2>&1 | zenity --progress
complete -W "$(sed 's/;.*//;' /etc/hosts | awk ' /^[[:digit:]]/ {$1 = "";print tolower($0)}')" ssh
2011-06-20 03:54:45
User: daodennis

If you have a lot of hosts in /etc/hosts this would be very useful. Anyone have any more concise examples?

TEST_UUID=$(blkid /dev/sda6 | sed -rn "s/^.*UUID=\"([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})\".*/\1/p")
curl icanhazip.com
for FILE in $(svn status | grep ? | grep .php); do svn add $FILE; done
2011-12-27 17:49:33
Functions: grep
Tags: svn PHP

simply change extension for others programming languages

ifconfig | grep "inet" | grep "broadcast" | awk '{print $2}'
ls -rt | tail -n 1
gcal -K -q GB_EN December/2012-January/2013 # Holidays for Dec/2012 and Jan/2013 with week numbers
2012-11-07 18:01:31
User: mpb

Display the holidays in December and January for UK/England (2012/2013).

Most Linux distros have "gcal" in their package manager system.

If not, it is available here: http://www.gnu.org/software/gcal

tshark -r *.eth -S -R "ajp13" -d tcp.port==9009,ajp13 -s 0 -l -V | awk '/Apache JServ/ {p=1} /^ *$/ {p=0;printf "\n"} (p){printf "%s\n", $0} /^(Frame|Internet Pro|Transmission Control)/ {print $0}'
2013-01-10 21:12:51
User: tsureshkumar
Functions: awk printf
Tags: tshark

if you have a capture file *.eth, and ajp protocol is in use on port 9009, you can paste the above command. You can change the fiile and port name

cat -n install | head -n 150 | tac | head -n 50 | tac
uptime | awk -F ',' ' {print $1" "$2}'|awk ' {print $3" "$4" "$5}' | sed '1,$s/:/ /' | awk ' {if ($4 =="user") print $1*60 + $2;else if ($2=="mins") print $1;else print $1*24*60 + $2*60 + $3}'
2013-07-19 13:28:29
User: tatgren
Functions: awk sed uptime
Tags: uptime minutes

find the uptime and convert in minutes, works with AIX and Linux too

pactl list sinks | grep -q Mute:.no && pactl set-sink-mute 0 1 || pactl set-sink-mute 0 0
for i in *.djvu; do djvu2pdf $i && echo "Finished -> $i"; done;
ls *(m-1)
echo sortmeplease|sed 's/./&\n/g'|sort|tr -d '\n'
cat filename | uuencode filename | mail -s "Email subject" user@example.com
2009-09-21 04:13:50
User: amaymon
Functions: cat mail uuencode
Tags: cat mail

uuencode the file to appear as an attachment

sleep 4; F="$(tempfile -s '.xwd')"; xwd > "$F" ; gimp "$F"
echo $(echo 'scale=2; ' '100 * ' $(eix --only-names -I | wc -l) / $(eix --only-names | wc -l) | bc -l)%
watch -n 1 :
2011-02-16 13:38:37
User: daniele
Functions: watch

Clock will appear in the top-right corner

sudo tcpdump -i en0 'udp port 53'
convert /home/user/file.jpg -resize 800x533 -strip -quality 80 -interlace line /home/user/web_file.jpg
grep -r <searchterm> .
2012-02-08 11:58:21
Functions: grep
Tags: grep directory

You don't need to use "*", it will fail if the working directory has too many fails due parameter extension, you can simply pass the working directory using ".".