The Linux du command

Source: Internet
Author: User
Tags zookeeper disk usage


The Linux du command

The Linux du command also looks at the space used, but unlike the DF command, the Linux du command is a view of the space used by the file and directory disks, or some difference from the DF command.

1. Command format:

du [Options] [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 output in kilobytes (1024bytes).

-M or--megabytes is output in megabytes.

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

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

-X or--one-file-xystem the file system at the beginning of the processing, if any other different file system directories are skipped.

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

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

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

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

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

-H or--si is the same as the-h parameter, but the k,m,g is converted to 1000 units.

-L or--count-links duplicates the hardware-linked files.

4. Usage examples:

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

Command:

Du

Output:

[[Email protected] ~]# CD test
[Email protected] test]# pwd
/root/test
[email protected] test]# du
52.
[email protected] test]# LL
Total 48
-rw-r--r--1 root root 41433 may Install.log
-rw-r--r--1 root root 3422 may Worldcount.jar

Description

Displays only the directory size of subdirectories below the current directory and the total size of the current directory, with the bottom 1288 being the total size of the current directory

Example 2: Display the space occupied by the specified file

Command:

Du Install.log

Output:
[email protected] test]# du Install.log
Install.log
[email protected] test]# du Worldcount.jar
4 Worldcount.jar

Description

Example 3: View the occupied space for a specified directory

Command:

Du SCF

Output:
[Email protected] ~]# mkdir hello/aa/
[email protected] ~]# CP Worldcount.jar hello/aa/
[email protected] ~]# du hello
Hello/aa
Hello
[Email protected] ~]#


Description

Example 4: Show the space occupied by multiple files

Command:

Du log30.tar.gz log31.tar.gz

Output:

[email protected] ~]# du test/install.log test/worldcount.jar
Test/install.log
4 Test/worldcount.jar


Description

Example 5: Show only the sum size

Command:

Du-s

Output:

[Email protected] ~]# du-s test
Test


Description

Example 6: Easy-to-read format display

Command:

Du-h Test

Output:

[Email protected] ~]# du-h test
52K Test


Description

Example 7: Files and directories are displayed

Command:

Output:

[Email protected] ~]# Du-ah test
4.0K Test/worldcount.jar
44K Test/install.log
52K Test


Description

Example 8: Show how many files or directories each occupy the size of disk space, and also count their sums

Command:

Du-c Hello.txt Zookeeper.out

Output:
[Email protected] ~]# du-c hello.txt zookeeper.out
Hello.txt
Zookeeper.out
Total

Description

With the-C option, Du shows not only the size of the two directories that occupy disk space, but also the sum of them in the last line.

Example 9: Sort by Space size

Command:

Du|sort-nr|more

Output:

[Email protected] test]# Du|sort-nr|more


[Email protected] test]#

Description

Example 10: Output the space used by each subdirectory under the current directory

Command:

Du-h--max-depth=1

Output:
[Email protected] ~]# du-h--max-depth=1
4.0K./videos
48K./.gnome2
52K./test
4.0K./downloads
148K./.pulse
4.0K./mymount
4.0K./music
4.0K./desktop
4.0K./.gnome2_private
4.0K./pictures
216K./.gconf
0./.gvfs
4.0K./documents
15M./.mozilla
4.0K./templates
4.0K./public
14M./.cache
16K./.gnupg
4.0K./.themes
16K./hello
4.0K./.nautilus
116K./A
44K./.config
600K./.thumbnails
380K./.gstreamer-0.10
4.0K./.icons
20K./.ssh
112K./.local
16K./.gnote
12K./.dbus
72K./.GCONFD
31M.
.





This article is from the "Liang blog" blog, make sure to keep this source http://7038006.blog.51cto.com/7028006/1829038

The Linux du command

Related Article

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.