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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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,418 results
curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g'
html2text http://checkip.dyndns.org | grep -i 'Current IP Address:'|cut -d' ' -f4
2009-08-06 11:30:32
User: adonis28850
Functions: cut grep

The same as the other user, but smarter, using -d and -f

ulimit -s 64
2009-08-06 10:40:25
User: ioggstream
Functions: ulimit
Tags: Linux ulimit

default stack size is 10M. This makes your multithread app filling rapidly your memory.

on my PC I was able to create only 300thread with default stack size.

Lower the default stack size to the one effectively used by your threads, let you create more.

ex. putting 64k I was able to create more than 10.000threads.

Obviously ...your thread shouldn't need more than 64k ram!!!

ldapmodify -Y "dn:uid=rob,dc=example.com" -g -R -J 2.16.840.1.113730.3.4.16 ...
html2text http://checkip.dyndns.org | grep -i 'Current IP Address:'|cut -c21-36
curl -u yourusername:yourpassword -d status=?Your Message Here? https://twitter.com/statuses/update.xml
schedtool 1
2009-08-06 08:42:03

Display information about the cores.

* sudo apt-get install schedtool

mencoder "mf://frame_*.bmp" -mf w=720:h=480:fps=30:type=bmp -ovc lavc -lavcopts vcodec=mpeg4 -o number_video.mp4
2009-08-06 06:59:49

Converts the batch of images to video.

*mencoder* required.

sudo cat /usr/share/icons/*/*/* > /dev/dsp
2009-08-06 03:12:27
User: 12345678
Functions: cat sudo

Plays the sound of the file, should sound like *some* kind of music, most files sound like static but some are really cool.


sudo cat /dev/sda > /dev/dsp sudo cat /dev/sda5 | aplay

Check out http://bbs.archlinux.org/viewtopic.php?id=70937 for more variations!

semi-dupe--like http://www.commandlinefu.com/commands/view/985/generate-white-noise but with different syntax and program.

sed "s:/old/direcory/:/new/directory/:" <file>
2009-08-06 00:37:45
Functions: sed
Tags: sed

Having to escape forwardslashes when using sed can be a pain. However, it's possible to instead of using / as the separator to use : .

I found this by trying to substitute $PWD into my pattern, like so

sed "s/~.*/$PWD/" file.txt

Of course, $PWD will expand to a character string that begins with a / , which will make sed spit out an error such as "sed: -e expression #1, char 8: unknown option to `s'".

So simply changing it to

sed "s:~.*:$PWD:" file.txt

did the trick.

find . -type f -print0 | xargs -0 -P 4 -n 40 grep -i foobar
2009-08-05 23:18:44
User: ketil
Functions: find grep xargs

xargs -P N spawns up to N worker processes. -n 40 means each grep command gets up to 40 file names each on the command line.

echo "Body goes here" | mutt -s "A subject" -a /path/to/file.tar.gz [email protected]
2009-08-05 23:06:25
User: ketil
Functions: echo

This command uses mutt to send the mail. You must pipe in a body, otherwise mutt will prompt you for some stuff. If you don't have mutt, it should be dead easy to install.

make -j 4
2009-08-05 22:50:57
User: kovan
Functions: make

Force make command to create as many compile processes as specified (4 in the example), so that each one goes into one core or CPU and compilation happens in parallel. This reduces the time required to compile a program by up to a half in the case of CPUs with 2 cores, one fourth in the case of quad cores... and so on.

colormake, colorgcc, colordiff
2009-08-05 22:40:11
User: kovan

Colorize output of make, gcc/g++ or diff, making it easier to read at a glance.

They are not distributed with make, diff or gcc, but are usually available in the repositories.

grep -Eho '<[a-ZA-Z_][a-zA-Z0-9_-:]*' * | sort -u | cut -c2-
2009-08-05 21:54:29
User: inkel
Functions: cut grep sort
Tags: sort grep cut xml

This one will work a little better, the regular expressions it is not 100% accurate for XML parsing but it will suffice any XML valid document for sure.

<ctrl+j>stty sane<ctrl+j>
2009-08-05 21:50:07
User: CharlieInCO

This is more or less the same as 'reset', but with two advantages: the initial LF character makes sure you're starting a new line to the tty driver, the final one is more reliably a line-end as CR is often unset; and second, 'stty sane' is reliable on older UNIX systems, especially Berkeley-based ones.

echo <ctrl-v><esc>c<enter>
2009-08-05 18:32:28
User: kcm
Functions: echo

This works in some situations where 'reset' and the other alternatives don't.

for file in *.mp3;do mkdir -p "$(mp3info -p "%a/%l" "$file")" && ln -s "$file" "$(mp3info -p "%a/%l/%t.mp3" "$file")";done
2009-08-05 17:04:34
User: matthewbauer
Functions: file ln mkdir

This will mv all your mp3 files in the current directory to $ARTIST/$ALBUM/$NAME.mp3

Make sure not to use sudo - as some weird things can happen if the mp3 file doesn't have id3 tags.

cat /etc/debian_version
2009-08-05 14:47:05
User: caiosba
Functions: cat

Easy way to find out what Debian version your machine is running

find . -name "*.gz" | xargs -n 1 -I {} bash -c "gunzip -c {} | sort | gzip -c --best > {}.new ; rm {} ; mv {}.new {}"
2009-08-05 14:16:15
User: kennethjor
Functions: bash find xargs

I used this because I needed to sort the content of a bunch of gzipped log files. Replace sort with something else, or simply remove sort to just rezip everything

find . -depth -type d -empty -exec rmdir -v {} +
2009-08-05 13:48:13
User: syssyphus
Functions: find rmdir
Tags: find

this will show the names of the deleted directories, and will delete directories that only no files, only empty directories.

cat file-that-failed-to-download.zip | curl -C - http://www.somewhere.com/file-I-want-to-download.zip >successfully-downloaded.zip
2009-08-05 13:33:06
Functions: cat

If you are downloading a big file (or even a small one) and the connection breaks or times out, use this command in order to RESUME the download where it failed, instead of having to start downloading from the beginning. This is a real win for downloading debian ISO images over a buggy DSL modem.

Take the partially downloaded file and cat it into the STDIN of curl, as shown. Then use the "-C -" option followed by the URL of the file you were originally downloading.

grep -r . /sys/class/net/eth0/statistics
2009-08-05 08:20:39
User: olorin
Functions: grep
Tags: Linux

Within /proc and /sys there are a lot of subdirectories, which carry pseudofiles with only one value as content. Instead of cat-ing all single files (which takes quite a time) or do a "cat *" (which makes it hard to find the filename/content relation), just grep recursively for . or use "grep . /blabla/*" (star instead of -r flag).

For better readability you might also want to pipe the output to "column -t -s : ".

indent -linux helloworld.c
2009-08-05 07:53:08
User: freestyler
Tags: indent

put "-linux" option into $HOME/.indent.pro to make it default