Linux command to learn: du

  The du command also checks the space used, but unlike the df command, the Linux du command checks the space used by the file and directory disk, and it is somewhat different from the df command.

grammar

  du [options] [files]

Options

-a or -all Display the size of individual files in the directory.
-b or -bytes Display directory or file size in bytes.
-c or --total In addition to displaying the size of individual directories or files, also display the sum of all directories or files.
-k or --kilobytes Output in KB (1024bytes).
-m or --megabytes Output in MB.
-s or --summarize only display totals, only the last summed value.
-h or --human-readable Use K, M, G as units to improve the readability of information.
-x or --one-file-xystem is based on the file system at the beginning of processing, and skips it if it encounters other different file system directories.
-L<symlink> or --dereference<symlink> Displays the source file size of the symlink specified in the options.
-S or --separate-dirs Display the size of an individual directory without the size of its subdirectories.
-X <file> or --exclude-from=<file> Specify a directory or file in <file>.
--exclude=<directory or file> Skip the specified directory or file.
-D or --dereference-args Display the source file size of the specified symlink.
-H or --si Same as the -h parameter, but K, M, G are in 1000 units.
-l or --count-links Repeats the count of hardware linked files.
--help Display help.
--version display version information

example

  Display the space occupied by a directory or file:

[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 .

  Only display the directory size of the subdirectories under the current directory and the total size of the current directory, the bottom 1288 is the total size of the current directory

  Display the space occupied by the specified file:

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

  View the space occupied by the specified directory:

[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

  Display the space occupied by multiple files:

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

  Show only the size of the sum:

[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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324692230&siteId=291194637