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

  1. Notes
    du [file | directory ...]

    • For each file specified, the du command displays the file system block usage.

    • For each directory specified, the du command displays the file system block usage for all its sub-directories.

    • If none is specified, the du command displays the file system block usage for all sub-directories of the current directory.
  2. Examples
    • Display the file system block usage for all files and directories:
      $ du -ah folder1/
       12K    folder1/
      4.0K    folder1//file1
      4.0K    folder1//file2
      4.0K    folder1//file3
        0B    folder1//folder2
        0B    folder1//folder2/folder3

    • Display the file system block usage for all files and directories, excluding the specified directory from the list:
      $ du -h folder1/*
      4.0K    folder1//file1
      4.0K    folder1//file2
      4.0K    folder1//file3
        0B    folder1//folder2
        0B    folder1//folder2/folder3

    • Display the file system block usage for all sub-directories of a directory:
      $ du -h folder1/
       12K    folder1/
        0B    folder1//folder2
        0B    folder1//folder2/folder3

    • Display the file system block usage for sub-directories of a directory "n" directories deep:
      $ du -hd 1 folder1/
       12K    folder1/
        0B    folder1//folder2

  3. Command Help (man du)
    The following options can be used:
    -a
    |For each directory specified, displays the file system block usage for the specified directory and all its files and sub-directories.
    
    -d <depth>
    |For each directory specified, displays the file system block usage for all its sub-directories <depth> directories deep.
    
    -s
    |Display the file system block usage for each specified file or directory.
    |Equivalent to "-d 0"
    
    -c
    |Display the total of file system block usage of all listed files.
    
    -h
    |"Human-readable" output.
    |Use unit suffixes: Byte (-b), Kilobyte (-k), Megabyte (-m), Gigabyte (-g).
    
    -k
    |Display block counts in 1024-byte (1-Kbyte) blocks.
    
    -m
    |Display block counts in 1048576-byte (1-Mbyte) blocks.
    
    -g
    |Display block counts in 1073741824-byte (1-Gbyte) blocks.
© 2025  mtitek