Question: How do I find the size of a directory in Linux command line?
Answer: The size of a folder or directory in Linux can be found using the du command. du stands for disk usage.
All you need to do is to use the command:
du -h <path_to_directory>
This will show the size of each subdirectory and the total size of the directory at the bottom of the output. The h option prints the output in human readable format. This means you see the size of directory in KB, MB or GB instead of in bytes.
If you just want to see the total size of a directory without bothering with the subdirectories, you can use the du command with s option.
du -sh <path_to_directory>
The s option summarizes the entries and just provides the total size of the said directory. Most of the time, you would be using this command option.
Here’s a screenshot to show you what the output of the above two commands looks like:
I hope this quick Linux tip helped you to find the size of a folder in Linux command line. Stay tuned for more quick tips.