To check the size of a folder (directory) in Linux, you can use the du
(disk usage) command. Here’s how you can do it:
du -sh <folder_path>
- Open a terminal.
- Run the following command, replacing
<folder_path>
with the path to the folder you want to check: The-s
option tellsdu
to display only the total size of the specified folder, and the-h
option provides the output in a human-readable format (e.g., GB, MB, KB). - For example, to check the size of the
/home/user/Documents
folder, you would run:
du -sh /home/user/Documents
If you want to check the size of all subdirectories within the specified folder as well, you can omit the -s
option. This will display the size of each subdirectory along with the total size of the main folder.
du -h <folder_path>
The du
command is a versatile tool for analyzing disk usage in Linux. It provides various options to customize the output and explore the sizes of individual files and directories within a given folder. For more information on the available options, you can refer to the du
command’s manual page by running man du
in the terminal.