du View the size of a file or directory disk space occupied

一、du的功能:`du` reports the amount of disk space used by the specified files and for each subdirectory (of directory arguments). with no arguments,`du` reports the disk space for the current directory。

  Obviously, with different df, which is used to view the size of files or directories take up more disk space.

  Two, du commonly used options:

  -H : displaying a human-readable manner ( expressed in the appropriate K / M / G Display Unit )

  -a: Displays the directory of disk space occupied, but also to show its directory and files take up disk space size

  -s : (the Summarize) displays the disk space occupied by the directory, do not display the disk space the size of its subdirectories and files take up ( ie, the sum of the count )

  -c: display disk space occupied by several directories or files, but also to statistical their sum

  --apparent-size: Display files or their size

  -l: Statistical hard disk space size occupied Links

  -L: Statistics symbolic link points to files take up disk space

  A, du -h: this is not to say.

  Two, du -a: Use this option to display the subdirectories and files take up disk space, directory size and directory.

 

Frequently used commands

-SH du  [specified file or directory]: View the current directory accounted for a total capacity. Without listing each child occupied capacity alone 

-LH --max-depth = du 1  : Check the current disk capacity under a sub-directory files and subdirectories occupied. --max-depth options to control the depth (from the beginning 0,1 ...)

 

Example:

1. 

you - sh *

 

2.

you -ch *. takes .gz

-cOption, is an abbreviated form of --total, it represents the sum for each object output to calculate its disk usage

 

3.

You LH --max-depth = 1

When --max-depth is set to 0, only the current folder is displayed total size

Visible, --max-depth = 0 effect, the equivalent -s

 

The difference between du and ls

  • du show disk space footprint.
  • ls shows that the size of the file contents.

Additionally, du, and ls for the same file, display size is not the same (abstract says: Disk Usage = content + packaging)

Because most of the file system requirements:

  1. A data block store up to contents of a file, when not full, the remaining space can not be used by other files.
  2. When the contents of a file is large, it can be stored to the plurality of data blocks.

 

Guess you like

Origin www.cnblogs.com/lisen10/p/11431424.html