{
    "mode": "info",
    "parameter": "du",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/du/json",
    "generated": "2026-11-09T22:55:24Z",
    "sections": {
        "File: coreutils.info,  Node: du invocation,  Next: stat invocation,  Prev: df invocation,  Up: File space usage": {
            "content": "",
            "subsections": [
                {
                    "name": "14.2 'du': Estimate file space usage",
                    "content": "'du' reports the space needed to represent a set of files.  Synopsis:\n\ndu [OPTION]... [FILE]...\n\nWith no arguments, 'du' reports the space needed to represent the\nfiles at or under the current directory.  Normally the space is printed\nin units of 1024 bytes, but this can be overridden (*note Block size::).\nNon-integer quantities are rounded up to the next higher unit.\n\nIf two or more hard links point to the same file, only one of the\nhard links is counted.  The FILE argument order affects which links are\ncounted, and changing the argument order may change the numbers and\nentries that 'du' outputs.\n\nThe program accepts the following options.  Also see *note Common\noptions::.\n\n'-0'\n'--null'\nOutput a zero byte (ASCII NUL) at the end of each line, rather than\na newline.  This option enables other programs to parse the output\neven when that output would contain data with embedded newlines.\n\n'-a'\n'--all'\nShow counts for all files, not just directories.\n\n'--apparent-size'\nPrint apparent sizes, rather than file system usage.  The apparent\nsize of a file is the number of bytes reported by 'wc -c' on\nregular files, or more generally, 'ls -l --block-size=1' or 'stat\n--format=%s'.  For example, a file containing the word 'zoo' with\nno newline would, of course, have an apparent size of 3.  Such a\nsmall file may require anywhere from 0 to 16 KiB or more of file\nsystem space, depending on the type and configuration of the file\nsystem on which the file resides.  However, a sparse file created\nwith this command:\n\ndd bs=1 seek=2GiB if=/dev/null of=big\n\nhas an apparent size of 2 GiB, yet on most modern file systems, it\nactually uses almost no space.\n\nApparent sizes are meaningful only for regular files and symbolic\nlinks.  Other file types do not contribute to apparent size.\n\n'-B SIZE'\n'--block-size=SIZE'\nScale sizes by SIZE before printing them (*note Block size::).  For\nexample, '-BG' prints sizes in units of 1,073,741,824 bytes.\n\n'-b'\n'--bytes'\nEquivalent to '--apparent-size --block-size=1'.\n\n'-c'\n'--total'\nPrint a grand total of all arguments after all arguments have been\nprocessed.  This can be used to find out the total file system\nusage of a given set of files or directories.\n\n'-D'\n'--dereference-args'\nDereference symbolic links that are command line arguments.  Does\nnot affect other symbolic links.  This is helpful for finding out\nthe file system usage of directories, such as '/usr/tmp', which are\noften symbolic links.\n\n'-d DEPTH'\n'--max-depth=DEPTH'\nShow the total for each directory (and file if '--all') that is at\nmost MAXDEPTH levels down from the root of the hierarchy.  The\nroot is at level 0, so 'du --max-depth=0' is equivalent to 'du -s'.\n\n'--files0-from=FILE'\nDisallow processing files named on the command line, and instead\nprocess those named in file FILE; each name being terminated by a\nzero byte (ASCII NUL). This is useful when the list of file names\nis so long that it may exceed a command line length limitation.  In\nsuch cases, running 'du' via 'xargs' is undesirable because it\nsplits the list into pieces and makes 'du' print with the '--total'\n('-c') option for each sublist rather than for the entire list.\nOne way to produce a list of ASCII NUL terminated file names is\nwith GNU 'find', using its '-print0' predicate.  If FILE is '-'\nthen the ASCII NUL terminated file names are read from standard\ninput.\n\n'-H'\nEquivalent to '--dereference-args' ('-D').\n\n'-h'\n'--human-readable'\nAppend a size letter to each size, such as 'M' for mebibytes.\nPowers of 1024 are used, not 1000; 'M' stands for 1,048,576 bytes.\nThis option is equivalent to '--block-size=human-readable'.  Use\nthe '--si' option if you prefer powers of 1000.\n\n'--inodes'\nList inode usage information instead of block usage.  This option\nis useful for finding directories which contain many files, and\ntherefore eat up most of the inodes space of a file system (see\n'df', option '--inodes').  It can well be combined with the options\n'-a', '-c', '-h', '-l', '-s', '-S', '-t' and '-x'; however, passing\nother options regarding the block size, for example '-b', '-m' and\n'--apparent-size', is ignored.\n\n'-k'\nPrint sizes in 1024-byte blocks, overriding the default block size\n(*note Block size::).  This option is equivalent to\n'--block-size=1K'.\n\n'-L'\n'--dereference'\nDereference symbolic links (show the file system space used by the\nfile or directory that the link points to instead of the space used\nby the link).\n\n'-l'\n'--count-links'\nCount the size of all files, even if they have appeared already (as\na hard link).\n\n'-m'\nPrint sizes in 1,048,576-byte blocks, overriding the default block\nsize (*note Block size::).  This option is equivalent to\n'--block-size=1M'.\n\n'-P'\n'--no-dereference'\nFor each symbolic link encountered by 'du', consider the file\nsystem space used by the symbolic link itself.\n\n'-S'\n'--separate-dirs'\nNormally, in the output of 'du' (when not using '--summarize'), the\nsize listed next to a directory name, D, represents the sum of\nsizes of all entries beneath D as well as the size of D itself.\nWith '--separate-dirs', the size reported for a directory name, D,\nwill exclude the size of any subdirectories.\n\n'--si'\nAppend an SI-style abbreviation to each size, such as 'M' for\nmegabytes.  Powers of 1000 are used, not 1024; 'M' stands for\n1,000,000 bytes.  This option is equivalent to '--block-size=si'.\nUse the '-h' or '--human-readable' option if you prefer powers of\n1024.\n\n'-s'\n'--summarize'\nDisplay only a total for each argument.\n\n'-t SIZE'\n'--threshold=SIZE'\nExclude entries based on a given SIZE.  The SIZE refers to used\nblocks in normal mode (*note Block size::), or inodes count in\nconjunction with the '--inodes' option.\n\nIf SIZE is positive, then 'du' will only print entries with a size\ngreater than or equal to that.\n\nIf SIZE is negative, then 'du' will only print entries with a size\nsmaller than or equal to that.\n\nAlthough GNU 'find' can be used to find files of a certain size,\n'du''s '--threshold' option can be used to also filter directories\nbased on a given size.\n\nWhen combined with the '--apparent-size' option, the '--threshold'\noption elides entries based on apparent size.  When combined with\nthe '--inodes' option, it elides entries based on inode counts.\n\nHere's how you would use '--threshold' to find directories with a\nsize greater than or equal to 200 megabytes:\n\ndu --threshold=200MB\n\nHere's how you would use '--threshold' to find directories and\nfiles - note the '-a' - with an apparent size smaller than or equal\nto 500 bytes:\n\ndu -a -t -500 --apparent-size\n\nHere's how you would use '--threshold' to find directories on the\nroot file system with more than 20000 inodes used in the directory\ntree below:\n\ndu --inodes -x --threshold=20000 /\n\n'--time'\nShow the most recent modification timestamp (mtime) of any file in\nthe directory, or any of its subdirectories.  *Note File\ntimestamps::.\n\n'--time=ctime'\n'--time=status'\n'--time=use'\nShow the most recent status change timestamp (ctime) of any file in\nthe directory, or any of its subdirectories.  *Note File\ntimestamps::.\n\n'--time=atime'\n'--time=access'\nShow the most recent access timestamp (atime) of any file in the\ndirectory, or any of its subdirectories.  *Note File timestamps::.\n\n'--time-style=STYLE'\nList timestamps in style STYLE.  This option has an effect only if\nthe '--time' option is also specified.  The STYLE should be one of\nthe following:\n\n'+FORMAT'\nList timestamps using FORMAT, where FORMAT is interpreted like\nthe format argument of 'date' (*note date invocation::).  For\nexample, '--time-style=\"+%Y-%m-%d %H:%M:%S\"' causes 'du' to\nlist timestamps like '2020-07-21 23:45:56'.  As with 'date',\nFORMAT's interpretation is affected by the 'LCTIME' locale\ncategory.\n\n'full-iso'\nList timestamps in full using ISO 8601-like date, time, and\ntime zone components with nanosecond precision, e.g.,\n'2020-07-21 23:45:56.477817180 -0400'.  This style is\nequivalent to '+%Y-%m-%d %H:%M:%S.%N %z'.\n\n'long-iso'\nList ISO 8601 date and time components with minute precision,\ne.g., '2020-07-21 23:45'.  These timestamps are shorter than\n'full-iso' timestamps, and are usually good enough for\neveryday work.  This style is equivalent to '+%Y-%m-%d %H:%M'.\n\n'iso'\nList ISO 8601 dates for timestamps, e.g., '2020-07-21'.  This\nstyle is equivalent to '+%Y-%m-%d'.\n\nYou can specify the default value of the '--time-style' option with\nthe environment variable 'TIMESTYLE'; if 'TIMESTYLE' is not set\nthe default style is 'long-iso'.  For compatibility with 'ls', if\n'TIMESTYLE' begins with '+' and contains a newline, the newline\nand any later characters are ignored; if 'TIMESTYLE' begins with\n'posix-' the 'posix-' is ignored; and if 'TIMESTYLE' is 'locale'\nit is ignored.\n\n'-X FILE'\n'--exclude-from=FILE'\nLike '--exclude', except take the patterns to exclude from FILE,\none per line.  If FILE is '-', take the patterns from standard\ninput.\n\n'--exclude=PATTERN'\nWhen recursing, skip subdirectories or files matching PATTERN.  For\nexample, 'du --exclude='*.o'' excludes files whose names end in\n'.o'.\n\n'-x'\n'--one-file-system'\nSkip directories that are on different file systems from the one\nthat the argument being processed is on.\n\nSince 'du' relies on information reported by the operating system,\nits output might not reflect the space consumed in the underlying\ndevices.  For example;\n\n* Operating systems normally do not report device space consumed by\nduplicate or backup blocks, error correction bits, and so forth.\nThis causes 'du' to underestimate the device space actually used.\n\n* In file systems that use copy-on-write, if two distinct files share\nspace the output of 'du' typically counts the space that would be\nconsumed if all files' non-holes were rewritten, not the space\ncurrently consumed.\n\n* In file systems that use compression, the operating system might\nreport the uncompressed space.  (If it does report the compressed\nspace, that report might change after one merely overwrites\nexisting file data.)\n\n* Networked file systems historically have had difficulty\ncommunicating accurate file system information from server to\nclient.\n"
                }
            ]
        },
        "For these reasons 'du' might better be thought of as an estimate of the": {
            "content": "size of a 'tar' or other conventional backup for a set of files, rather\nthan as a measure of space consumed in the underlying devices.\n\nAn exit status of zero indicates success, and a nonzero value\nindicates failure.\n",
            "subsections": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}