LINUX

LINUX – How do you get the size of a directory on the command line

Get directory size

There’s no Windows built in command to find directory size.  But there is a tool called diruse.exe which can be used to get folder size. This tool is part of XP support tools.  This command can be used to get directory size. This command’s syntax is given below.
Bash Code
diruse.exe   directory_name

Example:

Bash Code
C:\>diruse c:\windows
                Size  (b)  Files  Directory
                12555896050  64206  SUB-TOTAL:  C:\WINDOWS
                 12555896050  64206  TOTAL:  C:\WINDOWS

diruse prints the directory size in bytes and it also prints the number of files in the directory(it counts the number of files in the sub folders also).

From the Terminal command line, the following syntax to see the size of a directory:

Bash Code
du -sh /directory/path

For example, to get the total size of the /Applications folder, you would issue the following command string:

Bash Code
du -sh /Applications/

To get the directory size in mega bytes we can add /M switch.
Example:

Bash Code
          C:\>diruse /M C:\Windows
         Size (mb)  Files  Directory
         11974.24  64206  SUB-TOTAL: C:\WINDOWS
         11974.24  64206  TOTAL: C:\WINDOWS

Dir command accepts wild cards. We can use ‘*” to get the file sizes for all the files in a directory.

Bash Code
C:\>dir C:\Windows\Fonts
             Volume in drive C is Windows 7
             Volume Serial Number is 14A1-91B9

       Directory of C:\Windows\Fonts
                   06/11/2016  02:13 AM            10,976 8514fix.fon
                  06/11/2016  02:13 AM            10,976 8514fixe.fon
                  06/11/2016  02:13 AM            11,520 8514fixg.fon
                  06/11/2016  02:13 AM            10,976 8514fixr.fon
                  06/11/2016  02:13 AM            11,488 8514fixt.fon
                 06/11/2016  02:13 AM            12,288 8514oem.fon
                 06/11/2016  02:13 AM            13,248 8514oeme.fon
                 06/11/2016  02:13 AM            12,800 8514oemg.fon
READ  How to Install Linux on Chromebook (Guide)

About the author

Venkatesan Prabu

Venkatesan Prabu

Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I'm a frequent speaker at tech conferences and events.

Add Comment

Click here to post a comment