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,362 results
nmap -A -p1-85,113,443,8080-8100 -T4 --min-hostgroup 50 --max-rtt-timeout 2000 --initial-rtt-timeout 300 --max-retries 3 --host-timeout 20m --max-scan-delay 1000 -oA wapscan
2009-06-25 14:12:26
User: merkmerc

I've used this scan to sucessfully find many rogue APs on a very, very large network.

mstsc /w:1500 /h:900 /v:www.example.com
2009-06-25 14:01:42
User: merkmerc

Using a widescreen monitor, I often get annoyed that the RDP window is too high, or too narrow for what I want to display. In this example, I'm on a 1680 x 1050 display.

echo "-------------" >> nicinfo.txt; echo "computer name x" >> nicinfo.txt; ifconfig | grep status >> nicinfo.txt; ifconfig | grep inet >> nicinfo.txt; ifconfig | grep ether >> nicinfo.txt; hostinfo | grep type >> nicinfo.txt;
/usr/dt/bin/dtconfig -d
2009-06-25 09:32:37

With a full installation of Solaris 10, the graphical login and desktop will start by default. This command will disable that feature. To enable it again use: /usr/dt/bin/dtconfig -e

sudo /Applications/Utilities/Adobe\ Utilities.localized/Adobe\ Updater5/Adobe\ Updater.app/Contents/MacOS/Adobe\ Updater
2009-06-25 08:07:47
User: miccaman
Functions: sudo
Tags: Os X

adobe updater keeps popping up. (normal update fails, probably due to insufficient rights)

(src: http://aricsblog.blogspot.com/2007/12/adobe-updater-crashes-on-mac-os-x-and.html)

ctrl + r
2009-06-25 06:51:38
User: Bluehive

Very handy and time-saving.

Do a 'ctrl+ r' on command prompt. You will see a "(reverse-i-search)`':" mark. Just type any sub-string of the command you want to search(provided you have used it sometime in the same session).

Keep on searching by repeatedly pressing ctrl+r. Press enter once you get the desired command string.

curl -v -k -u user:password "https://members.dyndns.org/nic/update?hostname=<your_domain_name_here>&myip=$(curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z<>/ :]//g')&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
2009-06-24 17:00:15
User: din7

This is great if you are behind a router that does not support dynamic dns updates!

Example: AT&T u-verse gateway...

Put this in a script and run it as a cron job.

echo $numbers | sed "s/\( \|$\)/\n/g" | sort -nu | tr "\n" " " | sed -e "s/^ *//" -e "s/ $//"
2009-06-24 15:12:17
User: chickenzilla
Functions: echo sed sort tr

You can replace "sort -nu" with "sort -u" for a word list sorted or "sort -R" for a random-sorted line

(edit: corrected)

mii-tool eth0
2009-06-24 08:43:55
User: flart

with 'mii-tool -w eth0' you can watch the interface for changes of the link status

echo "${STRING}" | tr '[A-Z]' '[a-z]' | awk '{print toupper(substr($0,1,1))substr($0,2);}'
2009-06-23 21:11:34
User: mohan43u
Functions: awk echo tr
Tags: awk tr

Helpful when we want to do mass file renaming(especially mp3s).

find . -depth -type d -exec du -s {} \; | sort -k1nr
2009-06-23 20:52:35
User: mohan43u
Functions: du find sort
Tags: sort find du

somewhat faster version to see the size of our directories. Size will be in Kilo Bytes. to view smallest first change '-k1nr' to '-k1n'.

readlink -f ../super/symlink_bon/ahoy
2009-06-23 17:46:08
User: rbs
Functions: readlink

readlink -f accepts a relative, noncanonical path and emits the corresponding canonical, absolute path.

tune2fs -O extents,uninit_bg,dir_index /dev/yourpartition
2009-06-23 17:42:01
User: starchox
Functions: tune2fs

Before doing this, back-up all data on any ext3 partitions that are to be converted to ext4.

After running previous command you MUST run fsck, is needed to return the filesystem to a consistent state.

fsck -pDf /dev/yourpartition

Edit /etc/fstab and change the 'type' from ext3 to ext4 for any partitions that are converted to ext4.

echo {0..1}{0..1}{0..1}{0..1}
2009-06-23 17:30:20
User: dennisw
Functions: echo

If you should happen to find yourself needing some binary numbers, this is a quickie way of doing it. If you need more digits, just add more "{0..1}" sequences for each digit you need. You can assign them to an array, too, and access them by their decimal equivalent for a quickie binary to decimal conversion (for larger values it's probably better to use another method). Note: this works in bash, ksh and zsh. For zsh, though, you'll need to issue a setopt KSH_ARRAYS to make the array zero-based.


echo ${binary[9]}
ls -1t | head -n10
2009-06-23 12:15:12
User: wires
Functions: head ls
Tags: ls

order the files by modification (thanks stanishjohnd) time, one file per output line and filter first 10

ditto --arch i386 doubleTwist.app doubleTwist_i386.app
2009-06-22 23:59:14

ditto can be used to "thinnify" Mach-O Universal binaries to separate unncessary code from your machine. For example, doubleTwist.app shaved off around 10 MB while Google Earth went from 112 MB to 62 MB after extracting only the i386 code from them.

ssh -L :: -L :: @
2009-06-22 19:12:48
User: starchox
Functions: ssh

Thankfully, the ssh command allows you to specify multiple tunnels through the same server in one command.

Remeber if you want a priviliged port on your machine, you must use root or sudo account.

wget -q --user=<username> --password=<password> 'https://updates.opendns.com/nic/update?hostname=your_opendns_hostname&myip=your_ip' -O -
2009-06-22 18:08:42
User: Alanceil
Functions: wget

Intended for dynamic ip OpenDNS users, this command will update your OpenDNS network IP.

For getting your IP, you can use one of the many one-liners here on commandlinefu.


I use this in a script which is run by kppp after it has successfully connected to my ISP:



IP="`curl -s http://checkip.dyndns.org/ | grep -o '[[:digit:].]\+'`"


if [ "$IP" == "" ] ; then echo 'Not online.' ; exit 1


wget -q --user=topsecret --password="`echo $PW | xxd -ps -r`" 'https://updates.opendns.com/nic/update?hostname=myhostname&myip='"$IP" -O -

/etc/init.d/ntp-client restart &



PS: DynDNS should use a similar method, if you know the URL, please post a comment. (Something with members.dyndns.org, if I recall correctly)

find . -name "*.sql" -print0 | wc -l --files0-from=-
2009-06-22 17:45:03
User: vincentp
Functions: find wc
Tags: find wc count line

This command gives you the number of lines of every file in the folder and its subfolders matching the search options specified in the find command. It also gives the total amount of lines of these files.

The combination of print0 and files0-from options makes the whole command simple and efficient.

multitail /var/log/messages /var/log/apache2/access.log /var/log/mail.info
2009-06-22 06:51:11
User: Neo23x0

It works like a "tail -f" on several files.

Use the number keys 0-9 to set a baseline in the numbered window.

Pressing "b" let you scroll back in one of the windows.

while true; do { $(which logger) -p local4.notice `free -m | grep Mem`; sleep 60; } done &
2009-06-22 00:29:53
User: Neo23x0
Functions: grep sleep which

Uses logger in a while loop to log memory statistics frequently into the local syslog server.

bind '"\e[24~"':"\"ps -elF;df -h;free -mt;netstat -lnpt;who -a\C-m"""
2009-06-21 23:57:20
User: Neo23x0

Command binds a set of commands to the F12 key.

Feel free to alter the dashboard according to your own needs.

How to find the key codes?



Then press the desired key (example: F5)



bind '"\e[15~"':"\"ssh [email protected]\C-m"""


bind '"\e[16~"':"\"apachectl -k restart\C-m"""
2009-06-21 17:58:01
User: Neo23x0

!* is all of the arguments to the previous command rather than just the last one.

This is useful in many situations.

Here's a simple example:

vi cd /stuff


[exit vi, twice]


expands to: cd /stuff

# cd $partition; dd if=/dev/zero of=ShredUnusedBlocks bs=512M; shred -vzu ShredUnusedBlocks
2009-06-21 14:17:22
User: mpb
Functions: cd dd shred

This command securely erases all the unused blocks on a partition.

The unused blocks are the "free space" on the partition.

Some of these blocks will contain data from previously deleted files.

You might want to use this if you are given access to an old computer and you do not know its provenance.

The command could be used while booted from a LiveCD to clear freespace space on old HD.

On modern Linux LiveCDs, the "ntfs-3g" system provides ReadWrite access to NTFS partitions thus enabling this method to also be used on Wind'ohs drives.

NB depending on the size of the partition, this command could take a while to complete.

sudo sed 's/\o0/\n/g' "/proc/$(pidof -x firefox)/environ" ;# replace firefox