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

List by size all of the directories in a given tree.

Terminal - List by size all of the directories in a given tree.
du -h /path | sort -h
2011-09-02 13:26:23
User: moogmusic
Functions: du sort
List by size all of the directories in a given tree.


There are 3 alternatives - vote for the best!

Terminal - Alternatives
du -sh * | sort -h
SEARCHPATH=/var/; find $SEARCHPATH -type d -print0 | xargs -0 du -s 2> /dev/null | sort -nr | sed 's|^.*'$SEARCHPATH'|'$SEARCHPATH'|' | xargs du -sh 2> /dev/null
2011-07-06 08:21:58
User: moogmusic
Functions: du find sed sort xargs

This command lists all the directories in SEARCHPATH by size, displaying their size in a human readable format.

Know a better way?

If you can do better, submit your command here.

What others think

Very nice -h option for sort. I usually use the "du -k /path | sort -n" command which will give similar output but not that "human" readable as your.

Comment by ztank1013 268 weeks and 2 days ago

sort's option -h is great indeed, but can somebody tell me in which version of sort it first appeared? It is pitty that my system lacks such an option...

Comment by xakon 268 weeks and 1 day ago

'sort -h' is present in v8.5 ... looking for a changelog on GNU coreutils that doesn't require me to download the entire source code, argh. The changelog doesn't use version numbers, only dates, but mentions the --human-readable option in 2004 but not for which program in coreutils.

Comment by Mozai 268 weeks and 1 day ago


sort: invalid option -- 'h'

Try `sort --help' for more information.

Comment by totti 267 weeks and 4 days ago

My system also doesn't have an -h option for sort, which is a shame. This workaround is very useful to me, rounds to the nearest megabyte:

du -ms * | sort -nr

Comment by ronocdh 254 weeks and 5 days ago

Your point of view

You must be signed in to comment.