Linux under the Disk Management du command usage instructions

Source: Internet
Author: User
Tags disk usage


Function: Counts the size of the disk space that the directory (or file) occupies.

Syntax: du [options] [files or directories]

Parameters:

-S: Only the total number of blocks of data used for each names parameter is given.
-A: Recursively displays the number of blocks of data in each file and subdirectory in the specified directory. If-S is not specified or-A is specified, only the number of disk blocks per directory in names and each subdirectory in it is displayed.
-B: The disk space usage is listed in bytes (the system defaults to K bytes).
-K: Lists disk space usage in 1024-byte units.
-C: Finally add a total (system default).
-L: Calculates all file sizes, and calculates multiple times for hard linked files.
-X: Skipping directories on different file systems does not count. Simple example:

[Yanue@server www]$ du-h--max-depth=1
676K./avatar
7.9M./wp-includes
6.4M./wp-admin
18M./wp-content
33M. Use examples:

Instance 1. Displays the directory or the space occupied by the file

Du [file or directory] Instance 2: Display space occupied by multiple files

Du [file or directory] [file or directory] Instance 3: Displays the size of the disk space used by several files or directories, and counts their sum

du-c [file or directory] [file or directory] Instance 4: Sorted by Space size

Du|sort-nr|more

Usage Example:

1> to display disk usage for a directory tree and each subtree

Du/home/linux

This displays the number of disk blocks in the/home/linux directory and each of its subdirectories.

2> to display the disk usage of a tree and each subtree in 1024-byte units

Du-k/home/linux

This shows the number of 1024-byte disk blocks in the/home/linux directory and each of its subdirectories.

3> displays the disk usage of a directory tree and each subtree in MB

Du-m/home/linux

This shows the number of MB disk blocks in the/home/linux directory and each of its subdirectories.

4> displays the disk usage of a directory tree and each subtree in GB

Du-g/home/linux

This displays the number of GB disk blocks in the/home/linux directory and each of its subdirectories.

5> View the size of all directories and subdirectories under the current directory:

Du-h.

“.” Represents the current directory. can also be replaced with a clear path

-H indicates an easy-to-understand unit of K, M, and G

6> View the size of the user directory under the current directory and do not want to look at other directories and their subdirectories:

Du-sh User

-S means the summary, which lists only one summarized value

Du-h–max-depth=0 User

–max-depth=n represents a depth to the N-tier directory, which is set to 0, meaning that it is not drill-down to subdirectories.

7> lists the size of all directories and files under the user directory and its subdirectories:

Du-ah User

-A representation includes directories and files

8> lists the size of directories in the current directory that do not include the XYZ string:

Du-h–exclude= ' *xyz* '

9> want to show more information about the user directory and subdirectory size in one screen:

du-0h User

-0 (Bar 0) represents the information for each directory that is listed, without wrapping, but directly outputting the information for the next directory.

10> displays all disk usage for only one directory tree

The code is as follows Copy Code

[Maple@linux ~]$
[Maple@linux ~]$ du
8./test/links
8./test/dir/subdir1
8./test/dir/subdir2
/test/dir
160./test
108./test2
1492.
[Maple@linux ~]$
[Maple@linux ~]$ du-0
8./test/links8./test/dir/subdir18./test/dir/subdir220./test/dir160/test108./test21492. [Maple@linux ~]$ Du-c
8./test/links
8./test/dir/subdir1
8./test/dir/subdir2
/test/dir
160./test
108./test2
1492.
1492 Total
[Maple@linux ~]$
[Maple@linux ~]$ Du-h
8.0K./test/links
8.0K./test/dir/subdir1
8.0K./test/dir/subdir2
20K./test/dir
160K./test
108K./test2
1.5M.
[Maple@linux ~]$
[Maple@linux ~]$ Du-k
8./test/links
8./test/dir/subdir1
8./test/dir/subdir2
/test/dir
160./test
108./test2
1492.
[Maple@linux ~]$
[Maple@linux ~]$ Du-sh
1.5M.
[Maple@linux ~]$
[Maple@linux ~]$ Du-s
8./test/links
8./test/dir/subdir1
8./test/dir/subdir2
4./test/dir
132./test
108./test2
1224.
[Maple@linux ~]$
[Maple@linux ~]$ du-sh--exclude= "sub*"
8.0K./test/links
4.0K./test/dir
132K./test
108K./test2
1.2M.
[Maple@linux ~]$
[Maple@linux ~]$ Du-h
8.0K./test/links
8.0K./test/dir/subdir1
8.0K./test/dir/subdir2
20K./test/dir
160K./test
108K./test2
1.5M.
[Maple@linux ~]$

Supplemental Note : du displays the disk space occupied by the specified directory or file.

Parameters
A or-all displays the size of individual files in the directory.
-B or-bytes displays the directory or file size in bytes.
-C or--total displays the sum of all directories or files in addition to the size of individual directories or files.
-D or--dereference-args displays the source file size for the specified symbolic connection.
-H or--human-readable to k,m,g to improve the readability of the information.
The-H or--si is the same as the-h parameter, but K,m,g is a unit of conversion in 1000.
-K or--kilobytes in 1024 bytes.
-L or--count-links a file that calculates hardware connections repeatedly.
The source file size for the symbol connection specified in the-l< symbol connection > or--dereference< symbol connection > Display option.
-M or--megabytes is in 1MB.
-S or--summarize displays totals only.
When-S or--separate-dirs displays the size of an individual directory, it does not contain the size of its subdirectories.
-X or--one-file-xystem the file system at the start of the process, and if you encounter a different file system directory, skip.
-x< files > or--exclude-from=< files > specify directories or files in < file >.
--exclude=< directory or File > skips the specified directory or file.
--max-depth=< the directory layer > beyond the specified number of layers, ignored.
--help display Help.
--version Displays version information.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.