Common Linux commands (28th) and common linux commands

Source: Internet
Author: User

Common Linux commands (28th) and common linux commands

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 function:

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.Command instance:

Instance 1. space occupied by the display directory or file

Command: du

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.

[root@localhost test]# du608     ./test6308     ./test44       ./scf/lib4       ./scf/service/deploy/product4       ./scf/service/deploy/info12      ./scf/service/deploy16      ./scf/service4       ./scf/doc4       ./scf/bin32      ./scf8       ./test31288    .[root@localhost test]#

Instance 2. display the space occupied by the specified file

Command: du log2012.log

[root@localhost test]# du log2012.log 300     log2012.log[root@localhost test]#

Instance 3. view the space occupied by the specified directory

Command: du scf

[root@localhost test]# du scf4       scf/lib4       scf/service/deploy/product4       scf/service/deploy/info12      scf/service/deploy16      scf/service4       scf/doc4       scf/bin32      scf[root@localhost test]#


Instance 4. display the space occupied by multiple files

Command: du log30.tar.gz log31.tar.gz

[root@localhost test]# du log30.tar.gz log31.tar.gz 4       log30.tar.gz4       log31.tar.gz[root@localhost test]#

Instance 5. only show the total size

Command: du-s

[root@localhost test]# du -s1288    .[root@localhost test]# du -s scf32      scf[root@localhost test]# cd ..[root@localhost soft]# du -s test1288    test[root@localhost soft]#


Instance 6. display in a readable format

Command: du-h test

[root@localhost soft]# du -h test608K    test/test6308K    test/test44.0K    test/scf/lib4.0K    test/scf/service/deploy/product4.0K    test/scf/service/deploy/info12K     test/scf/service/deploy16K     test/scf/service4.0K    test/scf/doc4.0K    test/scf/bin32K     test/scf8.0K    test/test31.3M    test[root@localhost soft]#

Instance 7. Files And Directories are displayed

Command: du-ah test

[root@localhost soft]# du -ah test4.0K    test/log31.tar.gz4.0K    test/test13.tar.gz0       test/linklog.log0       test/test6/log2014.log300K    test/test6/linklog.log0       test/test6/log2015.log4.0K    test/test6/log2013.log300K    test/test6/log2012.log0       test/test6/log2017.log0       test/test6/log2016.log608K    test/test60       test/log2015.log0       test/test4/log2014.log4.0K    test/test4/log2013.log300K    test/test4/log2012.log308K    test/test44.0K    test/scf/lib4.0K    test/scf/service/deploy/product4.0K    test/scf/service/deploy/info12K     test/scf/service/deploy16K     test/scf/service4.0K    test/scf/doc4.0K    test/scf/bin32K     test/scf4.0K    test/log2013.log300K    test/log2012.log0       test/log2017.log0       test/log2016.log4.0K    test/log30.tar.gz4.0K    test/log.tar.bz24.0K    test/log.tar.gz0       test/test3/log2014.log4.0K    test/test3/log2013.log8.0K    test/test34.0K    test/scf.tar.gz1.3M    test[root@localhost soft]#

Instance 8. display the disk space occupied by several files or directories and calculate their total

Command: du-c log30.tar.gz log31.tar.gz

[Root @ localhost test] # du-c log30.tar.gz log31.tar.gz 4 log30.tar.gz 4 log31.tar.gz 8 total [root @ localhost test] #


Instance 9. sort by space size

Command: du | sort-nr | more

[root@localhost test]# du|sort -nr|more1288    .608     ./test6308     ./test432      ./scf16      ./scf/service12      ./scf/service/deploy8       ./test34       ./scf/service/deploy/product4       ./scf/service/deploy/info4       ./scf/lib4       ./scf/doc4       ./scf/bin[root@localhost test]#

Instance 10. output the space used by each subdirectory in the current directory

Command: du-h -- max-depth = 1

[root@localhost test]# du -h  --max-depth=1608K    ./test6308K    ./test432K     ./scf8.0K    ./test31.3M    .[root@localhost test]#

Original article: http://www.cnblogs.com/peida/archive/2012/12/10/2810755.html


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.