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