Using DU to check disk usage on Linux file systems

du stands for disk usage. It is a Linux command to check disk usage. Let’s quickly see how we can use du.

du – outputs disk space used by all directories and sub-directories in the current directory
du -a – outputs disk space used by all files, directories and sub-directories in the current directory
du * – disk space used by all files, directories and sub-directories in the current directory. The good thing about * is that it lists only one level deep files/ directories. * can also be used to filter the output. For example, du -a *m will list all files, directories and sub-directories whose names start with the letter ‘m’
du /mydir – outputs disk space used by all files, directories and sub-directories in the directory /mydir
du -h /mydir – same as above but the output is in the human-readable form e.g. 5.9G.


du /mydir – outputs disk space used by all files, directories and sub-directories in the directory /mydir
du -h /mydir – same as above but the output is in the human-readable form e.g. 5.9G.


du /mydir – outputs disk space used by all files, directories and sub-directories in the directory /mydir
du -h /mydir – same as above but the output is in the human-readable form e.g. 5.9G.

List large-sized files in a directory

Let’s now see how we can use du to list large-sized files in a directory
hit du command and pipe it with sort to sort the output of du command.

du -ah ~/Downloads/ | sort -rh – prints the disk usage of all files, directories and subdirectories in the ~/Downloads directory and sorts them in descending order of their size. Let’s break it down.

| gives the output of du -ah ~/Downloads to another command sort which then sorts the output. The rh in sort command sorts in the reverse order and compares human readable numbers (e.g., 2K 1G).

du -ah ~/Downloads/ | sort -rh | head -n 10– prints the largest 10 files.

Leave a Reply