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.

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



Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

All commands from sorted by
Terminal - All commands - 12,364 results
perltidy foo.pl
2010-07-19 11:51:47
User: bartonski

By default, perltidy will create a file with the extension '.tdy'.

lsof -i :[port number]
F=index.html; for i in *; do [[ $i = $F ]] && continue; echo "<li><a href='$i'>$i</a>"; done >$F
perl -MExtUtils::Installed -E 'say for ExtUtils::Installed->new()->modules()'
2011-11-16 17:26:47
User: kimmel
Functions: perl
Tags: perl oneliner

Lists all the modules that were installed the "proper way". It also uses Perl 5.10(or higher)'s say command for less typing.

xsltproc --stringparam name value <xsl_stylesheet> <xml_document>
2012-11-09 15:54:46
User: seb1245
Tags: xml XSLT

The XML document can be transformed to text, XML, HTML or anything else. The --stringparam option allows to set XSL variables externally.

FILE='mp3.list';LNNO=`wc -l $FILE|cut -d' ' -f 1`;LIST=( `cat $FILE` );for((;;)) do SEED=$((RANDOM % $LNNO));RNNO=$(python -c "print int('`openssl rand -rand ${LIST[$SEED]} 8 -hex 2>/dev/null`', 16) % $LNNO");mplayer ${LIST[$RNNO]};sleep 2s; done
icacls directory_or_file /grant user_or_group:(oi)(ci)(m,dc)
putty -L 631:localhost:631 [email protected]
awk '/text to grep/{print \$1}' logs... | sort -n | uniq -c | sort -rn | head -n 100
2014-07-10 20:36:02
User: impinball
Functions: awk head sort uniq
Tags: Linux sh

Accepts multiple files via logs.... Substitute "text to grep" for your search string.

If you want to alias this, you could do something like this:

alias parse-logs='awk "/$1/{print \$1}" ${@[@]:1} | sort -n | uniq -c | sort -rn | head -n 100'
lame -v 2 -b 192 --ti /path/to/file.jpg audio.mp3 new-audio.mp3
vos listvldb | agrep LOCKED -d RWrite | grep RWrite: | awk -F: '{print $2}' | awk '{printf("%s ",$1)} END {printf("\n")}'
2009-03-17 19:55:39
User: mpb
Functions: awk grep

This command shows if there are any locked AFS volumes.

The output is a list of AFS volume IDs (or nothing if there are none locked).

:%s/^/\=line('.').' '
2009-08-16 17:48:03
User: voyeg3r

Use this command to insert line numbers in source files, .' ' control how spaces you insert after number.

chr () { echo -en "\0$(printf %x $1)"}
ls -l | grep ^-
www-browser http://en.wikipedia.org/wiki/$(date +'%b_%d')
2011-05-09 02:42:32
User: benjabean1
Functions: date
Tags: bash

Improved version of command #8425.

This way, the default browser is used, as opposed to Firefox.

echo $(($(ulimit -u)-$(pgrep -u $USER|wc -l))
perl -le 'print scalar gmtime shift' 1234567890
full() {local i;for i in $*;do readlink -f $i;done}
2012-02-09 11:40:05
User: flxndn
Functions: readlink

You can use the command "full" not only with one item, with items with diferent paths, and with relatives and absolute paths.

function cdf () { [ -f $1 ] && { cd $(dirname $1); } || { cd $1 ; }; pwd; };
2012-09-08 10:50:58
User: Josso
Functions: cd dirname
Tags: bash ksh

Had trouble with the other function, because of missing semicolons. (According to my bash on OS X)

sudo cp /usr/share/zoneinfo/Europe/Paris /etc/localtime
ps -eLF | grep ^user
2013-07-24 09:53:12
User: balsagoth
Functions: grep ps
Tags: bash processes

This shows all process (-e) and threads (-L) in full format (-F)

watch ls -lh /path/to/folder
2014-03-27 10:51:36
User: vonElfensenf
Functions: ls watch
Tags: pv

forgot to use a pv or rsync and want to know how much has been copied.

ssh -X [email protected] 'DISPLAY=:0 notify-send "TEST MESSAGE."'
echo 'Enter Picasa album RSS URL:"; read -e feedurl; GET "$feedurl" |sed 's/</\n</g' | grep media:content |sed 's/.*url='"'"'\([^'"'"']*\)'"'"'.*$/\1/' > wgetlist
2009-09-22 10:51:08
User: kamathln
Functions: echo

Grab the RSS link to the Picasa album. Feed it to the script when its hungry. When its done writing the shopping list, just use

wget -c -i wgetlist

to get your stuff.

sudo du -sm * | sort -n
2010-09-24 17:56:41
User: wabi
Functions: du sort sudo

sudo is optional, but to find out about all files, it is nice, or else run as superuser, ie: su -c 'du -sm * | sort -n'