Use the du command in Linux to view the size of the directory

In Linux, you can use duthe command to view the size of a directory. Here are some commonly used ducommand options:

  • -h: Displays the file size in human readable format.
  • -s: Shows only the total size, not the size of each subdirectory.
  • -c: Displays the total size, and displays the total on the last line.
  • -a: Shows the size of all files and subdirectories in the directory, not just the size of the directory itself.

Here are some example usages:

  1. View the size of the current directory:

    du -sh
    
  2. Check the size of a specified directory:

    du -sh /path/to/directory
    
  3. View the size of all files and subdirectories in a directory:

    du -ah /path/to/directory
    
  4. View the total size of a directory, including subdirectories:

    du -shc /path/to/directory
    

Note that duthe command recursively calculates the size of all files and subdirectories in the directory, so it may take some time to complete the operation, especially for large directories.

Guess you like

Origin blog.csdn.net/somken/article/details/131952095
Recommended