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
rsync -arvx --numeric-ids --stats --progress --bwlimit=1000 file server:destination_directory
2013-10-01 13:00:59
Functions: file rsync
Tags: Linux rsync

Useful for transferring large file over a network during operational hours

mysqldump --force -uUSER -pPASS PRODUCTION_DB | mysql -uUSER -pPASS COPY_DB
2014-01-02 19:04:50
User: bones

this command uses mysqldump to dump the production database and pipe it directly to the copy-database

xxd -l 20 -c 20 -p /dev/urandom
2014-03-26 09:44:04
User: jt
Tags: password

Dumps 20 bytes from /dev/urandom and converts them to hex. -c and -p are needed to prevent splitting over lines.

sed -n '/url/s#^.*url=\(.*://.*\)#\1#p' ~/.mozilla/firefox/*.[dD]efault/SDBackups/*.speeddial | sort | uniq
2015-02-17 20:56:28
User: return13
Functions: sed sort

For all users of https://addons.mozilla.org/de/firefox/addon/speed-dial/

write user anytext
watch --no-title -d -n 1 'echo `date -d "next Thursday" +%s` "-" `date +%s` | bc -l'
2009-03-29 06:53:09
User: jnash
Functions: bc watch

Might be more useful if you were able to print it in Days HH:MM:SS format as:

perl -e [email protected]=gmtime(234234);printf("%d Days %02d:%02d:%02ds\n",@p[7,2,1,0]);'

But I'm not exactly sure how to replace the 234234 with the output of the countdown time. (Having some problems with nested quoting/command substitution). Help would be appreciated :)

vim ~/.purple/pounces.xml
2009-04-28 19:11:39
Functions: vim
Tags: vim pidgin

So you keep getting buzzes sounding from pidgin but you can't remember which buddy pounce is causing the beep. Well, cat/edit the ~/.purple/pounces and find out!

ls -t1 | head -n1 | xargs tail -f
find / -type f -size +512000 | xargs ls -lh | awk '{ print $5 " " $6$7 ": " $9 }'
2010-05-12 17:21:12
User: johnss
Functions: awk find ls xargs

This is an updated version that some one provided me via another "find" command to find files over a certain size. Keep in mind you may have to mess around with the print values depending on your system to get the correct output you want. This was tested on FC and Cent based servers. (thanks to berta for the update)

wmic process list IO
2010-08-20 11:05:34
User: glaudiston

there's some options, see more details in :

wmic /?

wmic process /?

wmic process list /?

pi 62999 | tr 0-9 del\ l\!owrH
2011-07-29 22:47:53
User: maurol
Functions: tr
Tags: bash pi

Pi also says hello world!

python -c 'import string, random; print "".join(random.choice(string.letters+string.digits) for x in range(6))'
awk -F: '$3 > 999 { print $1 }' /etc/passwd
2011-12-30 14:47:10
User: rockenrola
Functions: awk
Tags: awk uid passwd

To distinguish normal users from system users. Specify an UID, to list all all users with UID bigger than that in /etc/passwd.

show_code() { pygmentize $1 | less -N }
2012-05-12 09:18:33
User: Flow
Functions: less

Uses pygments ( http://pygments.org/ ) to highlight the source code and a less pipe to scroll and show line numbers of the code.

find . | while read line; do test `stat -c %u $line` -eq 1003 && chown android:android $line && echo $line; done
watch -d=c -n3 'lsof -itcp -iudp -c php'
2013-03-14 01:24:50
User: AskApache
Functions: watch
Tags: lsof PHP watch

Shows files and processes of the command php

sudo apt-key adv --keyserver hkp://keys.gnupg.net:80 --recv-keys [key to get here]
2013-07-23 08:29:40
User: phattmatt
Functions: get sudo

If you are an unlucky soul behind a corporate firewall you will likely find that downloading gpg keys is blocked. This is because the hkp protocol uses port 11371 by default to transfer the key.

By adding "hkp://" to the beginning of the hostname and ":80" to the end you are asking gpg to try using port 80 to connect (less likely to be blocked by a firewall). This relies on the remote server answering to requests over port 80.

icacls directory_or_file /remove:g group_or_user
for i in *.svg; do convert "$i" "${i%.svg}.png" & done
2014-03-26 15:03:54
User: robinro

convert all *.svg to png _in parallel_

this speeds up the conversion for many files, but might also not be feasible for a large number of files

find . -type f -iname '*.flac' | while read i; do mv -- "$i" "$i.tmp"; gst-launch filesrc location="$i.tmp" ! flacdec ! flacenc quality=8 ! filesink location="${i%.tmp}"; rm -- "$i.tmp"; done
2014-07-10 19:21:22
User: qdrizh
Functions: find mv read rm

Sometimes I get FLAC files that RhythmBox can't play but VLC can. So I re-encode them using GStreamer at highest compression.

grep 'font-family:[^;]*' <input file.svg> | sed 's/.*font-family:\([^;]*\).*/\1/g' | sort | uniq
2014-11-03 20:38:08
User: caiosba
Functions: grep sed sort
Tags: fonts svg

List all fonts used by an SVG file. Useful to find out which fonts you need to have installed in order to open/edit an SVG file appropriately.

sftp -s "sudo /usr/lib/sftp-server" [email protected]
2009-03-29 07:02:58
User: mrtheplague
Functions: sftp

This requires that your sudo not prompt for a password, as sftp cannot allocate the terminal necessary to ask.

find . | xargs file | grep ".*: .* text" | sed "s;\(.*\): .* text.*;\1;"
ord () { seq 1 127 | while read i; do echo `chr $i` $i; done | grep "^$1 " | cut -c '3-' }
2009-10-16 21:54:01
User: infinull
Functions: cut echo grep read seq

uses the previous "chr" function and uses it to create the inverse function "ord" by brute force.

It's slow, It's inelegant, but it works.

I thought I needed ord/chr to do a cartesian cipher in shell script a whie ago, but eventualy I realized I could get fancy with tr and do the same thing...

rm-but() { ls -Q | grep -v "$1" | xargs rm -r ; }
2010-05-13 09:28:56
User: sata
Functions: grep ls rm xargs
rm-but() { ls -Q | grep -v "$1" | xargs rm -r ; }

Add this to your .bashrc file.

Then whenever you need to remove all files/directories but one from present working directory. Run:

rm-but <important-file-or-directory>


1. This doesn't affect the hidden files.

2. Argument is actually as string. And all files/directories having this string in there name are left untouched.