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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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



All commands from sorted by
Terminal - All commands - 12,422 results
TIMEUNIT=$(awk '/timescale/{print NR}' a)
cho "(Something like http://foo.com/blah_blah)" | awk '{for(i=1;i<=NF;i++){if($i~/^(http|ftp):\/\//)print $i}}'
2009-11-28 03:31:41
Functions: awk

don't have to be that complicated

find -type d -name ".svn" -print0 | xargs -0 rm -rf
2010-02-25 10:16:18
User: tuxilicious
Functions: find rm xargs

man find: If no paths are given, the current directory is used. - Can anybody tell me why so many people are typing the dot?

groovy -e 'println URLEncoder.encode("Some text")'
mtr -c 50 -r example.com
2015-08-05 07:18:52
User: ohe

mtr is a network utility that combines traceroute and ping utility

find /path/to/dir -type f |sed 's/^.*\///'|grep -o '\.[^.]*$'|sort -f|uniq -i
schedtool 1
2009-08-06 08:42:03

Display information about the cores.

* sudo apt-get install schedtool

COPYFILE_DISABLE=true tar cvf newTarFile.tar Directory/
2010-07-01 09:36:48
User: alainkaa
Functions: tar
Tags: macosx

Using the COPYFILE_DISABLE=true environment variable you can prevent tar from adding any ._-files to your .tar-file on Mac OS X.

dirname $(readlink -f ${BASH_SOURCE[0]})
for i in {001..999}; print $i
2009-02-16 23:03:53
User: karld

zsh only

I always hated resorting to using $(seq -w 1 99) to pad numbers. zsh provides a shortcut that couldn't be more intuitive. It also works in reverse {99..01}

curl -s "https://www.random.org/cgi-bin/randbyte?nbytes=4" | od -DAn
2010-11-09 18:26:24
Functions: od
Tags: random

Grab 4 bytes from www.random.org over ssl and format them as an integer

grep -Ilr "<?php" .
tcpdump -nqt -s 0 -A -i eth0 port 5060
html2text http://checkip.dyndns.org | grep -i 'Current IP Address:'|cut -c21-36
tail -f LOGFILE | awk '{system("say \"" $0 "\"");}'
2011-09-16 06:20:06
User: tamouse
Functions: awk tail
Tags: awk tail say

like #9295, but awkish instead of perlish

tar -cf "../${PWD##*/}.tar" .
2013-11-06 11:15:38
User: joedhon
Functions: tar

should do the same as command #12875, just shorter.

cat schema.sql data.sql test_data.sql | mysql -u user --password=pass dbname
2009-03-24 08:39:40
User: tristan_ph
Functions: cat
Tags: mysql cat

Be aware of using the --password argument as it will appear your password in plain text on the screen. You may use -p argument instead, it will prompt you to enter you password in hidden mode.

wget http://www.discogs.com/search?q=724349691704 -O foobar &> /dev/null ; grep \/release\/ foobar | head -2 | tail -1 | sed -e 's/^<div>.*>\(.*\)<\/a><\/div>/\1/' ; rm foobar
2011-01-30 23:34:54
User: TetsuyO
Functions: grep head rm sed tail wget

Substitute that 724349691704 with an UPC of a CD you have at hand, and (hopefully) this oneliner should return the $Artist - $Title, querying discogs.com.

Yes, I know, all that head/tail/grep crap can be improved with a single sed command, feel free to send "patches" :D


echo -n "String to MD5" | md5sum | awk '{print $1}'
s=/etc/ssh/sshd_config;r=PermitRootLogin;cp $s{,.old}&& if grep $r $s;then sed "s/$r yes/$r no/" $s.old > $s; else echo $r no >> $s;fi
2011-01-30 23:41:59
User: kzh
Functions: cp echo grep sed
Tags: bash openssh

This will tighten up security for your box. The default value for PermitRootLogin sadly is 'yes'.

mysql -u <user> --password=<password> -e "SHOW COLUMNS FROM <table>" <database> | awk '{print $1}' | tr "\n" "," | sed 's/,$//g'
2009-10-29 13:42:17
User: maxmanders
Functions: awk sed tr

Useful when you need to write e.g. an INSERT for a table with a large number of columns. This command will retrieve the column names and comma-separate them ready for INSERT INTO(...), removing the last comma.

ffmpeg -i movie.mpg -vhook '/usr/lib/vhook/watermark.so -f overlay.png -m 1 -t 222222' -an mm.flv
fdupes DIRECTORY/ -r -d
2011-03-05 09:48:35
User: desmatron

allow you to find duplicates files in "DIRECTORY" and choose wich one to delete

fudpes must be installed: sudo apt-get install fdupes

( while read File; do mogrify -resize 1024 -quality 96 $File; done ) < filelist
2009-02-08 02:48:26
User: Corsair
Functions: read

Imagemagick library is used. If image format is not JPEG, the "quality" option should not be issued.

sudo service bluetooth restart