du Command in Linux: Check File and Directory Disk Usage
The du command in Linux (disk usage) will provide a detailed list about disk usage.
It is very useful to determine where the available disk space went, so you can investigate which directory is consuming the disk.
If we don't pass a directory as a parameter, it uses the current directory as the search base.
The most frequent options are:
- -a: Shows all files and not just directories;
- -c: Shows a total at the end of the listing;
- -h: Shows information in a simpler way. It uses M for megabytes and G for gigabytes;
- -s: Shows a summary of the specified directory and not the total of each subdirectory;
- -S: Excludes subdirectories from the count;
Examples:
$ du –h /home2M /home/carla4M /home/cristiane5M /home/guilherme1M /home/michel
With the -sh option, it shows the total, including subdirectories:
$ du –sh /home12M /home
With the -Sh option, it shows the total, excluding subdirectories:
$ du –Sh /home1k /home
If you want to know the total of each subdirectory:
$ du -sh ./*/291M ./carlacru/173M ./freud/142M ./mario/181M ./odonto/273M ./oficina/
The --inodes option shows the inode count:
$ du -s --inodes ./*/75 ./desafio/15 ./funnel/2 ./musicas/
You can investigate the entire disk, starting from root /:
# du -sh ./*/221M ./bin/125M ./boot/0 ./dev/32M ./etc/12G ./home/513M ./lib/219M ./lib64/0 ./media/0 ./mnt/120K ./opt/0 ./proc/145M ./root/420K ./run/43M ./sbin/0 ./sys/21M ./tmp/527M ./usr/2,8G ./var/
Note that pseudo-filesystems like /proc, /dev, and /sys do not occupy disk space because they are actually abstractions of the Kernel and subsystems.
![]() | The following command creates an "alias" called "dus" to show the data consumption of subdirectories: $ echo "alias dus='du -sh ./*/'" >> ~/.bashrc; alias dus='du -sh ./*/' This way, you can use the new "dus" command to determine the consumption of each directory in the system. |
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.
Liked it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.
