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,408 results
gsettings reset com.canonical.Unity.Dash favorite-scopes
2016-02-07 17:50:19
User: bugmenot
Functions: reset

To fix this bug: https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1389698

busybox nameif newname $(</sys/class/net/oldname/address)
2010-05-15 10:24:57
User: patrick2000
Functions: nameif

rename a network interface

e.g. make eth0 eth1 or vice versa

the interface needs to be down -> "/sbin/ifconfig oldname down"

ls -t1 $* | head -1 ;
2012-02-10 22:13:24
Functions: head ls

Returns the most recently modified file in the current (or specified) directory. You can also get the oldest file, via:

ls -t1 $* | tail-1 ;

tail -F /var/log/nginx/access.log | python -c 'exec("import sys,time\nl=0\ne=int(time.time())\nfor line in sys.stdin:\n\tt = int(time.time())\n\tl += 1\n\tif t > e:\n\t\te = t\n\t\tprint l\n\t\tl = 0")'
2012-05-15 21:56:46
User: pykler
Functions: python tail

Realtime lines per second in a log file using python ... identical to perl version, except python is much better :)

cat ~/.ssh/id_rsa.pub | ssh [email protected] "mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys; chmod 600 ~/.ssh/authorized_keys"
2012-07-18 04:41:55
Functions: cat ssh

chmod authorized_keys so you don't get "Authentication refused: bad ownership or modes for file /home/user/.ssh/authorized_keys"

plink -agent gist.github.com
nc -l $PORT | pv -b > archive.tar.bz2
2012-11-13 16:47:45
Tags: netcat tar pv

Receives bzip'd tar archive via netcat (openbsd nc) and stores locally. Displays size with pv. Start this receiver first, then the sender.

find $(YourPATH) -type f -exec dos2unix '{}' \;
make --print-data-base --dry-run | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}'
dsquery group -samid "Group_SAM_Account_Name" | dsget group -members -expand
ping -c 3 google.com
sudo mount -o remount,rw /
2016-02-07 17:57:19
User: bugmenot
Functions: mount sudo

Warning this will allow you to write to the system image on the phone, not recommended. But sometimes useful.

Print everything after last slash
2016-08-17 07:10:33
User: qdrizh
Functions: last
Tags: sed

FQPN - Path = Filename

pmset -g batt | awk '/^ /{print $5}'
gethostip -x
iozone -s 2g -r 64 -i 0 -i 1 -t 1
2009-11-19 10:43:54
User: w00binda

Iozone with a file of 2GB, 64KB record size, write/rewrite and read/re-read test, using just one thread.

find . -type f -not -regex ".*\/.svn\/.*" -exec sed -i 's/oldstring/newstring/g' {} +
grep -UIlr "^M" *
2010-08-20 21:16:34
User: randy909
Functions: grep

Where ^M is entered by ctrl-v-m (v then m). Especially useful on cygwin when checking into a version control system. If you're not using all cygwin tools (e.g. strawberry perl instead of cygwin perl) you'll find yourself dealing with this constantly.

-U tells grep to process the file as binary; it needs this to work

-I ignores binary files so you won't get false positives

-l only prints the filename instead of the offending lines

-r recursive

ls /var/log/ |wc -l
http_proxy=<proxy.server:port> wget <url>
2011-03-30 13:06:19
User: rdc
Functions: wget

On a machine behind a firewall, it's possible to pass the proxy server address in as a prefix to wget to avoid having to set it as an environment variable first.

perl -e "binmode(STDOUT, ':utf8'); print \"$@\""; echo # newline
2012-01-02 10:34:51
User: mathias
Functions: echo perl

This is especially useful to get crazy stuff like space characters copied to your pasteboard correctly.

Source: https://github.com/mathiasbynens/dotfiles/blob/master/.functions

sayspeed() { for i in $(seq 1 `echo "$1"|wc -c`); do echo -n "`echo $1 |cut -c ${i}`"; sleep 0.1s; done; echo "";}
2012-02-11 05:51:42
User: kundan
Functions: echo seq sleep wc

change the time that you would like to have as print interval

and just use it to say whatever you want to

pdftk 1.pdf 2.pdf cat output 12.pdf
git checkout HEAD~2 -- /path/to/dir
scrot -d 3 '/tmp/%Y-%m-%d_$wx$h.png' -e 'cat $f'|curl -F "image=@-" -F "key=1913b4ac473c692372d108209958fd15" http://api.imgur.com/2/upload.xml|grep -Eo "<original>(.)*</original>" | grep -Eo "http://i.imgur.com/[^<]*"
2012-11-13 21:16:09
User: dzup
Functions: grep

That its my personal key that i dont use, if you want yours, go to imgur and get it, or use that one