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.

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





Commands using du from sorted by
Terminal - Commands using du - 208 results
du -xm --max-depth 2 /var/log | sort -rn | head
2013-12-16 13:29:33
User: srvesh
Functions: du sort

this will give u the details in MB's; from high to low....

du -Sh | sort -h | tail
2013-11-27 17:50:11
User: pdxdoughnut
Functions: du sort

I added -S to du so that you don't include /foo/bar/baz.iso in /foo, and change sorts -n to -h so that it can properly sort the human readable sizes.

du -ah | sort -h | tail
du -hs *|sort -h
du -k ~/* | awk '$1 > 50000' | sort -nr
find /Users/jpn/.ievms/ -type f -print0| xargs -0 du -sh
2013-10-16 09:54:19
Functions: du find xargs

When you do a ls -1 | xargs rm it wouldn't workd because those files have spaces. So you must use

find -print0 and xargs -0

du -ah | sort -hr | head -n50 | cat -n
du -hd1 | sort -hr
brew cleanup -n | awk '{print $3}' | xargs du -s | awk '{s+=$1} END {print s}'
find -name *.bak -print0 | du -hc --files0-from=-
du -Lsbc * |awk 'function hr(bytes){hum[1024**4]="TiB";hum[1024**3]="GiB";hum[1024**2]="MiB";hum[1024]="kiB";for(x=1024**4;x>=1024;x/=1024){if(bytes>=x){return sprintf("%8.3f %s",bytes/x,hum[x]);}}return sprintf("%4d B",bytes);}{print hr($1) "\t" $2}'
ls | xargs -I{} du -sh {}
du -m --max-depth=1 [DIR] | sort -nr
du -hs `du -sk * | sort -rn | cut -f2-`
du -xks * | sort -n
2013-07-18 16:10:28
User: rdc
Functions: du sort

This command is useful for finding out which directories below the current location use the most space. It is summarised by directory and excludes mounted filesystems. Finally it is sorted by size.

du -hs /path/to/folder/*
du -h --max-depth=1 /path/folder/
2013-07-09 19:56:13
User: ene2002
Functions: du

I wanted an easy way to list out the sizes of directories and all of the contents of those directories recursively.

find . -type d -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {} | sort -rn
du -mx [directory] | grep -P '^\d{4}' | sort -rn
2013-05-24 09:52:41
User: mc0e
Functions: du grep sort
Tags: bash Linux du

I don't like doing a massive sort on all the directory names just to get a small set of them. the above shows a sorted list of all directories over 1GB. use head as well if you want.

du's "-x" flag limits this to one file system. That's mostly useful when you run it on "/" but don't want "/proc" and "/dev" and so forth. Remember though that it will also exclude "/home" or "/var" if those are separate partitions.

the "-a" option is often useful too, for listing large files as well as large directories. Might be slower.

du -xB M --max-depth=2 /var | sort -rn | head -n 15
du -h --time --max-depth=1 | sort -hr
du -h
du --max-depth=1 -h * |sort -h -k 1 |egrep '(M|G)\s'
2013-02-14 08:56:56
User: TerDale
Functions: du egrep sort

Enhanced version: fixes sorting by human readable numbers, and filters out non MB or GB entries that have a G or an M in their name.

ls -a | du --max-depth=1 -h 2>/dev/null |sort -h