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,378 results
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'

find ./ -iname "*.dmp" -maxdepth 0 -type f -exec tar czvf {}.tar.gz --remove-files {} \; \;
2011-09-07 08:36:29
User: evilinside
Functions: find tar

This command will :

-Archive all *.dmp files individually (one file per archive) from current directory .

-Delete original file after has been compressed.

wget -qO - --post-data "data[Row][clear]=text" http://md5-encryption.com | grep -A1 "Md5 encrypted state" | tail -n1 | cut -d '"' -f3 | sed 's/>//g; s/<\/b//g'
2011-10-13 03:44:48
User: samhagin
Functions: cut grep sed tail wget
Tags: md5

Encrypt any text to MD5 , replace text with the string you want to convert to MD5

perl -MO=Deparse filename.pl | perltidy > new.pl
2011-11-16 18:54:30
User: kimmel
Functions: perl

This will create a new file with proper code formatting and all comments removed.

groovy -e "def output=args[0]; def terms = args[1].split(','); terms.each { it -> def keyValues = it.split(':'); output = output.replaceAll(keyValues[0],keyValues[1]); } println output;" "`diff -rq . SRC DEST`" "old1:new1,old2:new2"
2012-03-24 02:52:22
User: airline

Script has to be modified to be executable! SRC and DEST a relative unix path, olds and news are the terms to be modified.

Very helpful to sync source folders present in different SCM.

If you dont like this one, just use rsync...

cloc --force-lang=yaml --match-f='\.url$' .
watch 'mysql -e "show full processlist;"'
find . -type f -exec grep -Hn <pattern> {} \;
curl -L -d "uid=<username>&pwd=<password>" http://www.example.com -c cookies.txt
2012-11-10 19:08:45
User: drwlrsn
Tags: curl http python

Generate a Netscape cookies file to use with Python's mechanize.

for code in $(seq -w 0 255); do for attr in 0 1; do printf "%s-%03s %bTest%b\n" "${attr}" "${code}" "\e[${attr};38;05;${code}m" "\e[m"; done; done | column -c $((COLUMNS*2))
2013-01-13 18:23:44
User: claudius
Functions: column printf seq
Tags: bash color colors

Shows the ?rendering? for each of the 256 colours in both the bold and normal variant. Using seq is helpful to get even lines, passing $((COLUMNS*2)) to column sort-of-handles the nonprintable characters.

pwd|grep -o '/'|perl -ne '$x.="./.";print`readlink -f $x`'|xargs -tn1 chmod 755
2013-03-14 12:03:44
Functions: chmod grep perl pwd xargs

`pwd` returns the current path

`grep -o` prints each slash on new line

perl generates the paths sequence: './.', './../.', ...

`readlink` canonicalizes paths (it makes the things more transparent)

`xargs -tn1` applies chmod for each of them. Each command applied is getting printed to STDERR.