In this article, we focus on how you can check the size of Directory on Linux Systems. This we are going to achieve using the command line interface.

The command used to retrieve the file sizes is the  du  command, short for disk usage.

The syntax for du usage is

du [OPTION]... [FILE] [directory]

Check Size of a Directory

To find out the size of a directory run

# du -sh

Let’s break this command down further

-s , --summarize -  Displays only a total for each argument
-h , --human-readable - This prints the sizes in a human readable format. e.g 50G , 285M

For example, to get the size of a directory, run

# du -sh directory_name/

In this case, I have a directory called ‘django’ in my current working directory. To find its size, I ran,

# du -sh /django

Sample Output

252M    django/

Display Directory size in KB/MB or GB

You can also decide to display disk usage size in Kb, MB or GB.

To accomplish this simply use -k for kilobytes, and -m for megabytes. Using our sample directory, the syntax will be

# du -k django/

Sample Output

find the disk usage of Directory and Sub Folders

To display the usage in Megabytes run,

# du -m django

Sample Output

find the disk usage of Directory and Sub Folders

As you may have noticed, the commands only display the disk usage of the directory but not the file sizes. To display the file sizes, use the -a flag as shown. the -a flag specifies all files and directories

# du -ah /django

Sample output

find the disk usage of Directory and Sub Folders

Find Total Directory Usage

To view the grand total usage of all files and directories in your directory, append the -c flag as shown

# du -csh django/


252M django/
252M total

find the disk usage of Directory and Sub Folders

If you want to display only the grand total of a  given directory including all the sub-directories, use ‘grep’ command with ‘du’ command like below.

# du -ch django | grep  docs

Sample Output


find disk usage of a specific directory

Find Sub Folder Disk Usage

To show which subfolders take up disk space. Run below command

# du -h --max-depth=1 | sort -hr

Sample Output

For more information about the du command run

# man du

That’s all we had for you folks. We hope you found this tutorial helpful. Keep tuned in for more helpful topics.

Read Also:



Please enter your comment!
Please enter your name here