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,360 results
vmrun start /path/to/virtual_machine.vmx nogui
2009-07-07 12:11:45

There is no output from this command. The command boots a virtual machine and you will have to wait for the boot sequence to complete before you can ping or connect to the virtual machine via ssh/rdp/vnc/nx/etc.

mount -t vfat /dev/sdx1 /media/psp/
cp texfile.toc texfile.toc.bak; latex texfile.tex; cmp -s texfile.toc texfile.toc.bak; if [ $? -ne 0 ]; then latex texfile.tex; fi
2009-07-07 07:09:45
User: gwiener
Functions: cmp cp

To check if the table-of-content in a LaTeX document is up-to-date, copy it to a backup before running LaTeX and compare the new .toc to the backup. If they are identical, it is updated. If not, you need to run LaTeX again.

egrep "(There were undefined references|Rerun to get (cross-references|the bars) right)" texfile.log
2009-07-07 06:48:03
User: gwiener
Functions: egrep
Tags: latex

LaTeX is not a smart compiler - You need to run it several times to make it back-patch all the missing refs. The message if to do so or not is buried in its endless output and the log file. This grep lines helps to find it.

< <infile> tr ' \t' '\n' | tr -s '\n' > <outfile>
2009-07-07 01:17:47
User: qubyte
Functions: tr
Tags: shell tr

Puts words on new lines, removing additional newlines.

tar -tf <file.tar.gz> | xargs rm -r
tr ' \t' '\n' <INFILE >OUTFILE
2009-07-06 21:24:44
User: CharlieInCO
Functions: tr
Tags: shell

Simply translates whitespace to newlines. Could be enhanced to compress out extra newlines, but that might be better handled in the next tool down the pipe, with eg uniq(1).

for i in $(tar -tf <file.tar.gz>); do rm $i; done;
2009-07-06 19:57:23
User: din7
Functions: rm tar

Remove annoying improperly packaged files that untar into the incorrect directory.

Example, When you untar and it extracts hundreds of files into the current directory.... bleh.

# dd if=/dev/sda | gzip -c | ssh [email protected] 'dd of=/mnt/backups/sda.dd'
awk '{c=split($0, s); for(n=1; n<=c; ++n) print s[n] }' INPUT_FILE > OUTPUT_FILE
2009-07-06 06:10:21
User: agony
Functions: awk
Tags: awk

Basically it creates a typical word list file from any normal text.

ruby -e " 3.times { system 'pdflatex mydoc.tex' } "
2009-07-05 09:55:59

When I make a latex document, I need to compile three times for generate an updated index of contents. With ruby on command line, I run this operation with a fast one liner.

curl -n -d status='Hello from cli' https://twitter.com/statuses/update.xml
2009-07-05 09:39:37
User: svg
Tags: twitter

Update twitter from commandline, without revealing your password and without having to type it interactively.

You 'll need to put a line "machine twitter.com login TWITTERUSER password TWITTERPASS" in $HOME/.netrc and better chmod 600 that file.

man -Tps ls >> ls_manpage.ps && ps2pdf ls_manpage.ps
2009-07-05 09:31:36
User: 0x2142
Functions: ls man
Tags: man pdf

Creates a PDF (over ps as intermediate format) out of any given manpage.

Other useful arguments for the -T switch are dvi, utf8 or latin1.

find / -type f -size +1000000000c
echo alias grep=\'grep --color=auto\' >> ~/.bashrc ; . ~/.bashrc
2009-07-05 07:44:13
User: 0x2142
Functions: alias echo
Tags: color grep

This will create a permanent alias to colorize the search pattern in your grep output

rsync -rtvu --modify-window=1 --progress /media/SOURCE/ /media/TARGET/
2009-07-05 07:40:10
User: 0x2142
Functions: rsync
Tags: backup rsync

This will backup the _contents_ of /media/SOURCE to /media/TARGET where TARGET is formatted with ntfs. The --modify-window lets rsync ignore the less accurate timestamps of NTFS.

echo 2+3 |bc
2009-07-04 22:03:41
User: Kaio
Functions: echo

Handy use of bc in the command line. No need to get 'into' the bc to perform calculations

FEATURES=keepwork emerge --resume
2009-07-04 21:09:27

For Gentoo:

If you do not use this command, portage will fetch the source again, and rebuild the hole application from the top.

This command make portage keep all files that ar allready built

pg_dump otrs2 | gzip > dump.gz
ps awwfux | less -S
2009-07-04 09:39:28
User: ToyKeeper
Functions: less ps

If you want a visual representation of the parent/child relationships between processes, this is one easy way to do it. It's useful in debugging collections of shell scripts, because it provides something like a call traceback.

When a shell script breaks, just remember "awwfux".

/usr/proc/bin/pfiles $PID | egrep "sockname|port"
pkgchk -l -p <full path to the file>
2009-07-04 08:22:11
User: sengork
Tags: solaris

Find which package a file belongs to on Solaris along with it's packaging system metadata.

cat /var/log/auth.log | logtool -o HTML > auth.html
2009-07-03 18:17:22
Functions: cat

Logtool is a nice tool that can export log file to various format, but its strength lies in the capacity of colorize logs. This command take a log as input and colorize it, then export it to an html file for a more confortable view. Logtool is part of logtool package.Tested on Debian.

vim -c new myfile
2009-07-03 17:54:43
Functions: vim

: new command allow to split a Vim screen in two separate windows. Each window can handle its own buffer.

Passing the -c new options when Vim start cause to split screen automatically.

nload -u m eth0
2009-07-03 17:47:38

Nload is part of nload package, tested under Debian. Nload display network bandwidth statistics, -u m options stands for MBit unit measure.