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,274 results
gzip -c source.csv > source.csv.gz
2012-10-17 18:31:51
User: cfunz
Functions: gzip
Tags: gzip aix

use this command to gzip the file and write to stdout and from the stdout redirect to the another file

find ~/.thunderbird/*.default/ -name *.msf | sed 's/ /\\ /g' | xargs rm {} \;
2010-06-04 12:35:24
User: allrightname
Functions: find rm sed xargs

The thunderbird message datastores get corrupt some times causing random failures, compaction to fail and general suck in thunderbird. Removing them causes thunderbird to rebuild the indexes and makes things quick again.

fdupes -rdN $folder
openssl pkcs8 -inform DER -nocrypt -in [priv key] -out [pem priv key]
eval $(curl -s http://www.commandlinefu.com/commands/matching/external/ZXh0ZXJuYWw=/sort-by-votes/plaintext|sed -n '/^# Get your external IP address$/{n;p;q}')
2009-11-04 16:58:31
User: jgc
Functions: eval sed

This command uses the top voted "Get your external IP" command from commandlinefu.com to get your external IP address.

Use this and you will always be using the communities favourite command.

This is a tongue-in-cheek entry and not recommended for actual usage.

PATH="${PATH}:$(find ${HOME}/bin -type d | tr '\n' ':' | sed 's/:$//')"
2013-06-19 19:22:06
User: malathion
Tags: $PATH

Many users have a personal ~/bin folder for user scripts and other miscellaneous applications they can't or don't want to add to /usr/bin. But this folder can get large and unwieldy. The above command adds ~/bin and all its subdirectories to the PATH environment variable so the scripts can be organized without changing .bashrc.

openssl ans1parse -inform DER < [priv key]
2009-02-05 16:54:19
User: wwest4

a pkcs8 key will have integer 00 at offset 4 and an rsaEncryption object at offset 9

defaults write com.apple.finder NSUserKeyEquivalents -dict 'New Finder Window' '@$N' 'New Folder' '@N'; killall Finder
2009-02-17 23:20:53
User: Vulpine
Functions: killall write

In Mac OS 9, the "New Folder" keyboard shortcut was Command+N, but in Mac OS X this was changed to "New Finder Window" instead, with "New Folder" taking the more awkward shortcut of Command+Shift+N. This command reverses their mappings.

find -name ".php" -exec perl -pi -e 's/search/replace/g/' {} \;
git push origin --all
awk "/<xsd:annotation>/{h=1};!h;/<\/xsd:annotation>/{h=0}" annotatedSchema.xsd
2011-07-15 07:17:17
User: 2chg
Functions: awk
Tags: xml filter

Removes all lines between the lines containing "" and "", including these lines itself


Sometimes when working with XML files without an graphical editor, large comment-/annotation-blocks taper the readability to walk through the file. I like to create a copy of such documents without these annotations. As the documentation itself is in documentation tags inside the annotation tags an therefore graphical editors tend to put the annotation tags in their own lines, this command removes all documentations within annotation-tags.

ip route show | awk '$3 ~ /^[1-9]+/ {print $3;}'
2010-08-08 23:57:23
User: kerim
Functions: awk route

Find your default gateway and print it directly output.



ping -c 1 www.google.com | /usr/bin/awk '{print $7}' | /usr/bin/awk 'NR > 1' | /usr/bin/awk 'NR < 2' | /usr/bin/awk -F"=" '{print $2}'
2010-12-15 08:50:52
User: ackers
Functions: ping

Does one ping to a URL or host, and echo out just the response time. I use this on, with MRTG to monitor the connections to various hosts.

for f in ~/.mcabber/histo/*; do a=`egrep "^(MR|MS)" $f | wc -l`; echo $f: $a | awk -F\/ '{print $6}'; done
dd bs=1 if=/dev/zero of=/path/to/imagename.raw seek=50G count=1 conv=notrunc
update-alternatives --config x-terminal-emulator
ipcalc $(ifconfig eth0 | grep "inet addr:" | cut -d':' -f2,4 | sed 's/.+Bcast:/\//g') | awk '/Network/ { print $2 } '
ldd path_to_executable
echo "John's" | grep -Po '\b\w+(?<!s)\b'
function ldd(){ objdump -p $1 | grep -i need; }
2010-09-07 02:44:59
User: jyf
Functions: grep objdump
Tags: ldd

use this to avoid executing the target app

sudo ifconfig wlan0 | grep inet | awk 'NR==1 {print $2}' | cut -c 6-
2013-02-18 14:10:07
User: mouths
Functions: awk cut grep ifconfig sudo

On wired connections set 'eth0' instead of 'wlan0'

awk '{out="";for(i=2;i<=NF;i++){out=out" "$i};sub(/ /, "", out);print out}'
2015-05-06 22:26:28
User: endix
Functions: awk
Tags: awk

Increase "2" in "i=2" to drop more columns.

sqlite3 $HOME/.dropbox/config.db "select value from config where key like '%dropbox_path%'"
2011-06-05 08:26:02
User: mobilediesel

Newer versions of Dropbox let you choose the location for your Dropbox folder. If you use script to put things into your Dropbox folder (todo list, screenshots, torrents etc.) but have the Dropbox folder in different locations on your other computers this lets you use the same script on all systems without having to tell it where the Dropbox folder is.

script -qf | tee >(nc -l -p 5000)
ct find -avobs -nxname -element 'brtype(branch_name)' -print 2>/dev/null