File and disk space usage report on Linux

Linux has very useful commands but usually they need some extra parameters to read the output easily. du and df are among these. du reports the file and directory usage. It is the command to find about the size of a directory and its sub-folders. Here it is how I use it:

du --block-size=1M --exclude='./.*' --max-depth=1 |sort -n

and the output,


--block-size gives the file size in 1 megabyte blocks, --exclude='./.*' does not select the files&folders provided by the pattern which is hidden files&folders and --max-depth=1 shows only the directories. After these options I sort the output so that it lists by ascending according to directory size. The last number 7107 is the total size of my home directory in megabytes except the hidden folders&files. You can put this command as duu into alias list by typing

echo alias duu='du --block-size=1M --exclude='./.*' --max-depth=1 |sort -n' >> ~/.bashrc

df is similar but for file systems. You can check the home and root folder usage easily:

df -h


-h parameter is for human readable output. It provides the total usage in mega or gigabytes. Otherwise numbers are in bytes which is hard to read.


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: