Linux Disk Management du command detailed

Source: Internet
Author: User
Tags file size readable disk usage jboss

Command use

The Du (disk usage) command calculates the disk space that a file or directory occupies. When you do not specify any options, it measures the current working directory and all its subdirectories, showing the number of directories that are accounted for by each directory, and then displays the total speed of the working directory.

Command format

Du [OPTION] ... [FILE] ...

-a,–all

Includes all the files, not just directories.

–apparent-size

Print apparent sizes, rather than disk usage; Although the apparent size is usually smaller, it may be larger due

To holes in (' sparse ') files, internal fragmentation, indirect blocks, and the like

-b,–block-size=size Use Size-byte blocks

-b,–bytes in bytes as unit of calculation

-K in kilobytes (KB) as a unit of calculation

-M in megabytes (m) as a unit of calculation

-c,–total finally add a total (system default)

-d,–dereference-args

Dereference FILEs that are symbolic links

The-H and--si effect is the same.

-h,–human-readable Output File size information (for example, 1K 234M 2G) in a more readable manner. Note: This option is also available in many other commands (DF, LS).

–si is the same as the-H effect, only 1000 is the conversion unit

-l,–count-links calculates all file sizes and calculates multiple times for hard linked files.

-l,–dereference the source file size of the symbol connection specified in the Display option.

-p,–no-dereference does not follow any symbolic connections (default)

-s,–separate-dirs does not include the size of subdirectories when calculating the space occupied by the directory.

-s,–summarize displays only the total space occupied by the working directory

-x,–one-file-system the file system at the start of the process, if you encounter a different file system directory, skip.

-X File,–exclude-from=file excludes the specified FILE

–exclude=pattern excludes files that match the style, pattern is the normal shell style,? represents any character, * represents any number of characters.

–max-depth=n

Lists only the information for directories and files with depths less than max-depth –max-depth=0 the effect is the same as –s

Use case

root@ubuntu:/# cd/home/web/

root@ubuntu:/home/web# du-s

793832. – Do not specify a file name to calculate the amount of space occupied by the current directory.

root@ubuntu:/#$ Du-sh

776M. – Do not specify a file name to calculate the amount of space occupied by the current directory. The-h option makes the output easier to read (compared to the previous example)

root@ubuntu:/#$ du–max-depth=1-h

– Output the space used by each subdirectory under the current directory

83M./java

87M./build

197M./jboss

128M./lib

1.1M./bin

52K./synclogs

4.8M./sql

920K./conf

52K./logs

20K./mail_group

56K./.svn

144M./htdocs

56K./jboss-conf

2.7M./auto-conf

8.0K./.mule

23M./classes

43M./templates

144K./project

776M.

Find large files

When disk space is depleted, it is unavoidable to clean up, for example, the/home directory is too large, you can use the following command to see who it is:

Du-s/home/* | Sort-nr

Related Article

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.