Linux: Find Out Directory Size Command

I am a new Linux user. How do I find out size of a directory on Linux operating systems using command line options?

You need to use the du command: [a] Find and estimate file space usage.
Tutorial details
Difficulty level Easy
Root privileges No
Requirements du
Est. reading time Less than a one minute
[b] Summarize disk usage of each FILE/Directory/Folder. [c] Shows the sizes of directories and files.


The basic syntax is:

du dirName
du [options] dirName


Without any options, du command shows the names and used space for each directories including all sub-directories in the current directory:
Sample outputs:

Fig.01: du command in action

To find information about /etc and /home/nixcraft directory, enter:
du /path/to/dir
du /etc
du /home/nixcraft
du /root /home/nixcraft

Pass the -h option to get output in human readable format i.e. show output in kilobytes (K), megabytes (M) and gigabytes (G):
du -h /etc
du -h /dir1/file2
du -h /root
du -h

Sample outputs:

8.0K	./.vim
24K	./scripts
48K	./.ssh
16K	./.keychain
2.2M	./.lftp
2.4M	.

Pass the -s option to see the total disk space used by a directory:
du -sh
du -sh /etc/
du -sh /etc /home/ /securebackup/

Sample outputs:

4.1M	/etc
152K	/home/
902M	/securebackup/

Pass the -c to see a grand total for all of the files, type:
du -csh /root/ /etc/ /home/
Sample outputs:

2.4M	/root/
4.1M	/etc/
152K	/home/
6.6M	total
See also
  • UNIX disk usage command examples – include command line tool such as du, df, ncdu, and GUI tools.
  • See du command man page for more information and examples.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 11 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
11 comments… add one
  • Mahdi Jun 9, 2013 @ 22:23

    Thank you very much!

  • kgas Jun 10, 2013 @ 11:30

    another good one is ncdu

    • tom Mar 16, 2014 @ 20:08

      ncdu is nice, thanks for that tip

  • bart Jun 10, 2013 @ 13:49

    “du -sh * | sort -r -n”

    Show all current files + directories with their size and sort them so that the largest file/folder shows on top and the smallest at the bottom.

    • mosi Mar 18, 2014 @ 15:59

      thanks sir for this impressive command :)

      • Finn Mar 30, 2014 @ 16:06

        That should be “du -sh * | sort -r -h”

        -n doesn’t take into account the K/M factor, -h does!

        If you want largest at the bottom:
        “du -sh * | sort -h”

  • meow Jun 10, 2013 @ 14:51

    When I read the title the first command came to my mind is “du”.

  • na3r Jun 30, 2013 @ 19:41

    another usefull command to determine directory size is

    du -h | sort -h

    it sorts directory by size

  • Bogdan Oct 22, 2013 @ 16:51

    Another good option to show disk usage is to limit only to one level, you don’t need all information from all folders each time.

    du -h –max-depth=1

    It will be faster and it won’t show you lots of information

    root@bogdan:/root# du -h --max-depth=1
    2.9M	./.nbi
    948K	./.local
    104K	./.gconf
    12K	./.gnome2
    4.0K	./.gnome2_private
    44K	./.filezilla
    356K	./.cache
    12K	./Desktop
    4.0K	./.gvfs
    1.2M	./.gem
    12K	./.dbus
    86M	./.cpan
    26M	./perl5
    1.5M	./.java
    80K	./.config
    16K	./.ssh
    4.0K	./.pulse
    165M	.
  • rueben Nov 9, 2013 @ 15:57

    …and if you don’t want to type out –max-depth=1…

    du -sh *

    • vincent Dec 19, 2013 @ 14:49

      This command is a bit different.
      It shows the files under top-level directory, but doesn’t show the total size of the directory.
      while with –max-depth=1
      it does not show the files, but will show the total size.

      In terms of the size of the first-level sub-directories, they are the same.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum