Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

du (Unix)

From Wikipedia, the free encyclopedia
Shell command for reporting file system storage use
du
Example screenshot ofdu in a terminal
Original authorsDennis Ritchie
(AT&T Bell Laboratories)
DevelopersVariousopen-source andcommercial developers
Initial release3 November 1971; 54 years ago (1971-11-03)
Written inPlan 9, FreeDOS:C
Operating systemUnix,Unix-like,Plan 9,Inferno,FreeDOS
PlatformCross-platform
TypeCommand
Licensecoreutils:GPLv3+
Plan 9:MIT License
FreeDOS:GPLv2

du is ashellcommand for reporting thefile system storage allocated tofiles anddirectory trees. With nocommand-line arguments, it reports the space allocated to theworking directory and to each directory tree that it contains, recursively. Space allocated to files is reported if files are specified for inclusion. For asymbolic link file, the size of the link file is reported, not what it links to.

Althoughdu is short fordiskusage,[1] the command is not limited todisk storage. It was developed during the long period of time when disk-based storage was the ubiquitousmass storage technology.

du differs fromdf in thatdu reports size information of file system items whereasdf reportsstatistics about the storage media as a whole.du can report more detailed information, but can take longer to complete when processing many files. Also, since a storage media may have allocated space that is not associated with an accessible file (i.e. file was deleted but space not freed),df might report more allocated space thandu if it were used to calculate the space of all files of a media. Also, the minfree setting that allocates data blocks for the file system and the super user processes creates a discrepancy between total blocks and the sum of used and available blocks.

Thedu command first appeared in version 1 ofAT&T UNIX. It is specified by theSingle UNIX Specification (SUS). The implementation inGNUcoreutils was written by Torbjorn Granlund, David MacKenzie, Paul Eggert, and Jim Meyering.[2] The command is also available forFreeDOS.[3] A similar command is available forWindows inSysinternals byMark Russinovich.

Use

[edit]

du accepts any number of parameters that each specify a file bypath to specify the starting scope. If none specified, the working directory is used. SUS mandates the following optional options:

  • -a: In addition to the default output, include information for each non-directory entry
  • -c: Report the grand total of the storage usage for the specified scope
  • -d #: The maximum directory tree depth of the scope. Deeper directories are ignored; for example, 0 sums the starting scope directory only and 1 sums the starting scope directory and its subdirectories
  • -H: Calculate storage usage for link references specified on the command line
  • -k: Show sizes as multiples of 1024bytes, not 512-byte
  • -L: Calculate storage usage for link references
  • -s: Report only the sum of the usage of the starting scope directory, and not that of subdirectories
  • -x: Only traverse files and directories on which the path argument is specified

Some implementations support other options. For example, BSD and GNU support a-h option that selects numbers to be formatted using metric units andnotation (e.g. 10MB) instead of bytes.

Examples

[edit]

Report the storage use for each file and directory tree inkilobytes (-k):

$du-sk*152304  directoryOne1856548 directoryTwo

Report the storage use in a morehuman-readable format (-h:

$du-sh*149M directoryOne1.8G directoryTwo

Report the storage use of all subdirectories and files including hidden files within the working directory sorted by file size:

$du-sk.[!.]**|sort-n

Report the storage use under in the working directory (-d 1) with a sum total at the end (-c), formatted as human-readable (-h):

$du-d1-c-h

For the GNU implementation,--max-depth is used instead of-d.

Report the storage use under the root directory (-d 1, trailing/) with a sum total at the end (-c), formatted as human-readable (-h) without traversing into other file systems (-x). Useful when /var, /tmp or other directories are on separate storage from the root directory:

$du-d1-c-h-x/

See also

[edit]

References

[edit]
  1. ^"Unix Programmer's Manual November 3, 1971"(PDF).Archived(PDF) from the original on December 28, 2025. RetrievedSeptember 22, 2025.
  2. ^du(1) – Linux User CommandsManual
  3. ^"ibiblio.org FreeDOS 1.2 Updates Package -- du (Unix-like)".www.ibiblio.org.Archived from the original on 2022-07-02. Retrieved2022-07-02.

External links

[edit]
The WikibookGuide to Unix has a page on the topic of:Commands
Windows
macOS
Linux
Other
File system
Processes
User environment
Text processing
Shell builtins
Searching
Documentation
Software development
Miscellaneous
File system
Processes
User environment
Text processing
Shell builtins
Networking
Searching
Software development
Miscellaneous
File system
Text utilities
Shell utilities
Retrieved from "https://en.wikipedia.org/w/index.php?title=Du_(Unix)&oldid=1336328130"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp