In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article gives you a detailed introduction of the df command in Linux disk management and how to use it. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
1. Command format:
Du [options] [File]
2. Command function:
Displays the disk usage space for each file and directory.
3. Command parameters:
-an or-all displays the size of individual files in the directory.
-b or-bytes displays the directory or file size in byte.
-c or-- total displays not only the size of individual directories or files, but also the sum of all directories or files.
-k or-- kilobytes output in KB (1024bytes).
-m or-- megabytes output in MB.
-s or-- summarize displays only the total and lists only the last plus value.
-h or-- human-readable is in the unit of KMagazine GetWord ("G"); to improve the readability of information.
-x or-- one-file-xystem is based on the file system at the beginning of the processing, and will be skipped in case of other different file system directories.
The source file size of the symbolic link specified in-L or-- dereference display options.
When-S or-- separate-dirs displays the size of an individual directory, it does not include the size of its subdirectories.
-X or-- exclude-from= is in the specified directory or file.
-- exclude= skips the specified directory or file.
-D or-- dereference-args displays the source file size of the specified symbolic link.
The parameters of-H or-- si are the same as-h, but the conversion unit of K _ ~ ~ M ~ G is 1000.
-l or-- count-links repeatedly calculates hardware-linked files.
4. Use an example:
Example 1: displays the space occupied by a directory or file
Command: du
Output:
The code is as follows:
[root@localhost 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.
[root@localhost test] #
Description:
Only the directory size of the subdirectories below the current directory and the total size of the current directory are displayed, and the bottom 1288 is the total size of the current directory
Example 2: displays the space occupied by the specified file
Command: du log2012.log
Output:
The code is as follows:
[root@localhost test] # du log2012.log
300 log2012.log
[root@localhost test] #
Example 3: view the space occupied by the specified directory
Command: du scf
Output:
The code is as follows:
[root@localhost 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
[root@localhost test] #
Example 4: show the space occupied by multiple files
Command: du log30.tar.gz log31.tar.gz
Output:
The code is as follows:
[root@localhost test] # du log30.tar.gz log31.tar.gz
4 log30.tar.gz
4 log31.tar.gz
[root@localhost test] #
Example 5: only the size of the sum is displayed
Command: du-s
Output:
The code is as follows:
[root@localhost test] # du-s
1288.
[root@localhost test] # du-s scf
32 scf
[root@localhost test] # cd..
[root@localhost soft] # du-s test
1288 test
[root@localhost soft] #
Example 6: easy-to-read format display
Command: du-h test
Output:
The code is as follows:
[root@localhost soft] # du-h test
608K test/test6
308K test/test4
4.0K test/scf/lib
4.0K test/scf/service/deploy/product
4.0K test/scf/service/deploy/info
12K test/scf/service/deploy
16K test/scf/service
4.0K test/scf/doc
4.0K test/scf/bin
32K test/scf
8.0K test/test3
1.3M test
[root@localhost soft] #
Example 7: both files and directories are displayed
Command: du-ah test
Output:
The code is as follows:
[root@localhost soft] # du-ah test
4.0K test/log31.tar.gz
4.0K test/test13.tar.gz
0 test/linklog.log
0 test/test6/log2014.log
300K test/test6/linklog.log
0 test/test6/log2015.log
4.0K test/test6/log2013.log
300K test/test6/log2012.log
0 test/test6/log2017.log
0 test/test6/log2016.log
608K test/test6
0 test/log2015.log
0 test/test4/log2014.log
4.0K test/test4/log2013.log
300K test/test4/log2012.log
308K test/test4
4.0K test/scf/lib
4.0K test/scf/service/deploy/product
4.0K test/scf/service/deploy/info
12K test/scf/service/deploy
16K test/scf/service
4.0K test/scf/doc
4.0K test/scf/bin
32K test/scf
4.0K test/log2013.log
300K test/log2012.log
0 test/log2017.log
0 test/log2016.log
4.0K test/log30.tar.gz
4.0K test/log.tar.bz2
4.0K test/log.tar.gz
0 test/test3/log2014.log
4.0K test/test3/log2013.log
8.0K test/test3
4.0K test/scf.tar.gz
1.3M test
[root@localhost soft] #
Example 8: displays the amount of disk space occupied by several files or directories, and calculates the sum of them
Command: du-c log30.tar.gz log31.tar.gz
Output:
The code is as follows:
[root@localhost test] # du-c log30.tar.gz log31.tar.gz
4 log30.tar.gz
4 log31.tar.gz
8 Total
[root@localhost test] #
With the-c option added, du not only displays the amount of disk space occupied by each of the two directories, but also sums them up on the last line.
Example 9: sort by space size
Command: du | sort-nr | more
Output:
The code is as follows:
[root@localhost 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
[root@localhost test] #
Example 10: output the space used by each subdirectory under the current directory
Command: du-h-- max-depth=1
Output:
The code is as follows:
[root@localhost test] # du-h-max-depth=1
608K. / test6
308K. / test4
32K. / scf
8.0K. / test3
1.3M.
[root@localhost test] #
On the Linux disk management df command detailed introduction and how to use to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.