h1

Get disk usage from the command line (du and df)

March 10, 2010

the du command can be used to get the size of files or directories from the command line. The usual usage is:

du -h

This will tell you how much disk space is being used by everything in the current directory. The -h stands for ‘human readable’ which one would have thought would be the default but exists for legacy reasons. The default behaviour without -h is to display the number of blocks taken up by the files.

To see the size of each file in a directory use:

du -h *

To see the disk usage statistics for all mounted drives you can use the df command which provides the amount of space in total, how much is used and how much is left. Its useful as it also provides the percentage used:

df -h

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: