Linux: Check how much disk storage each directory takes up (Disk Usage command – du)

by Yang Yang on September 2, 2009

The Linux command du stands for disk usage which is used to check the amount of disk storage any particular directory or file is using. By default, the simple command:

du

Would return the disk usage in God-knows-what-unit of each of the directories in the current working directory and those beneath them – in a recursive manner. If you happen to have lots of them, the returned stats would be scrolling down crazily which barely makes it any useful.

Even if you have specified a specific directory such as "somedir":

du somedir

It still works in this uncomfortable way.

The solution is to use the -sh switch, the one switch a beginner will ever need:

du -sh

Which simply returns the amount of disk space the current directory and all those stuff in it are using as a whole, something like:

2.4G

Much much more intuitive and readable.

By:

du -sh somedir

You can find out how much disk storage directory "somedir" is using:

101M    somedir

To get all the subsequent / child directories disk usage from the current directory, simply use the asterisk:

du -sh *

It will then list the disk usage of all of them (but not recursively) one by one in a very readable manner:

8.0K    dir1
1.4G    dir2
135M    dir3
Subscribe to Kavoir: blog feed

You should also read:

{ 6 comments… read them below or add one }