Linux disk management command: du command details

Source: Internet
Author: User
Tags disk usage

After a long period of development, the system administrator wants to know the functions of the df command in the linux disk management command. Many users also know about most of the linux disk management commands, here I will share my understanding and discuss with you the du command. Disk Quota: after reading this article, I believe you can get a satisfactory answer.

Linux disk management command -- du

The original English meaning of du is "disk usage", which means to display the usage of disk space.
Function: calculates the disk space occupied by directories or files.
Syntax: du [Option] [Names…]
Note: This command step by step enters each sub-directory of the specified directory and shows that the directory occupies 1024 bytes of the data block of the file system. If no Names is provided, the current directory is counted.

The options of this command are as follows:
◆-S indicates the total number of data blocks occupied by each Names parameter.
◆-A Recursively displays the number of data blocks occupied by each file in the specified directory and its children's directories. If neither-s nor-a is specified, only the disk blocks occupied by each directory and Its subdirectories in Names are displayed.
◆-B lists disk space usage in bytes. The system defaults to k Bytes ).
◆-K lists the disk space usage in 1024 bytes.
◆-C is followed by a total system default setting ).
◆-L calculate the size of all files, and calculate hard-linked files multiple times.
◆-X skipping directories on different file systems is not counted.

The following is an example of the use of the du command:
Example 1: view the disk space occupied by the/mnt directory. $ Cd/mnt $ ls-lFR total 10-rwxrwxrwx 2 root ll0 Ju1 3l 00:33 aa *
Drwxr-xr-x 2 root l024 Ju1 20 14:16 dev/
-Rw-r -- 1 root 6229 Aug 2 0l: 39 s1ack
Drwxrwxrwx 2 root 1024 Aug 2 02: 09 var/
1 rwxrwxrwx 1 root l0 Aug 2 0l: 51 wei->/home/wei/
Dev:
Tota1 0
Lrwxrwxrwx 1 root 8 Ju1 20 l4: l6 cdrom->/dev/hdb
Var:
Tata1 37
-R-xr-x l root 36064 Aug 2 rawrite. exe *

Example 2: List the disk space occupied by each directory, but not the space occupied by each file.
$ Du
L./dev
38./var
48.
The first column in the output list is the disk space capacity measured in blocks, and the second column lists the directory names that use these spaces. Note that the "du" command without options will run down the directory structure from the current directory until the capacity of all directories is listed. This may be a very long list, and sometimes only one total number is required. In this case, you can add the-s option in the du command to obtain the total number:
$ Du-s/mnt
/Mnt

Example 3: Use Option a to list the space occupied by all files and directories, and use option B in bytes to calculate the size.
$ Du-AB
8./dev/cdrom
L032./dev
36064./var/rawrite. exe
37088./var
6229./s1ack
1l0./aa
L0./wei
45493.

  1. Linux environment variable settings-Summary
  2. One of the Linux compression and packaging methods: tar command
  3. Linux Program Development
  4. How to monitor the usage of Linux system resources
  5. Explore various types of Linux Files

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.