Linux/Basic commands/du

From Wikiversity
Jump to navigation Jump to search

du [1][2] (abbreviated from disk usage) is a standard Unix program used to estimate file space usage—space used under a particular directory or files on a file system.

du examples[edit | edit source]

  • du -h --max-depth=1 | sort -hr or du -h -d 1 | sort -hr
  • du -sh -- *
  • du -ah --exclude="*.txt" /tmp/
  • Display only current File system: du -ha -x /tmp/
  • du -ha --time /tmp/
  • Files larger than 100M: du -h -t 100M -a /tmp

Activities[edit | edit source]

  1. Learn about du usage:
-a, In addition to the default output, include information for each non-directory entry
-c, display a grand total of the disk usage found by the other arguments
-d #, the depth at which summing should occur. -d 0 sums at the current level, -d 1 sums at the subdirectory, -d 2 at sub-subdirectories, etc.
-H, calculate disk usage for link references specified on the command line
-k, show sizes as multiples of 1024 bytes, not 512-byte
-L, calculate disk usage for link references anywhere
-s, report only the sum of the usage in the current directory, not for each directory therein contained
-x, only traverse files and directories on the device on which the pathname argument is specified.

See also[edit | edit source]