xref: /freebsd/usr.bin/du/du.1 (revision 3494f7c0)
1.\" Copyright (c) 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd August 1, 2019
29.Dt DU 1
30.Os
31.Sh NAME
32.Nm du
33.Nd display disk usage statistics
34.Sh SYNOPSIS
35.Nm
36.Op Fl Aclnx
37.Op Fl H | L | P
38.Op Fl g | h | k | m
39.Op Fl a | s | d Ar depth
40.Op Fl B Ar blocksize
41.Op Fl I Ar mask
42.Op Fl t Ar threshold
43.Op Ar
44.Sh DESCRIPTION
45The
46.Nm
47utility displays the file system block usage for each file argument
48and for each directory in the file hierarchy rooted in each directory
49argument.
50If no file is specified, the block usage of the hierarchy rooted in
51the current directory is displayed.
52.Pp
53The options are as follows:
54.Bl -tag -width indent
55.It Fl A
56Display the apparent size instead of the disk usage.
57This can be helpful when operating on compressed volumes or sparse files.
58.It Fl B Ar blocksize
59Calculate block counts in
60.Ar blocksize
61byte blocks.
62This is different from the
63.Fl h , k , m ,
64.Fl Fl si
65and
66.Fl g
67options or setting
68.Ev BLOCKSIZE
69and gives an estimate of how much space the examined file hierarchy would
70require on a filesystem with the given
71.Ar blocksize .
72Unless in
73.Fl A
74mode,
75.Ar blocksize
76is rounded up to the next multiple of 512.
77.It Fl H
78Symbolic links on the command line are followed, symbolic links in file
79hierarchies are not followed.
80.It Fl I Ar mask
81Ignore files and directories matching the specified
82.Ar mask .
83.It Fl L
84Symbolic links on the command line and in file hierarchies are followed.
85.It Fl P
86No symbolic links are followed.
87This is the default.
88.It Fl a
89Display an entry for each file in a file hierarchy.
90.It Fl c
91Display a grand total.
92.It Fl d Ar depth
93Display an entry for all files and directories
94.Ar depth
95directories deep.
96.It Fl g
97Display block counts in 1073741824-byte (1 GiB) blocks.
98.It Fl h
99.Dq Human-readable
100output.
101Use unit suffixes: Byte, Kilobyte, Megabyte,
102Gigabyte, Terabyte and Petabyte based on powers of 1024.
103.It Fl k
104Display block counts in 1024-byte (1 kiB) blocks.
105.It Fl l
106If a file has multiple hard links, count its size multiple times.
107The default behavior of
108.Nm
109is to count files with multiple hard links only once.
110When the
111.Fl l
112option is specified, the hard link checks are disabled, and these files
113are counted (and displayed) as many times as they are found.
114.It Fl m
115Display block counts in 1048576-byte (1 MiB) blocks.
116.It Fl n
117Ignore files and directories with user
118.Dq nodump
119flag
120.Pq Dv UF_NODUMP
121set.
122.It Fl r
123Generate messages about directories that cannot be read, files
124that cannot be opened, and so on.
125This is the default case.
126This option exists solely for conformance with
127.St -xpg4 .
128.It Fl s
129Display an entry for each specified file.
130(Equivalent to
131.Fl d Li 0 )
132.It Fl Fl si
133.Dq Human-readable
134output.
135Use unit suffixes: Byte, Kilobyte, Megabyte,
136Gigabyte, Terabyte and Petabyte based on powers of 1000.
137.It Fl t Ar threshold
138Display only entries for which size exceeds
139.Ar threshold .
140If
141.Ar threshold
142is negative, display only entries for which size is less than the absolute
143value of
144.Ar threshold .
145.It Fl x
146File system mount points are not traversed.
147.El
148.Pp
149The
150.Nm
151utility counts the storage used by symbolic links and not the files they
152reference unless the
153.Fl H
154or
155.Fl L
156option is specified.
157If either the
158.Fl H
159or
160.Fl L
161option is specified, storage used by any symbolic links which are
162followed is not counted (or displayed).
163The
164.Fl H ,
165.Fl L
166and
167.Fl P
168options override each other and the command's actions are determined
169by the last one specified.
170.Pp
171The
172.Fl h , k , m
173and
174.Fl Fl si
175options all override each other; the last one specified determines
176the block counts used.
177.Sh ENVIRONMENT
178.Bl -tag -width BLOCKSIZE
179.It Ev BLOCKSIZE
180If the environment variable
181.Ev BLOCKSIZE
182is set, and the
183.Fl h , k , m
184or
185.Fl Fl si
186options are not specified, the block counts will be displayed in units of
187that block size.
188If
189.Ev BLOCKSIZE
190is not set, and the
191.Fl h , k , m
192or
193.Fl Fl si
194options are not specified, the block counts will be displayed in 512-byte
195blocks.
196.El
197.Sh EXAMPLES
198Show disk usage for all files in the current directory.
199Output is in human-readable form:
200.Pp
201.Dl # du -ah
202.Pp
203Summarize disk usage in the current directory:
204.Pp
205.Dl # du -hs
206.Pp
207Summarize disk usage for a specific directory:
208.Pp
209.Dl # du -hs /home
210.Pp
211Show name and size of all C files in a specific directory.
212Also display a grand total at the end:
213.Pp
214.Dl # du -ch /usr/src/sys/kern/*.c
215.Sh SEE ALSO
216.Xr df 1 ,
217.Xr chflags 2 ,
218.Xr fts 3 ,
219.Xr symlink 7 ,
220.Xr quot 8
221.Sh STANDARDS
222The
223.Nm
224utility is compliant with the
225.St -p1003.1-2008
226specification.
227.Pp
228The flags
229.Op Fl cdhP ,
230as well as the
231.Ev BLOCKSIZE
232environment variable,
233are extensions to that specification.
234.Pp
235The flag
236.Op Fl r
237is accepted but ignored, for compatibility with systems implementing
238the obsolete
239.St -xcu5
240standard.
241.Sh HISTORY
242The
243.Nm
244utility and its
245.Fl a
246and
247.Fl s
248options first appeared in
249.At v1 .
250.Pp
251The
252.Fl r
253option first appeared in
254.At III
255and is available since
256.Fx 3.5 .
257The
258.Fl k
259and
260.Fl x
261options first appeared in
262.Bx 4.3 Reno
263and
264.Fl H
265in
266.Bx 4.4 .
267The
268.Fl c
269and
270.Fl L
271options first appeared in the GNU fileutils;
272.Fl L
273and
274.Fl P
275are available since
276.Bx 4.4 Lite1 ,
277.Fl c
278since
279.Fx 2.2.6 .
280The
281.Fl d
282option first appeared in
283.Fx 2.2 ,
284.Fl h
285first appeared in
286.Fx 4.0 .
287.Sh AUTHORS
288.An -nosplit
289This version of
290.Nm
291was written by
292.An Chris Newcomb
293for
294.Bx 4.3 Reno
295in 1989.
296