How to Get Directory Size, Files Size in Ubuntu Linux?

Command to get directory size in Ubuntu 18.04, 19.04 & 19.10!

Check Directory Size in Ubuntu


et Directory Size in Ubuntu: In this article, we provided the information about how to get the size of the directory or files in the directory in Ubuntu using DU command. The command here we used to retrieve the size of the directory is DU command. This DU command will help you to get the size of the directory, file’s size, and the size of root dirextory in human readable formats such as “KB, MB & GB“. Lets get into the article.

Jump To:

Du Command Basic Syntax:

The basic syntax of DU command in Ubuntu is,

Basic Syntax of DU Command

The basic du command to find the whole root directory size is,

$du -sh

The above command will print the current root directory size in human readable format. Follow the below instructions to know more about DU command options.

Du Command Options:

To find the options available in DU command, use the below command:

$du --options

The output of the above command is,

[email protected]:~$ du --help
Usage: du [OPTION]... [FILE]...
  or:  du [OPTION]... --files0-from=F
Summarize disk usage of the set of FILEs, recursively for directories.

Mandatory arguments to long options are mandatory for short options too.
  -0, --null            end each output line with NUL, not newline
  -a, --all             write counts for all files, not just directories
      --apparent-size   print apparent sizes, rather than disk usage; although
                          the apparent size is usually smaller, it may be
                          larger due to holes in ('sparse') files, internal
                          fragmentation, indirect blocks, and the like
  -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                           '-BM' prints sizes in units of 1,048,576 bytes;
                           see SIZE format below
  -b, --bytes           equivalent to '--apparent-size --block-size=1'
  -c, --total           produce a grand total
  -D, --dereference-args  dereference only symlinks that are listed on the
                          command line
  -d, --max-depth=N     print the total for a directory (or file, with --all)
                          only if it is N or fewer levels below the command
                          line argument;  --max-depth=0 is the same as
      --files0-from=F   summarize disk usage of the
                          NUL-terminated file names specified in file F;
                          if F is -, then read names from standard input
  -H                    equivalent to --dereference-args (-D)
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
      --inodes          list inode usage information instead of block usage
  -k                    like --block-size=1K
  -L, --dereference     dereference all symbolic links
  -l, --count-links     count sizes many times if hard linked
  -m                    like --block-size=1M
  -P, --no-dereference  don't follow any symbolic links (this is the default)
  -S, --separate-dirs   for directories do not include size of subdirectories
      --si              like -h, but use powers of 1000 not 1024
  -s, --summarize       display only a total for each argument
  -t, --threshold=SIZE  exclude entries smaller than SIZE if positive,
                          or entries greater than SIZE if negative
      --time            show time of the last modification of any file in the
                          directory, or any of its subdirectories
      --time=WORD       show time as WORD instead of modification time:
                          atime, access, use, ctime or status
      --time-style=STYLE  show times using STYLE, which can be:
                            full-iso, long-iso, iso, or +FORMAT;
                            FORMAT is interpreted like in 'date'
  -X, --exclude-from=FILE  exclude files that match any pattern in FILE
      --exclude=PATTERN    exclude files that match PATTERN
  -x, --one-file-system    skip directories on different file systems
      --help     display this help and exit
      --version  output version information and exit

The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).

Find Directory Size using DU Command:

With the help of the du command, you can easily find the size of the root directory, follow the below command:

$du -sh

Command Explanation:

  • -s :¬†Displays only a total for each argument
  • -h : Displays the values in the human readable format
Check this too  Change & Reset User Password In Linux!
Root Directory Size
Root Directory Size

Find Files Size in the Directory using DU Command:

With the help of du command you can able to find the individual file sizes in the directory, use the following command:

$du -ah ./Videos

Command Explanation:

  • -a : Write counts for all files
  • -h¬†: Displays the values in the human readable format
Find individual file size
Find individual file size

Get Files Size in the Directory in KB, MB using DU Command:

You can use the du command to display the file or directory size in KB, MB & GB values. By default, du command will displays the values in the GB. Follow the command to display the values in KB and MB.

$du -ka ./Videos

The above command displays the files sizes in KB.

List values in KB
List values in KB
$du -ma ./Videos
List values in MB
List values in MB

From the above image, you may see that the du command print the values in KB and MB of the files inside the Videos directory.


That’s it. In this way, you can find the size of the directory and its files by using DU command on Ubuntu. If you have any queries related to this topic and then feel free to comment us below.

Article Review
  • Article Explanation
  • Commands Provided
  • Commands Options
  • Images Explanation


For more articles, Kindly visit our HomePage

Leave a Reply

Your email address will not be published. Required fields are marked *

Written by Rachel

I'm Rachel, From Arizona. Am playing the "Content Management" Role in Tec Robust. I started working in TR from Jan 2019. Big Marvel Fan.

Contact me:
tecrobust [@]
Sub: Message to Rachel

Check Battery Status Ubuntu

How to Check Battery Status in Ubuntu 18.04, 19.04 & 19.10?

KdenLive for Ubuntu

Kdenlive for Ubuntu- Install Kdenlive on Ubuntu 18.04 LTS & 19.10