In Ubuntu you can easily view the total size of a directory or folder from the terminal command line tool. And the good part is you don’t need any fancy GUI apps for this. You can view this via the du command. du is the short form of disk usage. In this article we will see how to find the size of a particular folder and all folders on your system from your terminal application.
Du Command in Linux:
Find a particular Folder size in terminal:
The basic syntax is
du -hs /folderpath
-h : numbers in human readable.
-s : summary only.
-c : total
-h : human-numeric-sort
-r : reverse
du -hs /home/manikandan/Downloads
Here manikandan is my username you can change with your ubuntu username. It will give the size details about the Downloads folder.
If you want to get the size of the folder and all the other things inside of that folder separately, then use this command.
du -h /home/manikandan/Downloads
You can also sort by size using sort option.
du -sch /home/manikandan/Downloads/* | sort -rh
View all Folders and files size:
If you want to view the size of all folders and files in your complete system then run this command.
Note: It will scan and shows all files and folders from your system and take some time to complete.
Some other useful du Command Examples:
sudo du -h --max-depth=1 /var/lib
sudo du -sh --apparent-size /var/lib