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