know how to use du command with its examples

  • Used to get file/directory space usage, mostly used by the system admins when running into disk/filesystem usage issues.
  • It comes from “coreutils-8.4” package, 

Examples:

1. To get space usage for all

$ du -a

2. To print the aparent size instead of disk usage

$ du –apparent-size

3. To report the usage in spacified block size

$ du -B=SIZZE
$ du –block-size=1024 

To print the usage in aparent size of 1

$ du -b
$ du –bytes 

To produce a grand total

$ du -c
$ du –total 

To dereference only symlinks that are listed on the command line

$ du -D
$ du –dereference-args
 

To print sizes in human readable format

$ du -h

To print sizes in human readable format with powes of 1000 not 1024

$ du –si

To print the usage with block size as 1024 i.e. 1k

$ du -k

To count sizes many times if hard linked

$ du -l
$ du –count-links 

To print the usage with block size as 1024*1024=1048576 i.e. 1M

$ du -m

To dereference all symbolic links

$ du -L
$ du –dereference 

To not to follow any symbolic links (this is the default)

$ du -P
$ du –no-dereference 

To end each output line with 0 byte rather than newline

$ du -0
$ du –null 

To do not include size of subdirectories

$ du -S
$ du –separate-dirs 

To display only a total for each argument

$ du -x
$ du –one-file-system 

To exclude files that match any pattern in FILE

$ du -X
$ du –exclude-from=FILE

To exclude files that match PATTERN

$ du –exclude=PATTERN

To print the total for a directory

$ du –max-depth=N

To show time of the last modification of any file in the directory

$ du –time

To show time as WORD instead of modification time: atime, access, use, ctime or status

$ du –time=WORD

To show times using style STYLE

$ du –time-style=STYLE

To get the help

$ du –help

To get the version

$ du –version

 

Leave a Reply

Your email address will not be published. Required fields are marked *