View Linux disk or folder and file size

When the disk size will exceed the standard alarm, then if the master command df and du is a very wise choice.

    df can see a folder size, the proportion of use, file system and its hanging point, but the file can not do anything.
    du can view the file and folder size.

    Combination of the two to use, very effective. For example, to view a directory with df which is too large, then df view folders or file size, so you can quickly identify the crux.

A, df command

    You can display all the currently available space and file system usage

 -a: Show all file system disk usage, including 0 (block) file system, such as the / proc file system. 
  -k: k bytes in the display. 
  -i: i node information display, disk blocks instead. 
  -t: Specifies the display of each type of file system disk space usage. 
  -x: list is not a specified type of file system disk space usage (with the t option to the contrary). 
  -T: displays the file system type.



Two, du command
Du original meaning as the English "disk usage", meaning to show disk space usage situation
 
du [-abcDhHklmsSx] [-L <symbolic links>] [- X <file>] [- block-size] [- exclude = <directory or file>] [--max-depth = <directory levels> ] [- help] [- version] [directory or file]
 
-a or -all for each specified file shows disk usage, file or directory in each respective display disk usage.
When -b or -bytes display the directory or file size in byte units.
-c or -total addition to displaying the directory or file size, but also shows the sum of all files or directories.
-D or -dereference-args size of the source file specified symbolic link.
-h -human-readable or to K, M, G as a unit, to improve the readability of information.
-H -H or -si with the same parameters, but K, M, G is the conversion unit 1000 is, rather than conversion unit 1024.
-k or -kilobytes to 1024 bytes as a unit.
-l file or -count-links connected hardware double counting.
-L <symbolic link> or -dereference <symbolic link> display size of the symbol connected to the source file specified in the option.
-m or -megabytes to 1MB units.
-s or -summarize display only totals that the current size of the directory.
-Separate-dirs -S or when the display size of each directory, and the size of its free of subdirectories.
-x or -one-file-xystem to the file system at the start of a process prevail, if met other different file system directory is skipped.
The -X-<file> or -exclude-from = <file> specified file or directory in <file>.
-exclude = <file or directory> Skip the specified directory or file.
-max-depth = <directory levels> directory after more than a specified number of layers, be ignored.
-help Displays help.
-version Display version information.
 
1> To display the disk a directory tree and each of its sub-tree usage
you / home / Linux
This shows the number of disk blocks in the / home / linux directory and each subdirectory.
2> to 1024 bytes by displaying a directory tree and each subtree disk usage
You -k / home / linux
This shows that the 1024 bytes of disk blocks in / home / linux each directory and its subdirectories.
3> in MB display disk usage of a directory tree and each of its sub-tree
du -m /home/linux
This shows MB disk blocks in the / home / linux directory and each subdirectory.
4> in GB disks display a directory tree and each of its sub-tree usage
du -g /home/linux
This shows the number of GB disk blocks in the / home / linux directory and each subdirectory.
5> View size of all directories under the current directory and subdirectories:
You -h.
. "" Represents the current directory. It can also be replaced with a clear path
-h display indicates humanized form K, M, G in
6> View the size of the user directory under the current directory, you do not want to see the other and its subdirectories:
you -sh user
-s represents summary of meaning, that lists only a summary of value
du -h --max-depth=0 user
--max-depth = n represents the n-th layer only down to a directory, here set to 0, it means that not go into the subdirectory.
7> list the size of all directories and files under the user directory and its subdirectories:
you -ah user
-a meant to include directories and files
8> listed in the directory size of the current directory name of the directory xyz string does not include:
du -h --exclude='*xyz*'
9> want a screen following out more information about the user directory and subdirectories size:
you -0h user
-0 (zero bar) information representing each of a directory lists, not wrapped, but the next directory information is directly output.
10> display only the total disk usage of a directory tree
du -s /home/linux

Guess you like

Origin www.cnblogs.com/sumuncle/p/11314671.html