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,380 results
nmap -sP | awk "/^Host/"'{ print $3 }' |nawk -F'[()]' '{print $2}'
2011-12-31 15:50:22
User: cantormath
Functions: awk

Often you want to nmap a list of IPs using the -iL flag. This is an easy way to generate a list of IPs that are online in a specific subnet or IP range (

sed -i -e '1i \# -*- coding: utf-8 -*-' yourfile.py
2012-05-15 14:54:06
User: igniteflow
Functions: sed

Useful when specifying char encoding for Python and/or your editor

ip a s eth0 | awk '/inet / {print $2} | sed -e 's/\/..//g'
mplayer $(find . -iname '*.avi' | shuf -n1)
lp -dhp -P1-1 -o media=a4 *
2013-07-26 00:09:56
User: alphabraga
Functions: lp

Very usefull script to use when uoy must print all files from a directory.

for file in "$@"; do name=$(basename "$file" .webm) echo ffmpeg -i $file -vn -c:a copy $name.ogg ffmpeg -i "$file" -vn -c:a copy "$name.ogg" done
2013-10-05 14:49:07
User: hoodie
Functions: basename echo file

Strips the audio track from a webm video. Use this in combination with clive or youtube-dl.

watch -n1 iptables -vnL
jhead -autorot -ta+1 *
rpm -ivh 'http://www.website.com/path/to/desired_software_package.rpm'
ioreg -l -p IODeviceTree | grep -o EFI[0-9]. && system_profiler SPSoftwareDataType |grep 64
perl -le 'print join $/, @INC'
2009-09-22 22:18:35
User: chuckr
Functions: join perl

This will show where your Perl installation is looking for modules.

echo start > battery.txt; watch -n 60 'date >> battery.txt'
2009-10-18 07:00:26
User: m33600
Functions: echo watch

Fully recharge your computer battery and start this script.

It will create or clean the file named battery.txt, print a start on it and every minute it will append a time stamp to it.

Batteries last few hours, and each hour will have 60 lines of time stamping. Really good for assuring the system was tested in real life with no surprises.

The last time stamp inside the battery.txt file is of interest. It is the time the computer went off, as the battery was dead!

Turn on your computer after that, on AC power of course, and open battery.txt. Read the first and last time stamps and now you really know if you can trust your computer sensors.

If you want a simple line of text inside the battery.txt file, use this:

watch -n 60 'date > battery.txt'

The time of death will be printed inside

purple-remote "setstatus?status=Available&message=Checking libpurple"
xmms2 info $(xmms2 mlib search '<query>' | sed -ne 's/^00*\([1-9][0-9]*\).*$/\1/p') | awk -F' = ' '$1~/ url$/{print$2}'
pkill -f <process name>
2010-06-19 02:36:31
User: eikenberry
Tags: kill ps killall

Using -f treats the process name as a pattern so you don't have to include the full path in the command. Thus 'pkill -f firefox' works, even with iceweasel.

cd $(find -inum inode_no)
2010-09-25 06:04:32
User: emacs
Functions: cd find

First use ls -i to list files and directories with their inode number

Then if you want to change to one of the directories, replace inode_no with its inode then execute the command

sed -i '$a\FOOBAR' *
tag() { local t="$HOME/tags/$1"; [ -d $t ] || mkdir -p $t; shift; local i; for i in $*; do ln -s $(readlink -f $i) $t;done}
2012-02-10 15:43:02
Functions: ln mkdir readlink

shell function which allows you to tag files by creating symbolic links directories in a 'tags' folder.

The tag function takes a tag name as its first argument, then a list of files which take that tag. The directory $HOME/tags/tagname will then hold symbolic links to each of the tagged files. This function was modified from bartonski's (http://www.commandlinefu.com/commands/view/10216) inspired by tmsu (found at https://bitbucket.org/oniony/tmsu/wiki/Home) with readlink function by flxndn (http://www.commandlinefu.com/commands/view/10222).


tag dog airedale.txt .shizturc weimeraner.pl

This will create $HOME/tags/dog which contains symbolic links to airedale.txt .shizturc and weimeraner.pl

pdftk file.pdf dump_data output | grep -i Num
ip a s eth0 | awk -F"[/ ]+" '/inet / {print $3}'
watch -n1 iptables -vnL
fortune | cowsay -f sodomized-sheep
svn st | grep ^\? | awk '{print $2}' | xargs svn add
^[c (ctrl-v esc-c)
2009-03-18 15:15:24
User: angrox

Resets a scrambled terminal into its orignal state.

cat file | tee >> file
2009-07-30 07:34:03
User: GeckoDH
Functions: cat file tee

The command `cat file >> file` failes with the following error message:

cat: file: input file is output file

`tee` is a nice workaround without using any temporary files.