du (Disk Usage) Command in Linux

In short, "du"(Disk Usage) is command Linux / Unix we can check the volume occupied (information use) hard disk de folders si files.
An order very useful especially when we are limited by Hard disk space - or SSD - And we want to find out quickly that files and / or folders the "voluminous". Of course, command "du" It can be used in a variety of syntaxes that we use the information desired return.

Command line syntax "Du" is very simple and very flexible, as are all linux commands.

In order documentation "du", we are given the following options:

[[Email protected]] # du –help
Usage: from [OPTION]… [FILE]…
or: du [OPTION]… -files0-from = F
Summarize disk usage of each FILE, recursively for directories.

Mandatory arguments to long options is mandatory for short options too.
-a, –all write counts for all files, not just directories
–Apparent-size print apparent sizes, rather than disk usage; although the apparent size is usually smaller, it may be larger due to holes in (`sparse ') files, internal fragmentation, indirect blocks, and the like
-B, -block-Size = SIZE use SIZE-byte blocks
-b, -bytes equivalent to `-apparent-size -block-size = 1 '
-c, -total produce a grand total
-D, -dereference-Args dereference only symlinks That is Listed on the command line
–files0-from = F summarize disk usage of the NUL-terminated file names specified in file F;
If F is - the then read names from standard input
-H Equivalent to -dereference-args (-D)
-h, -human-readable print sizes in human readable format (eg, 1K 234M 2G)
-and like -h, but use Powers of 1000 1024 not
-block-size = -k like 1K
, -count-links count sizes many times if hard linked
-m like -block-size = 1M
-L, -dereference Dereference all symbolic links
-P, -no-Dereference do not follow any symbolic links (this is the default)
-0, -null End each output line with 0 byte rather than newline
-S, -separate-Dirs do not include size of subdirectories
-s, -summarize display only a total for each argument
-x, -one-file-system skip directories on different file systems
-X, –exclude-from =FILE exclude files that match any pattern in FILE
–Exclude = PATTERN exclude files that match PATTERN
–Max-depth = N 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
–Time show time of the last modification of any file in the directory, or any of its subdirectories
-time = WORD show time as WORD INSTEAD OF modification time: atime, access, use, ctime or status
-time-style = STYLE show times Using style STYLE: full-iso, long-iso, iso, + FORMAT
FORMAT is interpreted like `date '
-help display this help and exit
-version output version information and exit

Display values ​​has units of the first available SIZE from -block-size, and the DU_BLOCK_SIZE, BLOCK_SIZE blocksize and environment variables.
Otherwise, default units to 1024 bytes (or if POSIXLY_CORRECT 512 is set).

SIZE type requested (or integer type requested Optionally year FOLLOWED by) one of GMT: KB 1000, 1024 K, MB 1000 1000 *, M * 1024 1024, and so on for G, T, P, E, Z, Y.

All the above options can be combined in command lines that we display accurate reports about the files and folders concerned. For example, if you want to see the volume of individual folders and files from a specific location (/ var, in our example), the command line will f

[[Email protected] cousin]# -and du -s * | sort -h

This means Individual volume display busy folders and files in / var, sorted descending.

"sort -h"- sorts and displays the result in"Human Readable Format" Bytes, kilobytes, megabytes, gigabytes.

"-and"- has somewhat the same function as" -h ", but uses 1000 instead of 1024.

"-s"- displays the total for the parent directory without detailing the folders and files under it.

du (Disk Usage) Command in Linux

About the author


Passionate about everything that means gadget and IT, I am pleased to write on stealthsettings.com from 2006 and I love to discover new things about computers and macOS, Linux operating systems, Windows, iOS and Android.

Leave a Comment