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,419 results
dpkg-query -l| grep -v "ii " | grep "rc " | awk '{print $2" "}' | tr -d "\n" | xargs aptitude purge -y
2009-04-28 19:25:53
User: thepicard
Functions: awk grep tr xargs

This will, for an application that has already been removed but had its configuration left behind, purge that configuration from the system. To test it out first, you can remove the last -y, and it will show you what it will purge without actually doing it. I mean it never hurts to check first, "just in case." ;)

vim ~/.purple/pounces.xml
2009-04-28 19:11:39
Functions: vim
Tags: vim pidgin

So you keep getting buzzes sounding from pidgin but you can't remember which buddy pounce is causing the beep. Well, cat/edit the ~/.purple/pounces and find out!

ls | sed -n -r 's/banana_(.*)_([0-9]*).asc/mv & banana_\2_\1.asc/gp' | sh
2009-04-28 17:53:58
User: log0
Functions: ls sed
Tags: sed mv rename

A powerfull way to rename file using sed groups.

& stand for the matched expression.

\1 referes to the first group between parenthesis. \2 to the second.

screen -d -m [<command>]
2009-04-28 12:35:25
User: cammarin
Functions: screen
Tags: screen

Start screen in detached mode, i.e., already running on background. The command is optional, but what is the purpose on start a blank screen process that way?

It's useful when invoking from a script (I manage to run many wget downloads in parallel, for example).

rm ~/.mozilla/firefox/<profile_dir>/.parentlock
2009-04-28 12:15:58
User: cammarin
Functions: rm
Tags: firefox rm

Sometimes Firefox crashes or is bad finished and the message the process is still running appear while it's not. This also works when you sharing account from a NIS server and try to open the browser on multiple computers.

lshw -C display
2009-04-28 11:49:08
User: gwir

Use the lshw command to display information about your video card. Give more ouput when run as root.

sudo aptitude purge `dpkg --get-selections | grep deinstall | awk '{print $1}'`
alias dfr='df;free'
2009-04-28 11:30:31
User: ximo88
Functions: alias

A short way to give us relevant report in a moment done about quantities on disk usage, memory and swap in our Linux Systems.

alias h='history'
2009-04-28 11:20:03
User: ximo88
Functions: alias

typing history it's a long way but typing only h it's my way it works in whatever distro or OSes or shells that you use, you know, only for easyness :)

sudo apt-get remove --purge `dpkg -l | awk '{print $2}' | grep gnome` && apt-get autoremove
2009-04-28 10:34:42
User: kelevra
Functions: awk grep sudo
Tags: awk apt-get dpkg

Useful for removes a package and its depends, for example to remove the gnome desktop environment, also configuration files will be removed, you should be carefully and sure that you want to do this.

lspci |grep VGA
2009-04-28 08:34:42
User: CafeNinja
Functions: grep lspci
Tags: video Ubuntu

Displays only the VGA adapter/chipset being used for the graphics. In this case, it gave me the "M22" and "Mobility Radeon x300" that I needed to research a graphics issue I was having.

ifconfig en1 | awk '/inet / {print $2}' | mail -s "hello world" [email protected]
2009-04-28 06:01:52
User: rez0r
Functions: awk ifconfig mail

This is useful if you have need to do port forwarding and your router doesn't assign static IPs, you can add it to a script in a cron job that checks if you IP as recently changed or with a trigger script.

This was tested on Mac OSX.

date -d '2 weeks ago'
2009-04-28 03:09:23
User: Buzzcp
Functions: date

Use date to find the date at other days and times.

ls -S -lhr
2009-04-28 01:28:57
User: rez0r
Functions: ls

This command list and sort files by size and in reverse order, the reverse order is very helpful when you have a very long list and wish to have the biggest files at the bottom so you don't have scrool up.

The file size info is in human readable output, so ex. 1K..234M...3G

Tested with Linux (Red Hat Enterprise Edition)

netstat -an | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i < $1; i++) {printf("*")}; print "" }'
2009-04-27 22:02:19
User: knassery
Functions: awk grep netstat sort uniq

Written for linux, the real example is how to produce ascii text graphs based on a numeric value (anything where uniq -c is useful is a good candidate).

history -d
2009-04-27 20:19:09
User: sud0er
Tags: bash

If you're a moron like me, sometimes your fingers get away from you and you, for example, enter your password when you're already authenticated to ssh-agent, sudo, etc., and your password ends up in shell history. Here's how to get it out.

svn log $url -r $revision -v | egrep " [RAMD] \/" | sed s/^.....//
2009-04-27 19:50:06
User: nitehawk
Functions: egrep sed

url can be a working copy or url to a svn repository, revision is any valid revision number for that branch.

inkscape -f file.svg --verb=org.inkscape.color.grayscale --verb=FileSave --verb=FileClose
2009-04-27 18:59:31
User: prayer
Tags: inkscape

It requires inkscape 0.46 and lxml packages

curl --form username=from_twitter --form password=from_twitter --form media=@/path/to/image --form-string "message=tweet" http://twitpic.com/api/uploadAndPost
gpsbabel -D 0 -i geo -f "/path/to/.loc" -o garmin -F usb:
2009-04-27 15:46:37
User: baergaj
Tags: gps gpsbabel

gps data from geocaching.com is provided for free in .loc format.

mplayer -framedrop -vfm ffmpeg -lavdopts lowres=1:fast:skiploopfilter=all
2009-04-27 15:40:55
User: baergaj
Tags: video mplayer

Certain codecs in high res don't play so well on my Dell Mini 9. Using this command, I can play just about anything and it keeps the sound in sync to boot!

grep -i --color=auto
2009-04-27 15:03:28
User: P17
Functions: grep

Highlights the search pattern in red.

echo "Hello world" | base64
2009-04-27 15:00:08
User: P17
Functions: echo
Tags: encoding

Also works with files:

cat file

Hello world

base64 file


To decrypt use the -d option:

echo SGVsbG8gd29ybGQK | base64 -d

Hello world

cobbler check
2009-04-27 10:28:29
User: w00binda

A script that checks if your environment is correctly configured for using cobbler.