Estimate file space usage
du -0 {null} -a {all} -A {apparent-size} -B {block-size} -b {bytes} ๐ null ๐ all ๐ apparent-size ๐ block-size ๐ bytes du -0 {null} -a {all} -A {apparent-size} -B {block-size} -b {bytes} Sandbox: execFile · Timeout: 30s
system.storage.du system.storage.usage system.storage.mount | Name | Type | Required | Default | Description | Aliases |
|---|---|---|---|---|---|
null | string | No | - | end each output line with NUL, not newline | -0, --null |
all | string | No | - | write counts for all files, not just directories | -a, --all |
apparent-size | string | No | - | print apparent sizes rather than device usage; although the apparent size is usually smaller, it may be larger due to holes in ('sparse') files, internal fragmentation, indirect blocks, etc | -A, --apparent-size |
block-size | integer | No | - | scale sizes by SIZE before printing them; See SIZE format below; E.g., '-BM' prints sizes in units of 1,048,576 bytes | -B, --block-size |
bytes | string | No | - | equivalent to '--apparent-size --block-size=1' | -b, --bytes |
total | string | No | - | produce a grand total | -c, --total |
dereference-args | string | No | - | dereference only symlinks that are listed on the command line | -D, --dereference-args |
max-depth | integer | No | - | print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument; --max-depth=0 is the same as --summarize --files0-from=F summarize device usag... | -d, --max-depth |
flag-H | string | No | - | equivalent to --dereference-args (-D) | -H |
human-readable | string | No | - | print sizes in human readable format (e.g., 1K 234M 2G) --inodes list inode usage information instead of block usage | -h, --human-readable |
flag-k | string | No | - | like --block-size=1K | -k |
dereference | string | No | - | dereference all symbolic links | -L, --dereference |
count-links | string | No | - | count sizes many times if hard linked | -l, --count-links |
flag-m | string | No | - | like --block-size=1M | -m |
no-dereference | string | No | - | don't follow any symbolic links (this is the default) | -P, --no-dereference |
separate-dirs | string | No | - | for directories do not include size of subdirectories --si like -h, but use powers of 1000 not 1024 | -S, --separate-dirs |
summarize | string | No | - | display only a total for each argument | -s, --summarize |
threshold | integer | No | - | exclude entries smaller than SIZE if positive, or entries greater than SIZE if negative --time show time of the last modification of any file in the directory, or any of its subdirectories --time=W... | -t, --threshold |
exclude-from | file | No | - | exclude files that match any pattern in FILE --exclude=PATTERN exclude files that match PATTERN | -X, --exclude-from |
one-file-system | string | No | - | skip directories on different file systems --help display this help and exit --version output version information and exit | -x, --one-file-system |
files0_from | boolean | No | - | --files0-from | |
help | boolean | No | - | --help | |
inodes | boolean | No | - | --inodes | |
null | string | No | - | end each output line with NUL, not newline | -0, --null |
si | boolean | No | - | --si | |
time | boolean | No | - | --time | |
time_style | boolean | No | - | --time-style | |
version | boolean | No | - | --version |
Basic usage with null
du ${null} Display help message
du --help With 'root' privileges, use du(1), sort(1), and head(1) to display a list of the top 20 space-consuming files in whichever storage medium '/' is mounted. Here, du(1) is using the `-x` flag to keep to the one filesystem, which is important for getting accurate results on the filesystem on which you might, for example, be needing to free space. In order to sort the human-readable file sizes, sort(1) is using the `-h` flag, the `-k` flag to specify the column to sort (first), and its using the `-r` flag to reverse the sorting, so we see the highest size first. To then show the top-20 lines, we use head(1) and specify the number of lines via the `-n` flag. The default number of lines displayed by head(1) and tail(1) is 10. Root privileges are gained for this task by using sudo(8) on bash(1) in order to have a new root-owned BASH session, which then executes the commands proceeding the `-c` flag.
sudo bash -c 'du -xh / | sort -rhk 1 | head -n 20' Display just the total human-readable size of the current working directory.
du -sh Display the total human-readable size of the three provided directories, as well as the grand total of the combined directories.
du -chs ~/Desktop ~/Pictures ~/Videos You could potentially make this task a bit easier with BASH brace expansion.
du -chs ~/{Desktop,Pictures,Videos} du is a command-line utility for estimate file space usage.
du -0 {null} -a {all} -A {apparent-size} -B {block-size} -b {bytes}