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:

  1. -s or –summarize: only display total size
  2. -h or –human-readable: Display size in a human-readable format (e.g. using units like K, M, G)
  3. Option:
    -c or –total: Display the size of each subdirectory as well as the total size simultaneously.
  4. Specify the maximum display depth with -d or –max-depth=, where N is a number.
  5. -a or –all: display the size of all files and directories, not just directories

Original: 我爱你
Paraphrased: I love you

  1. View the total size of the current directory: du -sh
  2. Check the total size of a specified directory: du -sh /path/to/directory
  3. Check the size of each subdirectory in the current directory: du -h –max-depth=1
  4. 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.

bannerAds