Check file disk usage

You can use the du command in Linux to find out how much space is being consumed by a particular directory and its subdirectories. Used without any options, this command lists all directories below the current directory, along with the space consumed by each directory. At the end of the output, du lists the total disk space used within that directory structure.

Here is an example:

linux du command

In the picture above you can see the disk usage of the /home/bob/example_dir directory and its subdirectories.

By default, the disk space is displayed in 1KB block sizes. To make the output friendlier (in kilobytes, megabytes, and gigabytes), use the -h option:

linux du command h option

The total space consumed by the /home/bob/example_dir directory is shown on the last line (56 KB in this case).

Ordinarily, du shows the space used by the files in directories but not the space used by individual files. To report the size of individual files, use the -a option:

linux du command a option

Subscribe to our Newsletter

Like us on Facebook

Geek University 2019