How to Check Directory Size in Linux Using du Command
When working on a Linux terminal, you may often need to find out how much space a folder or directory is using. In this guide, we’ll look at how to check directory size in Linux using the du
command.
The du
command stands for disk usage, but it’s not used to check total disk space — instead, it helps you find the size of directories and folders. You can think of du as “directory usage.”
Check Directory Size Using du Command
To begin, open your terminal and run the du
command without any options:
du
This shows the usage for your current working directory.
By default, du also includes subdirectories recursively, which can make the output long and difficult to read in large folder structures. The last value in the output represents the total size of the directory.
However, since the size is displayed in bytes, it’s not very readable.
Make du Output Human Readable
You can make the du
output easier to understand by using the -h
option:
du -h
The -h
stands for human-readable, and it tells du
to display folder sizes in KB, MB, or GB. Now, you’ll see the sizes in an easier-to-read format, such as “12M” or “1.2G.”
Limit Directory Depth with --max-depth
By default, du
displays results for all subdirectories recursively. To make it easier to read, use the --max-depth
option to limit how deep du
scans directories.
Examples:
Shows only the total size of the current directory:
du -h --max-depth=0
Shows the total size of the current directory and its direct subdirectories (not recursive).
du -h --max-depth=1
You can increase the depth value (2, 3, etc.) to include deeper levels, but it’s usually enough to use 0 or 1 for quick checks.

du -sh command
You can check only the total size of a folder with the du -sh
command.
du -sh
It gives the same result as running du -h --max-depth=0
.


Include Files in the du Output
By default, du
only lists directory sizes. If you want to include files as well, use the -a
option:
du -ha --max-depth=1
This command lists both folders and files with their respective sizes. It’s useful if you want to see which files take up the most space inside a directory.
Check the Size of a Specific Directory
If you want to check a specific directory instead of the current one, just add its path. For example:
du -h --max-depth=1 /var/log
This command displays the total size of the /var/log
directory, along with its subdirectories.
Sort the du Output
The du
command doesn’t have a built-in sorting option, but you can easily sort the results using the sort
command.
To sort from smallest to largest:
du -h --max-depth=1 | sort -h
To sort from largest to smallest:
du -h --max-depth=1 | sort -hr
When sorting in reverse order (-hr
), the largest directories appear at the top, making it easy to find which ones consume the most space.

Conclusion
That’s how you can check directory size in Linux using the du
command.
Here’s a quick summary of the key options:
-h
– show human-readable sizes (KB, MB, GB)-sh
– show human-readable sizes (KB, MB, GB)--max-depth
– control how many subdirectory levels to display-a
– include files in the output
These commands are everything you need to efficiently check folder and directory sizes in Linux from the terminal.