1.\" $OpenBSD: du.1,v 1.39 2022/09/07 00:46:20 jsg Exp $ 2.\" $NetBSD: du.1,v 1.6 1996/10/18 07:20:31 thorpej Exp $ 3.\" 4.\" Copyright (c) 1990, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)du.1 8.2 (Berkeley) 4/1/94 32.\" 33.Dd $Mdocdate: September 7 2022 $ 34.Dt DU 1 35.Os 36.Sh NAME 37.Nm du 38.Nd display disk usage statistics 39.Sh SYNOPSIS 40.Nm du 41.Op Fl achkrsx 42.Op Fl H | L | P 43.Op Fl d Ar depth 44.Op Ar 45.Sh DESCRIPTION 46The 47.Nm 48utility displays the file system block usage for each 49.Ar file 50argument 51and for each directory in the file hierarchy rooted in each directory 52argument. 53Note that the system block usage is usually greater than 54the actual size of the file. 55If no file is specified, the block usage of the hierarchy rooted in 56the current directory is displayed. 57.Pp 58The options are as follows: 59.Bl -tag -width Ds 60.It Fl a 61Display entries for files in addition to entries for directories. 62.It Fl c 63Display the grand total after all the arguments have been processed. 64.It Fl d Ar depth 65Do not display entries for files and directories more than 66.Ar depth 67levels deep; 68.Fl d Cm 0 69has the same effect as 70.Fl s . 71Overrides earlier 72.Fl d 73and 74.Fl s 75options. 76.It Fl H 77Symbolic links on the command line are followed. 78Symbolic links encountered in the tree traversal are not followed. 79.It Fl h 80"Human-readable" output. 81Use unit suffixes: Byte, Kilobyte, Megabyte, 82Gigabyte, Terabyte, Petabyte, Exabyte in order to reduce the number of 83digits to four or less. 84.It Fl k 85By default, all sizes are reported in 512-byte block counts. 86The 87.Fl k 88option causes the numbers to be reported in kilobyte counts. 89.It Fl L 90All symbolic links are followed. 91.It Fl P 92No symbolic links are followed. 93.It Fl r 94Generate messages about directories that cannot be read, files 95that cannot be opened, and so on. 96This is the default. 97.It Fl s 98Display only the total for each of the specified files and directories. 99Overrides earlier 100.Fl d 101options. 102.It Fl x 103File system mount points are not traversed. 104.El 105.Pp 106It is not an error to specify more than one of 107the mutually exclusive options 108.Fl h 109and 110.Fl k . 111Where more than one of these options is specified, 112the last option given overrides the others. 113.Pp 114.Nm 115counts the storage used by symbolic links and not the files they 116reference unless the 117.Fl H 118or 119.Fl L 120option is specified. 121If either the 122.Fl H 123or 124.Fl L 125options are specified, storage used by any symbolic links which are 126followed is not counted or displayed. 127The 128.Fl H , 129.Fl L , 130and 131.Fl P 132options override each other and the command's actions are determined 133by the last one specified. 134.Pp 135Files having multiple hard links are counted (and displayed) a single 136time per 137.Nm 138execution. 139.Sh ENVIRONMENT 140.Bl -tag -width BLOCKSIZE 141.It Ev BLOCKSIZE 142Block counts will be displayed in units of this size block, unless the 143.Fl k 144or 145.Fl h 146option is specified. 147.El 148.Sh EXIT STATUS 149.Ex -std du 150.Sh EXAMPLES 151Display a summary of files and folders in the current directory, 152sorted by size: 153.Pp 154.Dl $ du -had 1 | sort -h 155.Sh SEE ALSO 156.Xr df 1 , 157.Xr fts_open 3 , 158.Xr symlink 7 , 159.Xr quot 8 160.Sh STANDARDS 161The 162.Nm 163utility is compliant with the 164.St -p1003.1-2008 165specification. 166.Pp 167The flags 168.Op Fl cdhP , 169as well as the 170.Ev BLOCKSIZE 171environment variable, 172are extensions to that specification. 173.Pp 174The flag 175.Op Fl r 176is accepted but ignored, for compatibility with systems implementing 177the obsolete 178.St -xcu5 179standard. 180.Sh HISTORY 181The 182.Nm 183utility first appeared in 184.At v1 . 185.Sh AUTHORS 186.An -nosplit 187This version of 188.Nm 189was written by 190.An Chris Newcomb 191for 192.Bx 4.3 Reno 193in 1989 and incorporates later contributions from 194.An Elan Amir , 195.An Keith Bostic , 196.An Luke Mewburn , 197.An Matt Bing , 198and 199.An Can Erkin Acar Aq Mt canacar@openbsd.org . 200