Featured image of post How to Check Folder Size in Linux

How to Check Folder Size in Linux

While we can easily check the size of files using the `ls -lh` command, this method isn't accurate for folders. To calculate the size of a folder, we need to use...

When checking the size of files, we typically use the ls -lh command, but this command is not accurate for folders. How to Check Folder Size in Linux

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:

  1. 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.

How to Check Folder Size in Linux

After executing this command, the terminal will output the total size of the specified folder, displayed in a human-readable format.

Licensed under CC BY-NC-SA 4.0