Get directory sizes in Ubuntu
In the Linux file system to get the size of a directory, you need to calculate and sum all file size of that directory.
The command du
is used for summarizing disk usage of each file, recursively for directories.
Get the size of a directory:
du -hs /path/to/directory
Here -h is for Human readable format and s for the summary.
For example:
devstudio:~$ du -hs /var/www/
1.2G /var/www/
Get the size of all directories individually:
du -h --max-depth=1 /path/to/directory
--max-depth is the level for directory size calculation.
For example:
devstudio:~$ du -h --max-depth=1 /var/www/devstudioonline.com/
311M /var/www/devstudioonline.com/app
231M /var/www/devstudioonline.com/public
542M /var/www/devstudioonline.com/
Keywords: