Du command to view the space used by files and directory Disks

Source: Internet
Author: User

Tag: Use OS file 2014 re c

The Linux du command is used to view the space used, but unlike the DF command, the Linux du command is used to view the space used by files and directory disks, or is there some difference with the DF command.

1. Command Format:

Du [Option] [file]

2. command functions:

Displays the disk space used by each file and directory.

3. command parameters:

-A or-All indicates the size of individual files in the directory.

-B or-Bytes: displays the size of directories or files in bytes.

-C or -- total not only displays the size of individual directories or files, but also the total number of all directories or files.

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

-M or -- megabytes is output in MB.

-S or -- summarize only displays the total, and only lists the last added total value.

-H or -- human-readable is in the unit of K, M, and g to improve information readability.

-X or -- one-file-xystem is based on the file system at the beginning of processing. If it encounters a different file system directory, it is skipped.

-L <symbolic link> or -- dereference <symbolic link> shows the source file size of the specified symbolic link in the option.

-S or -- separate-dirs displays the size of individual directories in hours without the size of their subdirectories.

-X <File> or -- exclude-from = <File> specifies the directory or file in <File>.

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

-D or -- dereference-ARGs displays the source file size of the specified symbolic link.

-H or -- Si is the same as-h, but K, M, and g are measured in 1000 units.

-L or -- count-links repeat the hardware link file.

 

4. Example:

Instance 1: displays the space occupied by directories or files.

Command:

Du

Output:

[[Email protected] Test] # Du

608./test6

308./test4

4./SCF/lib

4./SCF/service/deploy/product

4./SCF/service/deploy/info

12./SCF/service/deploy

16./SCF/service

4./SCF/doc

4./SCF/bin

32./SCF

8./test3

1288.

[[Email protected] Test] #

 

Note:

Only the directory size of the subdirectories under the current directory and the total size of the current directory are displayed. The bottom 1288 is the total size of the current directory.

 

Instance 2: displays the space occupied by the specified file

Command:

Du log2012.log

Output:

[[Email protected] Test] # Du log2012.log

300 log2012.log

[[Email protected] Test] #

Note:

 

Instance 3: view the space occupied by the specified directory

Command:

Du SCF

Output:

[[Email protected] Test] # Du SCF

4 SCF/lib

4 SCF/service/deploy/product

4 SCF/service/deploy/info

12 SCF/service/deploy

16 SCF/service

4 SCF/doc

4 SCF/bin

32 SCF

[[Email protected] Test] #

Note:

 

Example 4: display the space occupied by multiple files

Command:

Du log30.tar.gz log31.tar.gz

Output:

[[Email protected] Test] # Du log30.tar.gz log31.tar.gz

4 log30.tar.gz

4 log31.tar.gz

[[Email protected] Test] #

Note:

 

Instance 5: only show the total size

Command:

Du-S

Output:

[[Email protected] Test] # Du-S

1288.

[[Email protected] Test] # Du-s SCF

32 SCF

[[Email protected] Test] # CD ..

[[Email protected] Soft] # Du-s test

1288 Test

[[Email protected] Soft] #

Note:

 

Example 6: easy-to-read format display

Command:

Du-h test

Output:

[[Email protected] Soft] # Du-h test

608 K test/test6

308 K test/test4

4.0 K test/SCF/lib

4.0 K test/SCF/service/deploy/product

4.0 K test/SCF/service/deploy/info

12 K test/SCF/service/deploy

16 K test/SCF/service

4.0 K test/SCF/doc

4.0 K test/SCF/bin

32 K test/SCF

8.0 K test/test3

1.3 m Test

[[Email protected] Soft] #

 

Note:

 

Instance 7: Both files and directories are displayed.

Command:

Output:

[[Email protected] Soft] # Du-Ah Test

4.0 K test/log31.tar.gz

4.0 K test/test13.tar.gz

0 test/linklog. Log

0 test/test6/log2014.log

300 K test/test6/linklog. Log

0 test/test6/log2015.log

4.0 K test/test6/log2013.log

300 K test/test6/log2012.log

0 test/test6/log2017.log

0 test/test6/log2016.log

608 K test/test6

0 test/log2015.log

0 test/test4/log2014.log

4.0 K test/test4/log2013.log

300 K test/test4/log2012.log

308 K test/test4

4.0 K test/SCF/lib

4.0 K test/SCF/service/deploy/product

4.0 K test/SCF/service/deploy/info

12 K test/SCF/service/deploy

16 K test/SCF/service

4.0 K test/SCF/doc

4.0 K test/SCF/bin

32 K test/SCF

4.0 K test/log2013.log

300 K test/log2012.log

0 test/log2017.log

0 test/log2016.log

4.0 K test/log30.tar.gz

4.0 K test/log.tar.bz2

4.0 K test/log.tar.gz

0 test/test3/log2014.log

4.0 K test/test3/log2013.log

8.0 K test/test3

4.0 K test/scf.tar.gz

1.3 m Test

[[Email protected] Soft] #

Note:

 

Instance 8: displays the disk space occupied by several files or directories, and calculates the sum of these files and directories.

Command:

Du-C log30.tar.gz log31.tar.gz

Output:

[[Email protected] Test] # Du-C log30.tar.gz log31.tar.gz

4 log30.tar.gz

4 log31.tar.gz

8 Total

[[Email protected] Test] #

 

Note:

After the-C option is added, du not only displays the disk space occupied by the two directories, but also calculates the sum of these two directories in the last row.

 

Instance 9: sort by space size

Command:

Du | sort-Nr | more

Output:

[[Email protected] Test] # Du | sort-Nr | more

1288.

608./test6

308./test4

32./SCF

16./SCF/service

12./SCF/service/deploy

8./test3

4./SCF/service/deploy/product

4./SCF/service/deploy/info

4./SCF/lib

4./SCF/doc

4./SCF/bin

[[Email protected] Test] #

 

Note:

 

Example 10: output the space used by each subdirectory in the current directory

Command:

Du-h -- Max-depth = 1

Output:

[[Email protected] Test] # Du-h -- Max-depth = 1

608 K./test6

308 K./test4

32 K./SCF

8.0 K./test3

1.3 m.

[[Email protected] Test] #

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.