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.

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





All commands from sorted by
Terminal - All commands - 12,273 results
sniff_host: tcpdump -nn -i eth1 -w - | nc 666
jot -s '' -r -n 8 0 9
2009-08-24 13:35:20
User: Hal_Pomeranz
Tags: random jot rs

Don't need to pipe the output into rs if you just tell jot to use a null separator character.

curl -s "http://services.digg.com/stories?link=$NEWSURL&appkey=http://www.whatever.com&type=json" | python -m simplejson.tool | grep diggs
find /backup/directory -name "FILENAME_*" -mtime +15 -exec rm -vf {};
mount -t ntfs-3g -o ro,loop,uid=user,gid=group,umask=0007,fmask=0117,offset=0x$(hd -n 1000000 image.vdi | grep "eb 52 90 4e 54 46 53" | cut -c 1-8) image.vdi /mnt/vdi-ntfs
tweet(){ curl -u "$1" -d status="$2" "http://twitter.com/statuses/update.xml"; }
2009-08-23 16:56:24
User: Code_Bleu

Type the command in the terminal and press enter to create the tweet() function. Then run as follows:

tweet MyTwitterAccount "My message goes here"

It will prompt you for password. Make sure that you use escape "\" character in message for showing varialbles or markup.

awk '!a[$0]++' file
2009-08-23 15:28:43
User: voyeg3r
Functions: awk

This create an array 'a' with wole lines. only one occurrence of each line - Not Get lines ++ !

mount -t unionfs -o dirs=/tmp/unioncache=rw:/mnt/readonly=ro unionfs /mnt/unionfs
2009-08-23 14:16:13
User: Cowboy
Functions: mount

First look into /etc/modules if you have unionfs (or squashfs) support. If not, add the modules. UnionFS combines two filesystems. If there is a need to write a file, /tmp/unioncache will be used to write files (first create that directory). Reads will be done where the file is found first.


locate -e somefile | xargs ls -l
2009-08-23 13:16:59
User: nadavkav
Functions: locate ls xargs

use the locate command to find files on the system and verify they exist (-e) then display each one in full details.

rm -vf /backup/directory/**/FILENAME_*(m+15)
awk '!($0 in a) {a[$0];print}' file
structcp(){ ( mkdir -pv $2;f="$(realpath "$1")";t="$(realpath "$2")";cd "$f";find * -type d -exec mkdir -pv $t/{} \;);}
2009-08-23 11:26:38
User: frozenfire
Functions: mkdir
Tags: copy

Copies a dir structure without the files in it.

shutdown -h 60
2009-08-23 11:02:39
User: MikeTheGreat
Functions: shutdown
Tags: Shutdown

Replace 60 with the number of minutes until you want the machine to shut down.

Alternatively give an absolute time in the format hh:mm (shutdown -h 9:30)

Or shutdown right away (shutdown -h now)

nautilus -q
2009-08-23 10:38:30
User: deasc

man nautilus (1) - the GNOME File Manager




Quit Nautilus.

ps But if it hang up, you should kill it with -9 of couse

cp -pr olddirectory newdirectory
2009-08-22 22:11:24
User: stanishjohnd
Functions: cp

cp options:

-p will preserve the file mode, ownership, and timestamps

-r will copy files recursively

also, if you want to keep symlinks in addition to the above: use the -a/--archive option

y=http://www.youtube.com;for i in $(curl -s $f|grep -o "url='$y/watch?v=[^']*'");do d=$(echo $i|sed "s|url\='$y/watch?v=\(.*\)&.*'|\1|");wget -O $d.flv "$y/get_video.php?video_id=$d&t=$(curl -s "$y/watch?v=$d"|sed -n 's/.* "t": "\([^"]*\)",.*/\1/p')";done
2009-08-22 21:31:29
User: matthewbauer
Functions: echo grep sed

This will download a Youtube playlist and mostly anything http://code.google.com/apis/youtube/2.0/reference.html#Video_Feeds

The files will be saved by $id.flv

yes n
tar -C /oldirectory -cvpf - . | tar -C /newdirector -xvf -
2009-08-22 20:05:49
User: Cowboy
Functions: tar

It's the same like 'cp -p' if available. It's faster over networks than scp. If you have to copy gigs of data you could also use netcat and the tar -z option in conjunction -- on the receiving end do:

# nc -l 7000 | tar -xzvpf -

...and on the sending end do:

# tar -czf - * | nc otherhost 7000

jot -r -n 8 0 9 | rs -g 0
watch --interval 0 'iptables -nvL | grep -v "0 0"'
2009-08-22 18:18:05
User: Code_Bleu
Functions: grep watch

This will allow you to watch as matches occur in real-time. To filter out only ACCEPT, DROP, LOG..etc, then run the following command: watch 'iptables -nvL | grep -v "0 0" && grep "ACCEPT"' The -v is used to do an inverted filter. ie. NOT "0 0"

find /backup/directory -name "FILENAME_*" -mtime +15 | xargs rm -vf
rmdir **/*(/^F)
pgrep -u `id -u` firefox-bin || find ~/.mozilla/firefox -name '*.sqlite'|(while read -e f; do echo 'vacuum;'|sqlite3 "$f" ; done)
2009-08-22 10:36:05
User: kamathln
Functions: echo find read

Sqlite database keeps collecting cruft as time passes, which can be cleaned by the 'vacuum;' command. This command cleans up the cruft in all sqlite files relating to the user you have logged in as. This command has to be run when firefox is not running, or it will exit displaying the pid of the firefox running.

find / -type f -exec wc -c {} \; | sort -nr | head -100
sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).in-addr.arpa domain name pointer\(.*\)\./\4.\3.\2.\1\5/' \ lookups.txt
2009-08-22 09:37:20
User: hemanth
Functions: sed
Tags: sed

Reverse DNS lookups, from a file with list of IP's, here the file is called lookups.txt