From LQWiki
Jump to: navigation, search

du (disk usage) is a tool which displays how the disk is used. It can be used to determine the sizes of files or directories without resorting to ls.

Example use

To determine the size of the current directory

$ du -sh

The -s flag is used to get a summary of the disk usage (the total size) in the current directory, -h lists amounts in human-readable terms of "K" for kilobytes, "M" for megabytes and "G" for gigabytes, instead of numbers of blocks.

To determine the sizes of each file in the current directory,

$ du -sh *

lists each file with its size. In Linux, the --max-depth=1 can be used to similar effect.

If you want to know the largest ten files in the current directory, one can use:

$ du -s * | sort -nr | head 

to list these files.

Provided by

Most (all?) Linux distributions incorporate this from the GNU Coreutils: man page

Related Commands

  • df - Report disk usage by filesystems.
  • lsblk - Report information about block devices.
  • stat - Report status from an inode
  • sync - Update all cached disk blocks.
  • truncate - Change file length

See also