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 who they are files and / or folders the most "voluminous". Of course, "du" command 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 most linux commands.

In the documentation of the "du" command, we are presented with the following options:

[root @ server] # 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 produces the grand total
-D, –dereference-args dereference only symlinks that are listed on the command line
-files0-from = F summarize disk usage of the NUL-terminated file names specified in file F;
If F is - 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)
–Si like -h, but use powers of 1000 not 1024
-k like –block-size = 1K
-l, –count-links count sizes many times if hard linked
-m like –block-size = 1M
-L, –dereference dereference all symbolic links
-P, –no-dereference don't follow any symbolic links (this is the default)
-0, –null end each output line with 0 bytes 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 as `date '
–Help display this help and exit
–Version output version information and exit

Display values ​​are in units of the first available SIZE from –block-size, and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT 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

[Root @ server var] # du –si -s * | sort -h

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

"sort -h"- sort and display 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 below it.


du (Disk Usage) Command in Linux

About the author


Passionate about everything gadget and IT, I write with pleasure on stealthsettings.com since 2006 and I like to discover with you new things about computers and operating systems macOS, Linux, Windows, iOS and Android.

Leave a Comment