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,585 results
alias sshdo='ssh -q -t root@localhost -- cd $PWD \&\& sudo'
2010-10-20 22:33:22
User: darkfader
Functions: alias cd
Tags: sudo su ssh-agent

Run program as root by SSH key forwarding instead of sudoers.

Put this alias line in .bashrc or wherever you like. Alias arguments might need extra escaping.

You might wonder about security. But you'd block out root login as much as possible of course. In sshd_config you put this:

PermitRootLogin no

Match Address

  PermitRootLogin without-password

xinit $(which awesome) -- /usr/bin/Xephyr :5 -once -fullscreen -ac -keybd "ephyr,,,xkbmodel=pc105,xkblayout=it,xkbrules=evdev,xkboption="
2012-11-03 00:54:33
User: hute37
Functions: which
Tags: awesome


xinit $(which gnome-awesome-session)

with cat /usr/local/bin/gnome-awesome-session:


exec gnome-session --session awesome "$@"

following: http://awesome.naquadah.org/wiki/Quickly_Setting_up_Awesome_with_Gnome

note: in ubuntu 12.10 a probable Xephyr recent bug rejects keybd option ...

mplayer -shuffle $HOME/music/* $HOME/Dropbox/Music/*/* $HOME/Dropbox/Music/*/*/* etc. >> /dev/null 2>&1
for f in *.png; do convert $f -resize 852x480 $f; done
2013-12-15 11:28:07
User: egeoffray

Resize all png in the current folder.

Warning: no copy. Make sure you have a copy of the originals

10,30,50 * * * * ping -q -c1 -w3 | grep '1 received' - || env DISPLAY=:0 xeyes
2012-02-06 09:40:11
User: knoppix5
Functions: env grep ping
Tags: ping host crontab

Every 20 minutes ping host with IP address If it's not 'alive' or not reachable, then display something eye-catching (here xeyes) on the desktop.

Hint for newbies: edit crontab with

crontab -e
./poweriso extract $USER/file.daa / -od $USER/file_extracted
2009-02-15 23:19:40
User: brettalton

.daa is a non-standard disk image format that can not be read by any other program. This is how you can extract the files though.

PowerISO binary for Linux: http://www.poweriso.com/poweriso-1.3.tar.gz

"This is a free utility for linux which can extract, list, and convert image files (including ISO, BIN, DAA, and other formats). Type " poweriso -? " for detailed usage information. File Size: 278KB"

clamscan -ir --bell ~user/
2009-05-21 13:09:31

Scan for viruses, recursively and print only infected files, with bell sound. Clamscan is part of clamav package. Tested on Debian.

wget -qO - http://cfaj.freeshell.org/ipaddr.cgi
curl http://whatismyip.org
ls . | xargs file | grep text | sed "s/\(.*\):.*/\1/" | xargs gedit
for i in 192.168.1.{1..254} ; do if ping -c1 -w1 $i &>/dev/null; then echo $i alive; fi; done
git last commit on a file.
tar -cf - /etc | tar -xf - -C </destination/folder>
sudo sync && sudo echo 3 | sudo tee /proc/sys/vm/drop_caches
2012-03-17 08:27:58
User: StephenJudge
Functions: echo sudo sync tee
Tags: memory cache

"That's it. Not much to see here. The first command writes any cache data that hasn't been written to the disk out to the disk. The second command tells the kernel to drop what's cached. Not much to it. This invalidates the write cache as well as the read cache, which is why we have the sync command first. Supposedly, it is possible to have some cached write data never make it to disk, so use it with caution, and NEVER do it on a production server. You could ... but why take the risk?

As long as you are running a post 2.6.16 kernel,..."

Source: http://ubuntuforums.org/showpost.php?p=3621283&postcount=1

cal 04 2012 | awk 'NF <= 7 { print $7 }' | grep -v "^$" | tail -1
2012-05-03 16:57:45
User: javidjamae
Functions: awk cal grep tail

This is a little trickier than finding the last Sunday, because you know the last Sunday is in the first position of the last line. The trick is to use the NF less than or equal to 7 so it picks up all the lines then grep out any empty lines.

free -m | awk '/Swap/ {print $4}'
2009-09-02 11:46:17
User: voyeg3r
Functions: awk free

simple way to show free swap

ls -a | egrep "^\.\w"
2009-11-11 18:19:56
User: kulor
Functions: egrep ls
Tags: egrep ls dotfiles

trying to copy all your dotfiles from one location to another, this may help

echo "X-Facebook: from zuckmail ([MTI3LjAuMC4x])" | cut -d \[ -f 2 | cut -d \] -f 1 | openssl base64 -d
2010-05-09 00:46:28
User: IsraelTorres
Functions: cut echo

Currently Facebook has updated their headers to display but if you have saved e-mails from messages and FB related mail you can still reveal the IP. :)

Tested on Mac OS X 10.6.3

open -a Finder <path>
mount -t msdos /dev/fd0 /mnt/floppy
2009-12-10 06:46:53
User: eastwind
Functions: mount

-t option tells the system to look for a msdos filesystem

The /dev/fd0 is your floppy drive ( This may be different for you check /dev folder to confirm)

/mnt/floppy is the point where you want to mount the device to

rm -fr `find . -name Thumbs.db`
site="http://gifbin.com/"; for i in $(wget -qO- "$site"random| sed -r "s/^.*(bin\/.+\.gif).*$/\1/m" | grep "^bin"); do wget -c "$site$i"; filename=`basename $i`; [ `identify $filename | wc -l` -gt 1 ] || rm -f $filename; done
2011-02-15 10:05:37
User: az
Functions: grep rm sed wc wget

Download a bunch of random animated gifs from http://gifbin.com/

while x=0; do foo ; sleep 1 ; done
2012-07-11 13:22:21
User: eastwind
Functions: sleep

repeat a command every X seconds , output show the creation of partition image using fsarchiver, each line show the size of the image.