Du


From Linuxconfig.org

Jump to: navigation, search

.. back to the list of Linux Commands

Name

du - estimate file space usage

Synopsis - man page

du [OPTION]... [FILE]...
du [OPTION]... --files0-from=F

Frequently used options

-h, --human-readable
      print sizes in human readable format (e.g., 1K 234M 2G)
-s, --summarize
      display only a total for each argument
--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 --summarize

Examples

du is abbreviation of "disk usage". This command tool reports usage by given directory. Lets suppose that we have this directory structure in /tmp:

$ cd /tmp
$ mkdir -p dir1/dir2/dir3
$ tree dir1
Image:du01.gif

By default du command traverse whole directory structure:

$ du dir1
Image:du02.gif

by option -s we instruct du command to print total just for given argument. In our case the argument is dir1.

$ du -s dir1
Image:du03.gif

We can do the same by --max-depth=N:

$ du --max-depth=0 dir1
Image:du04.gif

Lets se how it works on /var directory:

# du -s /var
Image:du05.gif
# du --max-depth=1 /var
Image:du06.gif

If its hard for you to read size in bytes you can instruct du to display size in human readable format:

# du -h --max-depth=1 /var
Image:du07.gif

.. back to the list of Linux Commands

Personal tools
Linux Commands