When checking the size of files, we typically use the ls -lh
command, but this command is not accurate for folders.
To calculate the size of a folder, we can use the du
command in Linux. This command displays the disk usage of all files within a directory and offers different ways to present this information.
Some commonly used options include:
-h
: Display sizes in a human-readable format-s
: Show only the total size instead of the size of each subdirectory
Therefore, to check the size of a specific folder, you can use the following command:
du -sh /path/to/folder/
Here, /path/to/folder/
should be replaced with the path of the folder you want to check.
You can also use the --max-depth=1
option to specify the depth of subdirectories you want to include in the size calculation.
After executing this command, the terminal will output the total size of the specified folder, displayed in a human-readable format.