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,413 results
df -h
2009-07-08 11:25:28
User: Paaskehare
Functions: df

Bulit-in function in linux, so should work on any linux distribution.

for f in $(find * -maxdepth 0 -type f); do file=$(find ~/target -name $f); if [ -n "$file" ]; then cp $file ${file}.bak; mv $f $file; fi; done
2009-07-08 10:18:06
User: sanmiguel
Functions: cp find mv

You could start this one with

for f in *; do

BUT using the find with "-type f" ensures you only get files not any dirs you might have

It'll also create backups of the files it's overwriting

Of course, this assumes that you don't have any files with duplicated filenames in your target structure

unzip -lt foo.zip | grep testing | awk '{print $2}' | xargs rm -r
l=500; x=500; y=200; d=-15;for i in `seq $x $d $y`; do beep -l $l -f $i;done
2009-07-07 22:12:20
Tags: bash beep sound

Generates a frequency sweep from $x to $y, with $d numbers inbetween each step, and with each tone lasting $l milliseconds.

test `uname` = Linux && lsb_release -a || ( test `uname` = SunOS && cat /etc/release || uname -rms )
2009-07-07 20:51:30
User: virtualshock
Functions: cat test uname

Found in comments section works on most Linux flavors.

vmrun list
2009-07-07 12:13:50

Shows a list of running virtual machines on a vmware host (workstation/server/esx/etc.)

Again, this command is vmware-specific.

There are also other things you can do with `vmrun`. Just simply type vmrun by itself (no arguments) to get a readout of other things you can do with it.

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