Print this page
7967 Want apparent size option for du(1)
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
   1 '\" te
   2 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
   3 .\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.

   4 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
   5 .\" http://www.opengroup.org/bookstore/.
   6 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
   7 .\"  This notice shall appear on any product containing this material.
   8 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   9 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
  10 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  11 .TH DU 1 "Feb 6, 2007"
  12 .SH NAME
  13 du \- summarize disk usage
  14 .SH SYNOPSIS
  15 .LP
  16 .nf
  17 \fB/usr/bin/du\fR [\fB-dorx\fR] [\fB-a\fR | \fB-s\fR] [\fB-h\fR | \fB-k\fR | \fB-m\fR] [\fB-H\fR | \fB-L\fR]
  18      [\fIfile\fR ...]
  19 .fi
  20 
  21 .LP
  22 .nf
  23 \fB/usr/xpg4/bin/du\fR [\fB-dorx\fR] [\fB-a\fR | \fB-s\fR] [\fB-h\fR | \fB-k\fR | \fB-m\fR] [\fB-H\fR | \fB-L\fR]
  24      [\fIfile\fR ...]
  25 .fi
  26 
  27 .SH DESCRIPTION
  28 .sp
  29 .LP
  30 The \fBdu\fR utility writes to standard output the size of the file space
  31 allocated to, and the size of the file space allocated to each subdirectory of,
  32 the file hierarchy rooted in each of the specified files. The size of the file
  33 space allocated to a file of type directory is defined as the sum total of
  34 space allocated to all files in the file hierarchy rooted in the directory plus
  35 the space allocated to the directory itself. This sum will include the space
  36 allocated to any extended attributes encountered.
  37 .sp
  38 .LP
  39 Files with multiple links will be counted and written for only one entry. The
  40 directory entry that is selected in the report is unspecified. By default, file
  41 sizes are written in 512-byte units, rounded up to the next 512-byte unit.
  42 .SS "/usr/xpg4/bin/du"
  43 .sp
  44 .LP
  45 When \fBdu\fR cannot obtain file attributes or read directories (see
  46 \fBstat\fR(2)), it will report an error condition and the final exit status
  47 will be affected.
  48 .SH OPTIONS
  49 .sp
  50 .LP
  51 The following options are supported for \fB/usr/bin/du\fR and
  52 \fB/usr/xpg4/bin/du\fR:
  53 .sp
  54 .ne 2
  55 .na
  56 \fB\fB-a\fR\fR
  57 .ad
  58 .RS 6n
  59 In addition to the default output, report the size of each file not of type
  60 directory in the file hierarchy rooted in the specified file. Regardless of the
  61 presence of the \fB-a\fR option, non-directories given as \fIfile\fR operands
  62 will always be listed.
  63 .RE
  64 
  65 .sp
  66 .ne 2
  67 .na











  68 \fB\fB-d\fR\fR
  69 .ad
  70 .RS 6n
  71 Do not cross filesystem boundaries. For example, the command, \fBdu -d /\fR
  72 reports usage only on the root partition.
  73 .RE
  74 
  75 .sp
  76 .ne 2
  77 .na
  78 \fB\fB-h\fR\fR
  79 .ad
  80 .RS 6n
  81 All sizes are scaled to a human readable format, for example, \fB14K\fR,
  82 \fB234M\fR, \fB2.7G\fR, or \fB3.0T\fR. Scaling is done by repetitively dividing
  83 by \fB1024\fR.
  84 .RE
  85 
  86 .sp
  87 .ne 2


 162 .ne 2
 163 .na
 164 \fB\fB-x\fR\fR
 165 .ad
 166 .RS 6n
 167 When evaluating file sizes, evaluate only those files that have the same device
 168 as the file specified by the file operand.
 169 .RE
 170 
 171 .sp
 172 .LP
 173 Specifying more than one of the options in the mutually exclusive pair,
 174 \fB-H\fR and \fB-L\fR, is not considered an error. The last option specified
 175 determines the output format.
 176 .sp
 177 .LP
 178 Specifying more than one of the options in the mutually exclusive set of
 179 options \fB-h\fR, \fB-k\fR, and \fB-m\fR is not considered an error.  The last
 180 option specified determines the output format.
 181 .SH OPERANDS
 182 .sp
 183 .LP
 184 The following operand is supported:
 185 .sp
 186 .ne 2
 187 .na
 188 \fB\fIfile\fR\fR
 189 .ad
 190 .RS 8n
 191 The path name of a file whose size is to be written. If no \fIfile\fR is
 192 specified, the current directory is used.
 193 .RE
 194 
 195 .SH OUTPUT
 196 .sp
 197 .LP
 198 The output from \fBdu\fR consists of the amount of the space allocated to a
 199 file and the name of the file.
 200 .SH USAGE
 201 .sp
 202 .LP
 203 See \fBlargefile\fR(5) for the description of the behavior of \fBdu\fR when
 204 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
 205 .SH ENVIRONMENT VARIABLES
 206 .sp
 207 .LP
 208 See \fBenviron\fR(5) for descriptions of the following environment variables
 209 that affect the execution of \fBdu\fR: \fBLANG\fR, \fBLC_ALL\fR,
 210 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
 211 .SH EXIT STATUS
 212 .sp
 213 .LP
 214 The following exit values are returned:
 215 .sp
 216 .ne 2
 217 .na
 218 \fB\fB0\fR\fR
 219 .ad
 220 .RS 6n
 221 Successful completion.
 222 .RE
 223 
 224 .sp
 225 .ne 2
 226 .na
 227 \fB\fB>0\fR\fI\fR\fR
 228 .ad
 229 .RS 6n
 230 An error occurred.
 231 .RE
 232 
 233 .SH ATTRIBUTES
 234 .sp
 235 .LP
 236 See \fBattributes\fR(5) for descriptions of the following attributes:
 237 .SS "/usr/bin/du"
 238 .sp
 239 
 240 .sp
 241 .TS
 242 box;
 243 c | c
 244 l | l .
 245 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 246 _
 247 CSI     Enabled
 248 _
 249 Interface Stability     Stable
 250 .TE
 251 
 252 .SS "/usr/xpg4/bin/du"
 253 .sp
 254 
 255 .sp
 256 .TS
 257 box;
 258 c | c
 259 l | l .
 260 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 261 _
 262 CSI     Enabled
 263 _
 264 Interface Stability     Standard
 265 .TE
 266 
 267 .SH SEE ALSO
 268 .sp
 269 .LP
 270 \fBls\fR(1), \fBstat\fR(2), \fBattributes\fR(5), \fBenviron\fR(5),
 271 \fBfsattr\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)
 272 .sp
 273 .LP
 274 \fISystem Administration Guide: Basic Administration\fR
 275 .SH NOTES
 276 .sp
 277 .LP
 278 A file with two or more links is counted only once. If, however, there are
 279 links between files in different directories where the directories are on
 280 separate branches of the file system hierarchy, \fBdu\fR will count the excess
 281 files more than once.
 282 .sp
 283 .LP
 284 Files containing holes will result in an incorrect block count.


   1 '\" te
   2 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
   3 .\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
   4 .\" Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved.
   5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
   6 .\" http://www.opengroup.org/bookstore/.
   7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
   8 .\"  This notice shall appear on any product containing this material.
   9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
  10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
  11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  12 .TH DU 1 "March 14, 2017"
  13 .SH NAME
  14 du \- summarize disk usage
  15 .SH SYNOPSIS
  16 .LP
  17 .nf
  18 \fB/usr/bin/du\fR [\fB-Adorx\fR] [\fB-a\fR | \fB-s\fR] [\fB-h\fR | \fB-k\fR | \fB-m\fR] [\fB-H\fR | \fB-L\fR]
  19      [\fIfile\fR ...]
  20 .fi
  21 
  22 .LP
  23 .nf
  24 \fB/usr/xpg4/bin/du\fR [\fB-Adorx\fR] [\fB-a\fR | \fB-s\fR] [\fB-h\fR | \fB-k\fR | \fB-m\fR] [\fB-H\fR | \fB-L\fR]
  25      [\fIfile\fR ...]
  26 .fi
  27 
  28 .SH DESCRIPTION

  29 .LP
  30 The \fBdu\fR utility writes to standard output the size of the file space
  31 allocated to, and the size of the file space allocated to each subdirectory of,
  32 the file hierarchy rooted in each of the specified files. The size of the file
  33 space allocated to a file of type directory is defined as the sum total of
  34 space allocated to all files in the file hierarchy rooted in the directory plus
  35 the space allocated to the directory itself. This sum will include the space
  36 allocated to any extended attributes encountered.

  37 .LP
  38 Files with multiple links will be counted and written for only one entry. The
  39 directory entry that is selected in the report is unspecified. By default, file
  40 sizes are written in 512-byte units, rounded up to the next 512-byte unit.
  41 .SS "/usr/xpg4/bin/du"

  42 .LP
  43 When \fBdu\fR cannot obtain file attributes or read directories (see
  44 \fBstat\fR(2)), it will report an error condition and the final exit status
  45 will be affected.
  46 .SH OPTIONS

  47 .LP
  48 The following options are supported for \fB/usr/bin/du\fR and
  49 \fB/usr/xpg4/bin/du\fR:
  50 .sp
  51 .ne 2
  52 .na
  53 \fB\fB-a\fR\fR
  54 .ad
  55 .RS 6n
  56 In addition to the default output, report the size of each file not of type
  57 directory in the file hierarchy rooted in the specified file. Regardless of the
  58 presence of the \fB-a\fR option, non-directories given as \fIfile\fR operands
  59 will always be listed.
  60 .RE
  61 
  62 .sp
  63 .ne 2
  64 .na
  65 \fB\fB-A\fR\fR
  66 .ad
  67 .RS 6n
  68 Tally file size using the apparent size of the file instead of the disk blocks
  69 it occupies. This option is useful when operating on file systems which employ
  70 compression or in the presence of sparse files.
  71 .RE
  72 
  73 .sp
  74 .ne 2
  75 .na
  76 \fB\fB-d\fR\fR
  77 .ad
  78 .RS 6n
  79 Do not cross filesystem boundaries. For example, the command, \fBdu -d /\fR
  80 reports usage only on the root partition.
  81 .RE
  82 
  83 .sp
  84 .ne 2
  85 .na
  86 \fB\fB-h\fR\fR
  87 .ad
  88 .RS 6n
  89 All sizes are scaled to a human readable format, for example, \fB14K\fR,
  90 \fB234M\fR, \fB2.7G\fR, or \fB3.0T\fR. Scaling is done by repetitively dividing
  91 by \fB1024\fR.
  92 .RE
  93 
  94 .sp
  95 .ne 2


 170 .ne 2
 171 .na
 172 \fB\fB-x\fR\fR
 173 .ad
 174 .RS 6n
 175 When evaluating file sizes, evaluate only those files that have the same device
 176 as the file specified by the file operand.
 177 .RE
 178 
 179 .sp
 180 .LP
 181 Specifying more than one of the options in the mutually exclusive pair,
 182 \fB-H\fR and \fB-L\fR, is not considered an error. The last option specified
 183 determines the output format.
 184 .sp
 185 .LP
 186 Specifying more than one of the options in the mutually exclusive set of
 187 options \fB-h\fR, \fB-k\fR, and \fB-m\fR is not considered an error.  The last
 188 option specified determines the output format.
 189 .SH OPERANDS

 190 .LP
 191 The following operand is supported:
 192 .sp
 193 .ne 2
 194 .na
 195 \fB\fIfile\fR\fR
 196 .ad
 197 .RS 8n
 198 The path name of a file whose size is to be written. If no \fIfile\fR is
 199 specified, the current directory is used.
 200 .RE

 201 .SH OUTPUT

 202 .LP
 203 The output from \fBdu\fR consists of the amount of the space allocated to a
 204 file and the name of the file.
 205 .SH USAGE

 206 .LP
 207 See \fBlargefile\fR(5) for the description of the behavior of \fBdu\fR when
 208 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
 209 .SH ENVIRONMENT VARIABLES

 210 .LP
 211 See \fBenviron\fR(5) for descriptions of the following environment variables
 212 that affect the execution of \fBdu\fR: \fBLANG\fR, \fBLC_ALL\fR,
 213 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
 214 .SH EXIT STATUS

 215 .LP
 216 The following exit values are returned:
 217 .sp
 218 .ne 2
 219 .na
 220 \fB\fB0\fR\fR
 221 .ad
 222 .RS 6n
 223 Successful completion.
 224 .RE

 225 .sp
 226 .ne 2
 227 .na
 228 \fB\fB>0\fR\fI\fR\fR
 229 .ad
 230 .RS 6n
 231 An error occurred.
 232 .RE

 233 .SH ATTRIBUTES

 234 .LP
 235 See \fBattributes\fR(5) for descriptions of the following attributes:
 236 .SS "/usr/bin/du"

 237 

 238 .TS
 239 box;
 240 c | c
 241 l | l .
 242 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 243 _
 244 CSI     Enabled
 245 _
 246 Interface Stability     Stable
 247 .TE
 248 
 249 .SS "/usr/xpg4/bin/du"

 250 

 251 .TS
 252 box;
 253 c | c
 254 l | l .
 255 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 256 _
 257 CSI     Enabled
 258 _
 259 Interface Stability     Standard
 260 .TE
 261 
 262 .SH SEE ALSO

 263 .LP
 264 \fBls\fR(1), \fBstat\fR(2), \fBattributes\fR(5), \fBenviron\fR(5),
 265 \fBfsattr\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)

 266 .LP
 267 \fISystem Administration Guide: Basic Administration\fR
 268 .SH NOTES

 269 .LP
 270 A file with two or more links is counted only once. If, however, there are
 271 links between files in different directories where the directories are on
 272 separate branches of the file system hierarchy, \fBdu\fR will count the excess
 273 files more than once.

 274 .LP
 275 Files containing holes will result in an incorrect block count. In this case,
 276 one may use the \fB-A\fR option to report file sizes by their apparent size
 277 instead.