Linux du command and DF command Difference __linux

Source: Internet
Author: User
Tags disk usage
1, the difference between the two

Du,disk usage, is to search the file to calculate the size of each file and then accumulate, du can see the files are only some of the existing, not deleted.        The size of his calculations is the sum of all the file sizes currently he thinks exist. Df,disk free, through the file system to quickly get the size of information, when we delete a file, the file is not immediately in the file system disappeared, but temporarily disappeared, when all programs are not used, will be based on the rules of the OS released deleted files, DF records the size of the file obtained through the file system, and he is better able to see the deleted files than the Du, and to calculate the size of this part of the space is added, more accurate.

When the file system is also determined to delete the file, Du and DF are the same.

2,du Command

1. command format:

du [option] [file] 2. command function:

Displays the disk usage space for each file and directory. 3. Command 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.

-K or--kilobytes is output in kilobytes (1024bytes).

-M or--megabytes is output in MB.

-S or--summarize only displays totals, listing only the last plus total value.

-H or--human-readable to k,m,g to improve the readability of the information.

-X or--one-file-xystem the file system at the start of the process, and if you encounter a different file system directory, skip.

-l< the source file size of the symbolic link specified in the symbol link > or--dereference< symbol link > Display option.

When-S or--separate-dirs displays the size of an individual directory, it does not contain the size of its subdirectories.

-x< files > or--exclude-from=< files > specify directories or files in < file >.

--exclude=< directory or File > skips the specified directory or file.

-D or--dereference-args displays the source file size for the specified symbolic link.

The-H or--si is the same as the-h parameter, but K,m,g is a unit of conversion in 1000.

-L or--count-links a file that duplicates the hardware link.

4. Use instance:

Example 1: Displays the directory or the space occupied by the file

command:

Du

Output:

[Root@localhost test]# du

608./test6

308./test4

4./scf/lib

4./scf/service/deploy/product

4./scf/service/deploy/info

/scf/service/deploy

/scf/service

4./scf/doc

4./scf/bin

/scf

8./test3

1288.

[Root@localhost test]#

Description:

Displays only the directory size of the subdirectory below the current directory and the total size of the current directory, and the bottom 1288 is the total size of the current directory

Example 2: Show Specify space occupied by the file

command:

Du Log2012.log

Output:

[Root@localhost test]# du Log2012.log

Log2012.log

[Root@localhost test]#

Description:

Instance 3: View the specified directory Space occupied by

command:

Du SCF

Output:

[Root@localhost test]# du SCF

4 Scf/lib

4 scf/service/deploy/product

4 Scf/service/deploy/info

Scf/service/deploy

Scf/service

4 Scf/doc

4 Scf/bin

Scf

[Root@localhost test]#

Description:

Example 4: Displays the space occupied by multiple files

command:

Du log30.tar.gz log31.tar.gz

Output:

[Root@localhost test]# du log30.tar.gz log31.tar.gz

4 log30.tar.gz

4 log31.tar.gz

[Root@localhost test]#

Description:

Instance 5: Show only the sum size

command:

Du-s

Output:

[Root@localhost test]# Du-s

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.