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,394 results
php -r 'echo strtotime("2009/02/13 15:31:30")."\n";'
2009-03-24 19:38:46
User: sudopeople

Most people know that you can run a PHP script from the command line like so:

php ./my_script.php

But sometimes I just want to run a quick bit of code, the PHP Command Line Interface allows me to do so with the -r option.

Requires package php5-cli

rpm -Va | grep -v "\.\.\.\.\.\.\.T"
cat -v -t -e
2009-03-24 19:29:03
User: alperyilmaz
Functions: cat
Tags: cat

Useful to detect number of tabs in an empty line, DOS newline (carriage return + newline).

A tool that can help you understand why your parsing is not working.

man -t man | lp
2009-03-24 19:08:07
User: icco
Functions: man
Tags: printing

man -t manpagename gives a postscript version of said man page. You then pipe it to ls, and assuming you have cups set up, it prints in your default printer.

echo -e "[client]\nuser = YOURUSERNAME\npassword = YOURPASSWORD" > ~/.my.cnf
2009-03-24 19:05:39
User: alperyilmaz
Functions: echo
Tags: mysql bash

The file .my.cnf located at user's home directory is used for mysql login. If this file exists, then


can be replaced with

mysql database -e 'SOME SQL COMMAND'

It saves you from typing!

This is valid for mysqladmin and mysqldump commands as well.

/usr/sbin/arp -i eth0 | awk '{print $3}' | sed 1d
date -d "@$(find dir -type f -printf '%C@\n' | sort -n | sed -n "$(($(find dir -type f | wc -l)/2))p")" +%F
2009-03-24 18:48:49
User: allengarvin
Functions: date dir find wc

I needed to get a feel for how "old" different websites were, based on their directories.

vimdiff foo.c <(bzr cat -r revno:-2 foo.c)
gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=test.pdf multipageproject.pdf
2009-03-24 17:14:46
User: iain
Functions: gs

Xsane produces PDFs that are too large - particularly multipage PDFs. This command compresses them. If you do not use A4, remove the -sPAPERSIZE flag.

tar -czf - * | ssh example.com "cat > files.tar.gz"
2009-03-24 17:02:02
User: migurski
Functions: ssh tar

I recently found myself with a filesystem I couldn't write to and a bunch of files I had to get the hell out of dodge, preferably not one at a time. This command makes it possible to pack a bunch of files into a single archive and write it to a remote server.

host google.com
2009-03-24 16:25:12
User: tommaso
Functions: host

host is a simple utility for performing DNS lookups. It is normally used to convert names to IP addresses and vice versa. When no arguments or options are given, host prints a short summary of its command line arguments and options.

2009-03-24 16:19:12
User: haivu
Functions: bc

bc is a wonderful calculator. Just type bc at the command line and have at it. Ctrl+D (or type quit) will get you out. This usage is just scratching the surface: bc can handle a mini scripting language, complete with variable, statements, loop, conditional statements and more. Do a man page on it to find out.

2009-03-24 16:03:28
User: haivu

Short and sweet command. This command is also useful for other information such as what IP address a particular user logged in from, how long had they been logged in, what shell do they use.

find . -regex "[^.]*" -depth -empty -type d -mtime +1 -exec rmdir -v {} \;
rdate -s time-A.timefreq.bldrdoc.gov
bvi [binary-file]
2009-03-24 15:30:50
User: haivu
Tags: edit

bvi is your vi for binary editing. If your system does not have it, you can get it from


find / -nouser -o -nogroup -print
perl -e 'print "Hello World!", "\n";'
for dir in $(ls); do du -sk ${dir}; done
2009-03-24 13:42:55
User: morlockhq_
Functions: dir du

Sometimes you want to know the summary of the sizes of directories without seeing the details in their subdirectories. Especially if it is going to just scroll off the screen. This one liner summarizes the disk usage of any number of directories in a directory without giving all the details of whats happening underneath.

find -iname '*.flac' | sed 's:/[^/]*$::' | uniq
2009-03-24 13:26:31
User: ar
Functions: find sed

Run this in your music folder, or give the path directly after "find".

The sed pattern filters away the basename.

xvidcap --file filename.mpeg --fps 15 --cap_geometry 1680x1050+0+0 --rescale 25 --time 200.0 --start_no 0 --continue yes --gui no --auto
2009-03-24 08:49:15
User: tristan_ph
Functions: yes
Tags: xvidcap compiz

That will capture 200 seconds of video at fullscreen 1680x1050 resolution, but scaled down 25 percent, with 15 frames per second.


cat schema.sql data.sql test_data.sql | mysql -u user --password=pass dbname
2009-03-24 08:39:40
User: tristan_ph
Functions: cat
Tags: mysql cat

Be aware of using the --password argument as it will appear your password in plain text on the screen. You may use -p argument instead, it will prompt you to enter you password in hidden mode.

curl http://domain.com/file.tar.gz | tar zx
for i in $(pgrep -v -u root);do kill -9 $i;done
2009-03-24 02:54:52
User: lostnhell
Functions: kill


grep -- displays process ids

-v -- negates the matching, displays all but what is specified in the other options

-u -- specifies the user to display, or in this case negate

The process loops through all PIDs that are found by pgrep, then orders a forced kill to the processes in numerical order, effectively killing the parent processes first including the shells in use which will force the users to logout.

Tested on Slackware Linux 12.2 and Slackware-current

for f in `jot - 0 50 5` ; do ping -c 1 -m 50 10.0.2.$f ; done
2009-03-23 23:51:18
User: chinkshady
Functions: ping

Say you need to ping every 5th IP address on your network .. this will give you a way of doing that.

jot can also do counting ... like

jot 4





download from http://oreilly.com/catalog/upt2/examples/#jot or fins athena-jot in rpm format