]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/du/du.1
zfs: merge openzfs/zfs@a4bf6baae
[FreeBSD/FreeBSD.git] / usr.bin / du / du.1
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
45 The
46 .Nm
47 utility displays the file system block usage for each file argument
48 and for each directory in the file hierarchy rooted in each directory
49 argument.
50 If no file is specified, the block usage of the hierarchy rooted in
51 the current directory is displayed.
52 .Pp
53 The options are as follows:
54 .Bl -tag -width indent
55 .It Fl A
56 Display the apparent size instead of the disk usage.
57 This can be helpful when operating on compressed volumes or sparse files.
58 .It Fl B Ar blocksize
59 Calculate block counts in
60 .Ar blocksize
61 byte blocks.
62 This is different from the
63 .Fl h , k , m ,
64 .Fl Fl si
65 and
66 .Fl g
67 options or setting
68 .Ev BLOCKSIZE
69 and gives an estimate of how much space the examined file hierarchy would
70 require on a filesystem with the given
71 .Ar blocksize .
72 Unless in
73 .Fl A
74 mode,
75 .Ar blocksize
76 is rounded up to the next multiple of 512.
77 .It Fl H
78 Symbolic links on the command line are followed, symbolic links in file
79 hierarchies are not followed.
80 .It Fl I Ar mask
81 Ignore files and directories matching the specified
82 .Ar mask .
83 .It Fl L
84 Symbolic links on the command line and in file hierarchies are followed.
85 .It Fl P
86 No symbolic links are followed.
87 This is the default.
88 .It Fl a
89 Display an entry for each file in a file hierarchy.
90 .It Fl c
91 Display a grand total.
92 .It Fl d Ar depth
93 Display an entry for all files and directories
94 .Ar depth
95 directories deep.
96 .It Fl g
97 Display block counts in 1073741824-byte (1 GiB) blocks.
98 .It Fl h
99 .Dq Human-readable
100 output.
101 Use unit suffixes: Byte, Kilobyte, Megabyte,
102 Gigabyte, Terabyte and Petabyte based on powers of 1024.
103 .It Fl k
104 Display block counts in 1024-byte (1 kiB) blocks.
105 .It Fl l
106 If a file has multiple hard links, count its size multiple times.
107 The default behavior of
108 .Nm
109 is to count files with multiple hard links only once.
110 When the
111 .Fl l
112 option is specified, the hard link checks are disabled, and these files
113 are counted (and displayed) as many times as they are found.
114 .It Fl m
115 Display block counts in 1048576-byte (1 MiB) blocks.
116 .It Fl n
117 Ignore files and directories with user
118 .Dq nodump
119 flag
120 .Pq Dv UF_NODUMP
121 set.
122 .It Fl r
123 Generate messages about directories that cannot be read, files
124 that cannot be opened, and so on.
125 This is the default case.
126 This option exists solely for conformance with
127 .St -xpg4 .
128 .It Fl s
129 Display an entry for each specified file.
130 (Equivalent to
131 .Fl d Li 0 )
132 .It Fl Fl si
133 .Dq Human-readable
134 output.
135 Use unit suffixes: Byte, Kilobyte, Megabyte,
136 Gigabyte, Terabyte and Petabyte based on powers of 1000.
137 .It Fl t Ar threshold
138 Display only entries for which size exceeds
139 .Ar threshold .
140 If
141 .Ar threshold
142 is negative, display only entries for which size is less than the absolute
143 value of
144 .Ar threshold .
145 .It Fl x
146 File system mount points are not traversed.
147 .El
148 .Pp
149 The
150 .Nm
151 utility counts the storage used by symbolic links and not the files they
152 reference unless the
153 .Fl H
154 or
155 .Fl L
156 option is specified.
157 If either the
158 .Fl H
159 or
160 .Fl L
161 option is specified, storage used by any symbolic links which are
162 followed is not counted (or displayed).
163 The
164 .Fl H ,
165 .Fl L
166 and
167 .Fl P
168 options override each other and the command's actions are determined
169 by the last one specified.
170 .Pp
171 The
172 .Fl h , k , m
173 and
174 .Fl Fl si
175 options all override each other; the last one specified determines
176 the block counts used.
177 .Sh ENVIRONMENT
178 .Bl -tag -width BLOCKSIZE
179 .It Ev BLOCKSIZE
180 If the environment variable
181 .Ev BLOCKSIZE
182 is set, and the
183 .Fl h , k , m
184 or
185 .Fl Fl si
186 options are not specified, the block counts will be displayed in units of
187 that block size.
188 If
189 .Ev BLOCKSIZE
190 is not set, and the
191 .Fl h , k , m
192 or
193 .Fl Fl si
194 options are not specified, the block counts will be displayed in 512-byte
195 blocks.
196 .El
197 .Sh EXAMPLES
198 Show disk usage for all files in the current directory.
199 Output is in human-readable form:
200 .Pp
201 .Dl # du -ah
202 .Pp
203 Summarize disk usage in the current directory:
204 .Pp
205 .Dl # du -hs
206 .Pp
207 Summarize disk usage for a specific directory:
208 .Pp
209 .Dl # du -hs /home
210 .Pp
211 Show name and size of all C files in a specific directory.
212 Also 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
222 The
223 .Nm
224 utility is compliant with the
225 .St -p1003.1-2008
226 specification.
227 .Pp
228 The flags
229 .Op Fl cdhP ,
230 as well as the
231 .Ev BLOCKSIZE
232 environment variable,
233 are extensions to that specification.
234 .Pp
235 The flag
236 .Op Fl r
237 is accepted but ignored, for compatibility with systems implementing
238 the obsolete
239 .St -xcu5
240 standard.
241 .Sh HISTORY
242 The
243 .Nm
244 utility and its
245 .Fl a
246 and
247 .Fl s
248 options first appeared in
249 .At v1 .
250 .Pp
251 The
252 .Fl r
253 option first appeared in
254 .At III
255 and is available since
256 .Fx 3.5 .
257 The
258 .Fl k
259 and
260 .Fl x
261 options first appeared in
262 .Bx 4.3 Reno
263 and
264 .Fl H
265 in
266 .Bx 4.4 .
267 The
268 .Fl c
269 and
270 .Fl L
271 options first appeared in the GNU fileutils;
272 .Fl L
273 and
274 .Fl P
275 are available since
276 .Bx 4.4 Lite1 ,
277 .Fl c
278 since
279 .Fx 2.2.6 .
280 The
281 .Fl d
282 option first appeared in
283 .Fx 2.2 ,
284 .Fl h
285 first appeared in
286 .Fx 4.0 .
287 .Sh AUTHORS
288 .An -nosplit
289 This version of
290 .Nm
291 was written by
292 .An Chris Newcomb
293 for
294 .Bx 4.3 Reno
295 in 1989.