Paul - The Programmer

simple & stupid
Connect to wireless network with wireless tools
Detect CRLF (^M) line terminators in shell script

Good Linux Tool, find out the biggest file / directory in the system

paul posted @ Tue, 22 Mar 2011 22:13:44 +0800 in linux with tags Linux Debian du sort , 2742 readers

No matter how big your hard disk is, it can still run out of space someday. So, do some regular cleaning up work is necessary. Free some space by deleting the files which are out of date or not needed anymore.

To get the space consumed by each directory with du and find out the biggest one with sort.


$du --max-depth=1 -h | sort -h -r

Meaning of du options:

--max-depth : print the total size of direcotries on the firest level.

-h  : print the size in human readable format (e.g.  1K, 2M, 3G, etc. ).

Meaning of sort options:

-h : sort human readable format numbers.

-r : reverse the result, the biggest number is on the top.

What I need to do is use this command recursively from the root directory ( / ) . It will finally lead me to the file or directory which consumes most of my storage.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.

Login *

loading captcha image...
(type the code from the image)
or Ctrl+Enter