A daily Linux command () du command

Source: Internet
Author: User
Tags utext

The du command is a view of the space used by files and directory disks.

(1) Usage:

usage: du [options] [file]

(2) Function:

function: report disk space usage

(3) Option parameters:

1)-A--all displays statistics on all files, not just subdirectories.

2)-B--bytes outputs the size in bytes, overriding the default 1024-byte count unit.

3)-H--human-readable with K,m,g as the unit, improve the readability of the information.

4)-S--summarize show only sum for each parameter

5)--max-depth=n only outputs the total of the command line parameters that are less than or equal to the nth level of the directory. The--max-depth=0 function is the same as the-s option.

6)-m--megabytes output in megabytes to the size of the count unit (that is, 1,048,576 bytes)

7)-X file--exclude-from=file is the same as--exclude in addition to the schema obtained from the specified file. Patterns are listed as rows. If the specified file is '-', then read the pattern from the standard input.

8)-K--kilobytes Output in KB (1024bytes)

(4) Example:

The default is 1024 bytes in a unit

1) [[email protected] sunjimeng]# du documents display the space usage of a directory or file

[[email protected] sunjimeng]# du Documents               //Show only Table of contents 0    documents/finddir/dir/cdir    documents/finddir/Dir    documents/ Finddir 8    documents/pdir8    documents/nopdir    

Show space usage for files

[email protected] sunjimeng]# du documents/finddir/dir/head_text4    documents/finddir/dir/ Head_text 

2) [[email protected] sunjimeng]# DU-A documents Detailed view of the current directory, sub-directory, all files and directories

[email protected] sunjimeng]# du-a Documents4documents/finddir/dir/Head_text4documents/finddir/dir/Less20documents/finddir/dir/Cdir4documents/finddir/dir/less1.gz Adocuments/finddir/Dir Adocuments/Finddir0documents/pdir/Find4documents/pdir/T3.txt4documents/pdir/VF0documents/pdir/Utext8documents/Pdir0documents/nopdir/Find4documents/nopdir/T3.txt4documents/nopdir/VF0documents/nopdir/Utext8documents/Nopdir -Documents

3) [[email protected] document]# du by default displays the space usage of the folder for the current directory

[email protected] document]# du0./Newdir A    . [[email protected] document]# ll total dosage A-rw-r--r--.1Root Users -May -  Geneva: -All.txt-rw-rw-r--.1Sunjimeng Users0May +  A: -B.text3-rw-rw-r--.1Sunjimeng Users0May +  A: -C.text6-rw-rw-r--.1Sunjimeng Users0May +  A: -D.TEXTDRWXR-xr-x.2Root UsersWuyiMay -  Geneva: -Newdir-rw-r--r--.1Root Users theMay -  Geneva: -T1.txt-rw-r--r--.1Root Users +May -  Geneva: WuT2.txt[[email protected] document]# CD ./[email protected] sunjimeng]# du Document0document/Newdir ADocument

4) [[email protected] sunjimeng]# Du-ah Documents display in an easy-to-read manner

[email protected] sunjimeng]# du-Ah Documents4.0K documents/finddir/dir/Head_text4.0K documents/finddir/dir/Less20documents/finddir/dir/Cdir4.0K documents/finddir/dir/less1.gz12k Documents/finddir/dir12k Documents/Finddir0documents/pdir/Find4.0K documents/pdir/T3.txt4.0K documents/pdir/VF0documents/pdir/Utext8.0K documents/Pdir0documents/nopdir/Find4.0K documents/nopdir/T3.txt4.0K documents/nopdir/VF0documents/nopdir/Utext8.0K documents/nopdir28k Documents

5) [[email protected] sunjimeng]# Du-hba Documents displayed in a single byte

[email protected] sunjimeng]# du-HBA Documents664documents/finddir/dir/Head_text $documents/finddir/dir/Less26documents/finddir/dir/Cdir thedocuments/finddir/dir/less1.gz854documents/finddir/Dir870documents/Finddir0documents/pdir/Find -documents/pdir/T3.txt thedocuments/pdir/VF0documents/pdir/Utext241documents/Pdir0documents/nopdir/Find -documents/nopdir/T3.txt thedocuments/nopdir/VF0documents/nopdir/Utext241documents/Nopdir1396Documents

6) [[email protected] sunjimeng]# Du-s * Only shows the space usage of subfolders in total

[Email protected] sunjimeng]# Du-s *0Desktop ADocument -Documents0Downloads0Findtextdir0Music0Pictures0 Public0Templates0videos[[email protected] sunjimeng]# du-S//Displays the current folder by default Sunjimeng5328    

7) [[email protected] sunjimeng]# DU-BH * |sort-n sorted according to the size of the directory, including subdirectories of the directory

[Email protected] sunjimeng]# DU-BH * |sort-N1. 4K Documents6Desktop6documents/finddir/dir/Cdir6Downloads6Findtextdir6Music6Pictures6 Public6Templates6VideosWuyidocument/Newdir241documents/Nopdir241documents/Pdir321Document854documents/finddir/Dir870Documents/finddir

8) [[email protected]/]# Du-ahm--max-depth=0 Displays the size of the folder in M, and can specify the depth of the display

[Email protected]/]# Du-ahm--max-depth=0 //depth of 0 indicates only the current folder/size is displayed du: Unable to access"./PROC/4599/TASK/4599/FD/4": There is no file or directory//But the entire disk must be queried in order to know the result du: inaccessible"./PROC/4599/TASK/4599/FDINFO/4": No file or directory du: unreachable"./PROC/4599/FD/4": No file or directory du: unreachable"./PROC/4599/FDINFO/4": No file or directory du: unreachable"./run/user/1000/gvfs": Insufficient Permissions3540    . [[Email protected]/]# Du-ahm--max-depth=1 the./Boot1./DEVDU: Unable to access"./PROC/4670/TASK/4670/FD/4": No file or directory du: unreachable"./PROC/4670/TASK/4670/FDINFO/4": No file or directory du: unreachable"./PROC/4670/FD/4": No file or directory du: unreachable"./PROC/4670/FDINFO/4": No file or directory0./PROCDU: Unable to access"./run/user/1000/gvfs": Insufficient Permissions9./Run0./SYS -./etc1./Root1./tmp -./var3304./usr0./bin0./Sbin0./Lib0./lib646./Home0./Media0./mnt0./opt0./SRV0./touch_test0./Touch_text3540. The entire Ext file system space usage is about 3540M

A daily Linux command () du command

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.