DF and Du commands in Linux

Source: Internet
Author: User

DFCommand:Check disk space usage of the file system

Commonly used: DF-hi, DF,-ha, DF-th, DF-th-x vfat,

Function: You can use this command to obtain the space occupied by the hard disk and the remaining space.

Syntax: DF [Option]

-A: displays the disk usage of all file systems, including 0 block file systems, such as/proc file systems.

-K is displayed in K bytes.

-I: displays the I node information instead of the disk block.

-T: displays the disk space usage of each specified type of file system.

-X lists the disk space usage of a file system of a specified type (opposite to the T option ).

-T displays the file system type.

-H indicates the use of "human-readable" output, that is, the size of the file system is in a readable format such as GB and MB.

Example 1: List the disk space usage of each file system.
$ DF
Filesystem 1 K-blocks used available use % mounted on
/Dev/hda2 1361587 1246406 44823 97%/

The 1st column represents the path name of the device file corresponding to the file system (usually the partition on the hard disk );

The 2nd column lists the number of data blocks (1024 bytes) contained in the partition;

Column 3 and 4 indicate the number of used and available data blocks, respectively. The sum of the number of blocks in column 3 and 4 is not equal to the number of blocks in Column 2nd. This is because by default, each partition leaves a small amount of space for the system administrator to use.

The 5th column indicates the percentage of space used by normal users. Even if this number reaches 100%, the partition still has space for the system administrator. Column 6th indicates the Installation Point of the file system.

 

Example 2: List the I node usage of each file system.
$ DF-ia
Filesystem inodes iused ifree iused % mounted on
/Dev/hda2 352256 75043 277213 21%/
None 0 0 0%/proc
Localhost :( pid221) 0 0 0 0%/Net


Example 3: list the types of file systems.
$ DF-T
Filesystem type 1k-blocks used available use % mounted on
/Dev/hda2 ext2 1361587 1246405 44824 97%/
In this example, the file system is of the ext2 type.

 

Inode is the basic information (metadata) used to store files and directories, including the time, file name, user, and group. When dividing a sector, the system will first make a bunch of inode for later use. The number of inode is related to the total number of files and directories that can be created in the system. If most of the files to be stored are small, there will be a large number of files on hard disks of the same size, that is, a large number of inode are required to mount files and directories.

 

 

DuCommand: query the disk space used by an archive or directory

A: displays the disk space occupied by all directories and each file in the second directory.

B: The size is represented by bytes (the default value is K bytes)

C: add the total value (default)

S: only display the total size of each file

X: only calculate the files of the same file system.

L: Calculate the size of all files
Common commands: Du-

Operation Details
The reference command du can display the disk space occupied by all files in each directory in the unit of subdirectories in the specified directory. For example:

# Du-H/etc

104 K/etc/defaults

6.0 K/etc/X11

...

10 K/etc/SSL

1.7 m/etc

 

# Du-SH/etc
1.7 m/etc

When viewing the usage of the Directory, we can export the output results to the sort command for sorting to know which file has used the most space:

# Du/etc | sort-Nr | more

1746/etc

388/etc/mail

...

4/etc/gnats

2/etc/skel

The-Nr parameter of sort indicates that reverse sorting is performed by numerical sorting. Because we want to sort the directory size, we cannot use the size output of human-readable, otherwise, the directory size may contain letters such as K and M, which may result in incorrect sorting.

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.