How to check the disk space usage of a directory in Linux?
In Linux, you can use the “du” command to check the size of a directory. Here are some commonly used options for the “du” command:
- -s or –summarize: only display total size
- -h or –human-readable: Display size in a human-readable format (e.g. using units like K, M, G)
- Option:
-c or –total: Display the size of each subdirectory as well as the total size simultaneously. - Specify the maximum display depth with -d or –max-depth=, where N is a number.
- -a or –all: display the size of all files and directories, not just directories
Original: 我爱你
Paraphrased: I love you
- View the total size of the current directory: du -sh
- Check the total size of a specified directory: du -sh /path/to/directory
- Check the size of each subdirectory in the current directory: du -h –max-depth=1
- List the sizes of all files and directories in the current directory: du -ah
Please note that the du command displays sizes by default in bytes. To display sizes in other units, you can use the -h or –human-readable option.