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.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

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.


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:



2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.




All commands from sorted by
Terminal - All commands - 11,492 results
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.

cobbler repo add --name=CentOS-5.3-i386-updates --mirror=http://mirror3.mirror.garr.it/mirrors/CentOS/5.3/updates/i386/
2009-04-27 10:18:45
User: w00binda
Tags: cobbler

Add a repo to cobbler. To download all the repository contents the command is:

cobbler reposync
lam -f 1.4 myfile
2009-04-26 19:31:22

Lam is a command available on Bsd (I've tested it on OpenBSD).Is useful for laminate a file line by line. The -f option set the field width ( -f min.max ).

curl -f -O http://pcbsd.fastbull.org/7.0.2/i386/PCBSD7.0.2-x86-DVD.iso
2009-04-26 07:23:31
User: battavia
Tags: curl

download a specific file with -f to not display errors and -O to write output to a file named as the remote file.

for i in `screen -ls | perl -ne'if(/^\s+\d+\.([^\s]+)/){print $1, " "}'`; do gnome-terminal -e "screen -x $i"; done
2009-04-25 22:39:24
User: hank
Functions: perl
Tags: screen Linux perl

There was another line that was dependent on having un-named screen sessions. This just wouldn't do. This one works no matter what the name is. A possible improvement would be removing the perl dependence, but that doesn't effect me.

for img in $( ls *.CR2 ); do convert $img $img.jpg; done
for i in /sys/class/net/*; do e=`basename $i`; echo "# $e"; sudo ethtool $e | grep -E "Link|Speed" ; done
2009-04-25 14:32:08
User: hank
Functions: echo grep sudo
Tags: Network Linux

Basically an improvement on an earlier ethtool command line.

lsof -i
mkdir $(date +%Y%m%d)
2009-04-25 14:16:45
User: thebodzio
Functions: date mkdir
Tags: alias date mkdir

Not a discovery but a useful one nontheless.

In the above example date format is 'yyyymmdd'. For other possible formats see 'man date'.

This command can be also very convenient when aliased to some meaningful name:

alias mkdd='mkdir $(date +%Y%m%d)'
lndir sourcedir destdir
2009-04-24 18:30:29

Lndir create from source directory to destination directory a full symlink tree of all contents of source directory, really useful for propagate changes from a directory to another.

look mysql /etc/group
2009-04-24 18:20:20
Functions: look

Look search for lines in a file that beginning with a given string.

Same as $ grep ^n /etc/passwd

echo "A great password" | md5sum
2009-04-24 14:32:56
User: ubersoldat
Functions: echo

You can also use sha1sum and variants for longer passwords

/usr/local/bin/OFPW -mode 1
/usr/local/bin/OFPW -pass thepassword
hwinfo --block --short
2009-04-24 11:13:31

Yields entries in the form of "/dev/hda1" etc.

Use this if you are on a new system and don't know how the storage hardware (ide, sata, scsi, usb - with ever changing descriptors) is connected and which partitions are available.

Far better than using "fdisk -l" on guessed device descriptors.

for i in `ls *xml`; do sed -e 's,oldpassword,newpassword,g' $i > $i.2 && mv -f $i.2 $i ; done
sed 's/\o0/\n/g' /proc/INSERT_PID_HERE/environ