Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux Command Tutorial: du command to view disk space     - The Samba service does not have permission to access (Server)

- SSH security note (Linux)

- MySQL multi-master multi-cluster deployment uses alive Galera (Database)

- Linux Security (Linux)

- Changes in C # asynchronous programming model (Programming)

- Ubuntu apt-mirror established local private sources (Linux)

- Everyone should know something about TCP (Linux)

- Linux dual physical network card set to a virtual NIC (Linux)

- Java call by value and by reference (Programming)

- Linux partition command (Linux)

- iOS persistence of data archiving NSKeyedArchiver (Programming)

- Under CentOS yum install Nginx smooth switch mounted to Tengine (Server)

- Nodejs command-line program development tutorial (Programming)

- Google open source TCP team repaired the Linux kernel TCP flaw (Linux)

- Additional SQL Server 5123 database reported error (Database)

- Linux kernel log --dmesg (Linux)

- C / C ++ language usage summary of const (Programming)

- Zabbix monitors Nginx status (Server)

- Simple configuration shell scripts virtual machine environment experiment (Linux)

- Android start automatically and add and delete a desktop shortcut (Programming)

 
         
  Linux Command Tutorial: du command to view disk space
     
  Add Date : 2016-08-11      
         
         
         
  Du command, namely, disk usage, file or directory can calculate the disk space occupied.

Format:

du [options] [file]
du [OPTION] ... [FILE] ...

No option is specified, it will measure the current working directory and all its subdirectories, respectively display the amount of space each directory, and finally display the working directory of the total space.

Command Options:

-a, -all
It includes all files, not just directories
-B, -block-Size = SIZE use SIZE-byte blocks
-b, -bytes bytes for the unit
-k, in kilobytes (KB) for the unit
-m, in megabytes (M) for the unit
-c, -total plus a final total (default)
-D, -dereference-Args
dereference FILEs that are symbolic links
-H With - -si same effect.
-h, -human-readable way to compare the reading output file size information (for example, 1K 234M 2G). Note: This option in many other commands (df, ls) is also effective.
-si -h with the same effect, just as in 1000 in terms of unit
-l, -count-links to calculate the size of all the files on the hard link file, the calculation times.
-L, -dereference Display options are symbolic links to specify the size of the source file.
-P, -no-Dereference do not follow any symbolic links (default)
-S, -separate-Dirs do not include size of subdirectories when calculating the space occupied by the directory.
-s, -summarize working directory displays only the total space
-x, -one-file-system to start processing a file system prevail, when there are other different file system directory is skipped.
-X FILE, -exclude-from = FILE exclude specified FILE
-exclude = PATTERN exclude files that meet the style, Pattern Shell is the ordinary style? Represent any one character, * represents any number of characters.
-max-depth = N
List only depth is less than max-depth directory and file information -max-depth = 0 when the effect is the same as with -s

Example:

Example 1: Display directory or file uses less space

command:

du

Output:

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

Explanation:

Show only the total size of the total size of the current directory and subdirectories of the current directory size directory, the bottom of the current directory 1288

Example 2: Specify file takes

command:

du log2012.log

Output:

[Root @ localhost test] # du log2012.log
300 log2012.log
[Root @ localhost test] #
Example 3: Check the space occupied by the specified directory

command:

du scf

Output:

[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: displaying a plurality of the space occupied by the file

command:

du log30.tar.gz log31.tar.gz

Output:

[Root @ localhost test] # du log30.tar.gz log31.tar.gz
4 log30.tar.gz
4 log31.tar.gz
[Root @ localhost test] #
Example 5: Displays total size

command:

du -s

Output:

[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

command:

du -h test

Output:

[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: files and directories are displayed

command:

Output:

[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: Several display each file or directory size of disk space occupied, but also their statistical sum

command:

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

Output:

[Root @ localhost test] # du -c log30.tar.gz log31.tar.gz
4 log30.tar.gz
4 log31.tar.gz
8 Total
[Root @ localhost test] #
Explanation:

Plus -c option, du shows not only takes up two directories each the size of disk space, is also the last line of statistics their sum.

Example 9: Sort by space

command:

du | sort -nr | more

Output:

[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 space used by each subdirectory under the current directory

command:

du -h --max-depth = 1

Output:

[Root @ localhost test] # du -h --max-depth = 1
608K ./test6
308K ./test4
32K ./scf
8.0K ./test3
1.3M.
[Root @ localhost test] #
     
         
         
         
  More:      
 
- WebLogic 12c Configuration Node Manager Managed Server (Database)
- Linux command in the dialog whiptail (Linux)
- Keepalived + Nginx Installation and Configuration (Server)
- To install Ganglia (Linux)
- What is Unikernel? (Linux)
- Teach you how to synchronize Microsoft OneDrive in Linux (Linux)
- Android using SVG vector graphics to create cool animation effects (Programming)
- WordPress plug-ins installed in Ubuntu, enter the subject of FTP and not create directory problem (Server)
- To solve the Mac in question invalid BASH under configuration environment variable (Linux)
- Delay for the specified IP port analog network to send and receive packets on Linux (Linux)
- STL source code analysis - iterator each container classification (Programming)
- VMware virtual machine operating system log Error in the RPC receive loop resolve (Linux)
- MySQL log from the library than the main library (Database)
- How to install with JSON support in Ubuntu 15.04 SQLite 3.9.1 (Database)
- PHP security Programming Advice (Programming)
- Java thread lifecycle (Programming)
- Fast Learning Clojure (Programming)
- CentOS5 installation Nodejs (Linux)
- Eclipse-ee Tomcat browser can not start Tomcat, and Web project service deployment (Server)
- Linux iptables firewall and vsftpd to resolve the issue (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.