I want to check the Linux directory size along with its sub-directories. How can I??
This article will help you to know how to check the total size of the Linux directory in a terminal. Ever you noticed that, when running the command ls, it shows size almost 4096 bytes. Did you think why so?? Clearly, its the space taken by the meta information for the directory to store on the disk. It’s not the size of the files contains inside it.
To check all the files size within a directory, du (Disk Usage) command is used.
1. To check the size of a directory along with its sub-directories. Run the following command.
$ du -ah /home/arun/downloads
where a = all files and directories
h = Human Readable format means in Kilobytes, Megabytes, Gigabytes etc.
2. To check total size of a directory, execute the following command.
$ du -sh /home/arun/Downloads/
where s = shows total size of a directory
Remember: Du command is used to check the disk usage of files and directories.
To check the size of the Linux partitions, need to use the fdisk command.
Read More: How to Attach New Hard Disk with Existing Linux Server
Conclusion: You have perfectly learned how to check the total disk usage of a directory or file in a Linux operating system. In case of any confusion or feedback, kindly write in below comment box.