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





Maintained by Jon H.

Site originally by David Winterbottom (user root).

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,388 results
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
telnet towel.blinkenlights.nl
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
kill -9 $(ps -ef | grep [h]ttpd | awk '{print $2}')
echo -e "CHECK=SAMPLE" output --command_to_long
2013-04-03 08:46:47
User: techie
Functions: echo

This is longer than others on here. The reason for this is I have combined two different matrix commands so it would work on all computers. I logged onto my server through a computer and it worked fine. I logged into my server through a mac and it looked $4!t so I have made one that works through both.

ps -e -o pid,vsz,comm= | sort -n -k 2
2014-05-14 00:36:50
Functions: ps sort

left-most column is PID, middle is virtual memory being consumed, right-most is actual process.

find . -size 0 -print0 | xargs -0 rm
2009-10-29 14:10:02
User: osvaldofilho
Functions: find xargs

The command find search commands with size zero and erase them.

date MMDDhhmmYYYY
2010-05-29 08:26:13
User: christian773
Functions: date

date MMDDhhmmYYYY

date MMDDhhmm

# example 27.12.1975 08:00

date 122708001975