MTI TEK
  • Home
  • About
  • LLMs
  • Docker
  • Kubernetes
  • Java
  • All Resources
Linux-Ubuntu | du -- display disk usage statistics
  1. Notes
  2. Examples
  3. Command Help (man du)

  1. Notes
    du [OPTION]... [FILE]...
    
    • For each file specified, the du command displays the disk space usage.

    • For each directory specified, the du command displays the disk space usage for the directory and all its contents recursively.

    • If no file or directory is specified, the du command displays the disk space usage for the current directory and all its contents.
  2. Examples
    • Display the disk usage for all files and directories in human-readable format:
      $ du -ah folder1/
      4.0K    folder1/file1
      4.0K    folder1/file2
      4.0K    folder1/file3
      0    folder1/folder2
      0    folder1/folder2/folder3
      16K    folder1/
      
    • Display the disk usage for all items within a directory (but not the directory itself):
      $ du -h folder1/*
      4.0K    folder1/file1
      4.0K    folder1/file2
      4.0K    folder1/file3
      0    folder1/folder2
      
    • Display the disk usage for directories only (default behavior):
      $ du -h folder1/
      0    folder1/folder2/folder3
      0    folder1/folder2
      16K    folder1/
      
    • Display the disk usage for directories up to a specific depth:
      $ du -hd 1 folder1/
      0    folder1/folder2
      16K    folder1/
      
    • Display only the total disk usage of a directory:
      $ du -sh folder1/
      16K    folder1/
      
    • Display disk usage with a grand total:
      $ du -shc folder1/ folder2/
      16K    folder1/
      8.0K   folder2/
      24K    total
      
  3. Command Help (man du)
    The following options can be used:
    -a, --all
        Display sizes for all files, not just directories.
    
    -d, --max-depth=N
        Print the total for a directory only if it is N or fewer levels below the command line argument.
    
    -s, --summarize
        Display only a total for each argument (equivalent to --max-depth=0).
    
    -c, --total
        Produce a grand total at the end.
    
    -h, --human-readable
        Print sizes in human readable format (e.g., 1K 234M 2G).
    
    -k, --block-size=1K
        Use 1024-byte blocks instead of the default block size.
    
    -m, --block-size=1M
        Use 1048576-byte (1-Mbyte) blocks.
    
    -B, --block-size=SIZE
        Scale sizes by SIZE before printing them.
    
    -L, --dereference
        Dereference all symbolic links.
    
    -x, --one-file-system
        Skip directories on different file systems.
    
    --exclude=PATTERN
        Exclude files that match PATTERN.
    
    --time
        Show time of the last modification of any file in the directory.
    
    --apparent-size
        Print apparent sizes, rather than disk usage.
    
© 2025 mtitek