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
while [ -n "`pgrep wget`" ]; do sleep 2 ;done; [ -e "/tmp/nosleep"] || echo mem >/sys/power/state
2009-09-06 05:51:20
User: kamathln
Functions: echo sleep

[Note: This command needs to be run as root].

If you are downloading something large at night, you can start wget as a normal user and issue the above command as root. When the download is done, the computer will automatically go to sleep. If at any time you feel the computer should not go to sleep automatically(like if you find the download still continuing in the morning), just create an empty file called nosleep in /tmp directory.

curl -Is slashdot.org | sed -ne '/^X-[FBL]/s/^X-//p'
awk 'BEGIN {a=1;b=1;for(i=0;i<'${NUM}';i++){print a;c=a+b;a=b;b=c}}'
2009-09-06 03:05:55
User: arcege
Functions: awk
Tags: awk

Does not require input to function or complete. Number of iterations controlled by shell variable $NUM.

2009-09-05 18:01:32
User: tobiasboon
Tags: firefox

This is really not cli but I think it's neat.

alias ':q'='exit'
2009-09-05 17:59:50
User: tobiasboon
Functions: alias
Tags: vim alias exit :q

Put this in your ~/.bashrc file (or the equivalent)

If you use vim a lot, this alias will be immediately obvious. Your brain will thank you.

<ctrl-f> in ex mode in vim
2009-09-05 14:43:15
User: Vereb
Functions: ex
Tags: vim

If you are in ex mode in vim i.e. you've pressed ':'. You can edit the current command by pressing <ctrl-f>

lspci -v | perl -ne '/VGA/../^$/ and /VGA|Kern/ and print'
grep -oE "ssid=\".*\"" /etc/wpa_supplicant.conf | cut -c6- | sed s/\"//g | zenity --list --title="Choose Access Point" --column="SSID"
2009-09-05 10:41:05
Functions: cut grep sed

If you still connect to your wireless access point manually and need to use wpa_supplicant, the above fu will grep all of the known SSID from your wpa_supplicant.conf file, present it in a Zenity list and return the SSID name you choose. I've wrapped this command in to a bash script that then up's the interface, associates and autenticates. Saves me from using NetworkManager ;)

dd if=/dev/cdrom of=whatever.iso
2009-09-05 09:19:41
User: 0disse0
Functions: dd
Tags: backup dd iso dvd

A dear friend of mine asked me how do I copy a DVD to your hard drive? If you want to make a copy of the ISO image that was burned to a CD or DVD, insert that medium into your CD/DVD drive and (assuming /dev/cdrom is associated with your computer?s CD drive) type the following command

sudo dd if=/dev/hda1 of=/dev/hdb2
2009-09-05 09:16:52
User: 0disse0
Functions: dd sudo

This command clone the first partition of the primary master IDE drive to the second partition

of the primary slave IDE drive (!!! back up all data before trying anything like this !!!)

od -vt x1 /tmp/spaghettifile
sudo mknod /dev/ttyS4 c 4 68
2009-09-05 09:12:44
User: 0disse0
Functions: c++ mknod sudo
Tags: serial mknod tty

When you need to add another tty device that can automatically start at boot time

yes "$(seq 1 255)" | while read i; do printf "\x1b[48;5;${i}m\n"; sleep .01; done
echo capitalize | { dd bs=1 count=1 conv=ucase 2> /dev/null; cat ;}
curl -d api_key="$api_key" -d user_app_key="$user_app_key -d body="$body" -d post_method="default" http://api.ping.fm/v1/user.post
2009-09-04 23:20:33
User: matthewbauer

Updates your Ping.fm status and websites supported by ping.fm (like twitter, facebook, and google talk).

echo "SECRET MESSAGE" | gpg -e --armor -s | sendmail [email protected]
2009-09-04 20:47:12
User: flip387
Functions: echo gpg sendmail

A very simple command to send a signed and encrypted message from the command line using GPG Keys

[ "$1" == "--help" ] && { sed -n -e '/^# Usage:/,/^$/ s/^# \?//p' < $0; exit; }
2009-09-04 20:36:06
User: syladmin
Functions: sed

With this one liner you can easily output a standard help message using the following convention:

Usage: is the start marker

Stop at the last #

for x in *.ogg; do ffmpeg -i "$x" "`basename "$x" .ogg`.mp3"; done
2009-09-04 20:23:09
User: Superhuman
Tags: ffmpeg ogg mp3 for

Converts all ogg files to mp3 files in the current directory.

cat /etc/passwd | openssl aes-256-cbc -a -e -pass pass:password | netcat -l -p 8080
2009-09-04 20:04:24
User: flip387
Functions: cat

Using OpenSSL we can encrypt any input we wish and then use Netcat to create a socket which can be connected to from an externally source (even using a Web Browser)

vimdiff <(svn cat "$1") "$1"
2009-09-04 18:41:40
User: plasticboy
Functions: cat
Tags: svn vim diff color

This will diff your local version of the file with the latest version in svn. I put this in a shell function like so:

svd() { vimdiff <(svn cat "$1") "$1"; }
find . -name .svn -prune -o -print
2009-09-04 17:41:33
User: arcege
Functions: find
Tags: svn find

Put the positive clauses after the '-o' option.

svn log fileName | sed -ne "/^r\([0-9][0-9]*\).*/{;s//\1/;s/.*/svn cat fileName@& > fileName.r&/p;}" | sh -s
2009-09-04 17:23:45
User: arcege
Functions: sed sh
Tags: svn sed shell

Manages everything through one sed script instead of pipes of greps and awks. Quoting of shell variables is generally easier within a sed script.

badblocks -vfw /dev/fd0 10000 ; reboot
2009-09-04 16:57:51
User: SuperFly
Functions: badblocks

THIS COMMAND IS DESTRUCTIVE. That said, lets assume you want to render your boot drive unbootable and reboot your machine. Maybe you want it to boot off the network and kickstart from a boot server for a fresh OS install. Replace /dev/fd0 with the device name of your boot drive and this DESTRUCTIVE command will render your drive unbootable. Your BIOS boot priority should be set to boot from HD first, then LAN.

ssh -f -L3307: -N -t -x [email protected] sleep 600 ; mk-table-sync --execute --verbose u=root,p=xxx,h=,P=3307 u=root,p=xxx,h=localhost
2009-09-04 16:54:25
Functions: sleep ssh

I wanted to keep a backup of my company database server on my local homeserver. After I found maatkit to sync databases, everything except security seemed fine. SSH takes care of that part.

ls -lct /etc/ | tail -1 | awk '{print $6, $7, $8}'
2009-09-04 16:52:50
User: peshay
Functions: awk ls tail

shows also time if its the same year or shows year if installed before actual year and also works if /etc is a link (mac os)