via: http://www.tecmint.com/check-linux-disk-usage-of-files-and-directories/
The Linux “du” (Disk Usage) is a standard Unix/Linux command, used to check the information of disk usage of files and directories on a machine. The du command has many parameter options that can be used to get the results in many formats. The du command also displays the files and directory sizes in a recursively manner.
1. To find out the disk usage summary of a /home/tecmint directory tree and each of its sub directories. Enter the command as:
[root@tecmint]# du /home/tecmint
40 /home/tecmint/downloads
4 /home/tecmint/.mozilla/plugins
4 /home/tecmint/.mozilla/extensions
12 /home/tecmint/.mozilla
12 /home/tecmint/.ssh
689112 /home/tecmint/Ubuntu-12.10
689360 /home/tecmint
The output of the above command displays the number of disk blocks in the /home/tecmintdirectory along with its sub-directories.
2. Using “-h” option with “du” command provides results in “Human Readable Format“. Means you can see sizes in Bytes, Kilobytes, Megabytes, Gigabytes etc.
[root@tecmint]# du -h /home/tecmint
40K /home/tecmint/downloads
4.0K /home/tecmint/.mozilla/plugins
4.0K /home/tecmint/.mozilla/extensions
12K /home/tecmint/.mozilla
12K /home/tecmint/.ssh
673M /home/tecmint/Ubuntu-12.10
674M /home/tecmint
3. To get the summary of a grand total disk usage size of an directory use the option “-s” as follows.
[root@tecmint]# du -sh /home/tecmint
674M /home/tecmint
4. Using “-a” flag with “du” command displays the disk usage of all the files and directories.
[root@tecmint]# du -a /home/tecmint
4 /home/tecmint/.bash_logout
12 /home/tecmint/downloads/uploadprogress-1.0.3.1.tgz
24 /home/tecmint/downloads/Phpfiles-org.tar.bz2
40 /home/tecmint/downloads
12 /home/tecmint/uploadprogress-1.0.3.1.tgz
4 /home/tecmint/.mozilla/plugins
4 /home/tecmint/.mozilla/extensions
12 /home/tecmint/.mozilla
4 /home/tecmint/.bashrc
689108 /home/tecmint/Ubuntu-12.10/ubuntu-12.10-server-i386.iso
689112 /home/tecmint/Ubuntu-12.10
689360 /home/tecmint
5. Using “-a” flag along with “-h” displays disk usage of all files and folders in human readeable format. The below output is more easy to understand as it shows the files inKilobytes, Megabytes etc.
[root@tecmint]# du -ah /home/tecmint
4.0K /home/tecmint/.bash_logout
12K /home/tecmint/downloads/uploadprogress-1.0.3.1.tgz
24K /home/tecmint/downloads/Phpfiles-org.tar.bz2
40K /home/tecmint/downloads
12K /home/tecmint/uploadprogress-1.0.3.1.tgz
4.0K /home/tecmint/.mozilla/plugins
4.0K /home/tecmint/.mozilla/extensions
12K /home/tecmint/.mozilla
4.0K /home/tecmint/.bashrc
673M /home/tecmint/Ubuntu-12.10/ubuntu-12.10-server-i386.iso
673M /home/tecmint/Ubuntu-12.10
674M /home/tecmint
6. Find out the disk usage of a directory tree with its subtress in Kilobyte blcoks. Use the “-k” (displays size in 1024 bytes units).
[root@tecmint]# du -k /home/tecmint
40 /home/tecmint/downloads
4 /home/tecmint/.mozilla/plugins
4 /home/tecmint/.mozilla/extensions
12 /home/tecmint/.mozilla
12 /home/tecmint/.ssh
689112 /home/tecmint/Ubuntu-12.10
689360 /home/tecmint
7. To get the summary of disk usage of directory tree along with its subtrees in Megabytes(MB) only. Use the option “-mh” as follows. The “-m” flag counts the blocks in MB units and “-h” stands for human readable format.
[root@tecmint]# du -mh /home/tecmint
40K /home/tecmint/downloads
4.0K /home/tecmint/.mozilla/plugins
4.0K /home/tecmint/.mozilla/extensions
12K /home/tecmint/.mozilla
12K /home/tecmint/.ssh
673M /home/tecmint/Ubuntu-12.10
674M /home/tecmint
8. The “-c” flag provides a grand total usage disk space at the last line. If your directory taken674MB space, then the last last two line of the output would be.
[root@tecmint]# du -ch /home/tecmint
40K /home/tecmint/downloads
4.0K /home/tecmint/.mozilla/plugins
4.0K /home/tecmint/.mozilla/extensions
12K /home/tecmint/.mozilla
12K /home/tecmint/.ssh
673M /home/tecmint/Ubuntu-12.10
674M /home/tecmint
674M total
9. The below command calculates and displays the disk usage of all files and directories, but excludes the files that matches given pattern. The below command excludes the “.txt” files while calculating the total size of diretory. So, this way you can exclude any file formats by using flag “-–exclude“. See the output there is no txt files entry.
[root@tecmint]# du -ah --exclude="*.txt" /home/tecmint
4.0K /home/tecmint/.bash_logout
12K /home/tecmint/downloads/uploadprogress-1.0.3.1.tgz
24K /home/tecmint/downloads/Phpfiles-org.tar.bz2
40K /home/tecmint/downloads
12K /home/tecmint/uploadprogress-1.0.3.1.tgz
4.0K /home/tecmint/.bash_history
4.0K /home/tecmint/.bash_profile
4.0K /home/tecmint/.mozilla/plugins
4.0K /home/tecmint/.mozilla/extensions
12K /home/tecmint/.mozilla
4.0K /home/tecmint/.bashrc
24K /home/tecmint/Phpfiles-org.tar.bz2
4.0K /home/tecmint/geoipupdate.sh
4.0K /home/tecmint/.zshrc
120K /home/tecmint/goaccess-0.4.2.tar.gz.1
673M /home/tecmint/Ubuntu-12.10/ubuntu-12.10-server-i386.iso
673M /home/tecmint/Ubuntu-12.10
674M /home/tecmint
10. Display the disk usage based on modification of time, use the flag “–time” as shown below.
[root@tecmint]# du -ha --time /home/tecmint
4.0K 2012-10-12 22:32 /home/tecmint/.bash_logout
12K 2013-01-19 18:48 /home/tecmint/downloads/uploadprogress-1.0.3.1.tgz
24K 2013-01-19 18:48 /home/tecmint/downloads/Phpfiles-org.tar.bz2
40K 2013-01-19 18:48 /home/tecmint/downloads
12K 2013-01-19 18:32 /home/tecmint/uploadprogress-1.0.3.1.tgz
4.0K 2012-10-13 00:11 /home/tecmint/.bash_history
4.0K 2012-10-12 22:32 /home/tecmint/.bash_profile
0 2013-01-19 18:32 /home/tecmint/xyz.txt
0 2013-01-19 18:32 /home/tecmint/abc.txt
4.0K 2012-10-12 22:32 /home/tecmint/.mozilla/plugins
4.0K 2012-10-12 22:32 /home/tecmint/.mozilla/extensions
12K 2012-10-12 22:32 /home/tecmint/.mozilla
4.0K 2012-10-12 22:32 /home/tecmint/.bashrc
24K 2013-01-19 18:32 /home/tecmint/Phpfiles-org.tar.bz2
4.0K 2013-01-19 18:32 /home/tecmint/geoipupdate.sh
4.0K 2012-10-12 22:32 /home/tecmint/.zshrc
120K 2013-01-19 18:32 /home/tecmint/goaccess-0.4.2.tar.gz.1
673M 2013-01-19 18:51 /home/tecmint/Ubuntu-12.10/ubuntu-12.10-server-i386.iso
673M 2013-01-19 18:51 /home/tecmint/Ubuntu-12.10
674M 2013-01-19 18:52 /home/tecmint
相关推荐
书名为《Linux Commands and Shell Programming 2nd》,即第二版《Linux命令及Shell编程实用指南》,作者为Mark G. Sobell。这本书被描述为Linux命令行操作和Shell编程的必备读物,其内容通俗易懂,翔实可靠,专注于...
PRENTICE_HALL-A_Practical_Guide_To_Linux_Commands_Editors_And_Shell_Programming
Linux英文原版图书系列].PRENTICE_HALL-A_Practical_Guide_To_Linux_Commands_Editors_And_Shell_Programming.chm
_Easy_to_manage_linux_commands_方便简单的管理linux命令__lflxp-cmd
Quectel_EC20_AT_Commands_Manual_V1.0.pdfQuectel_EC20_AT_Commands_Manual_V1.0.pdf
文档标题为《Quectel_EC20_R2.1_AT_Commands_Manual_V1.0.pdf》,文档描述为移远EC20 AT指令手册。文档中强调了提供及时、全面服务的宗旨,并提供了总部联系方式,包括电话、邮箱及网址。手册中包含了一系列的联系...
《Quectel EC20 AT命令...综上所述,《Quectel EC20 AT Commands Manual》是理解并利用EC20模块进行物联网应用开发的重要参考资料,通过学习和掌握其中的AT命令和实践案例,开发者可以高效地构建自己的4G通信解决方案。
Quectel_EC20_AT_Commands_Manual_V1.3 版本,相对以前版本有所更新!
_Impressive_Linux_commands_cheat_sheet_CLI_writt_pls
linux_命令实践总结_commands-linux
《Quectel EC20 R2.1 AT Commands Manual V1.0》是针对Quectel EC20无线通信模块的一份详细指令集手册。该手册涵盖了EC20模块使用AT命令进行通信的所有核心知识,旨在帮助开发者和工程师有效地控制和配置这个4G LTE...
### Quectel BC26 AT Commands Manual V1.0 关键知识点解析 #### 一、文档概述 **标题**:Quectel_BC26_AT_Commands_Manual_V1.0.pdf **描述**:该文档为NB-IoT模块系列中的BC26型号设备提供了AT命令手册,版本号...
Quectel_BC95_AT_Commands_Manual_V1.9.pdf Quectel_BC95_AT_Commands_Manual_V1.9.pdf Quectel_BC95_AT_Commands_Manual_V1.9.pdf
《Quectel EC20 R2.0 AT Commands Manual V1.2》是针对移远通信EC20 R2.0版本的LTE模块所编写的AT指令手册。该手册详细阐述了如何通过AT命令来控制和配置EC20模块,以实现与网络的连接、数据传输、电话通话等功能。...
Quectel_BC95_AT_Commands_Manual_V1.5.pdf Quectel_BC95_AT_Commands_Manual_V1.5.pdf Quectel_BC95_AT_Commands_Manual_V1.5.pdf
[Linux英文原版图书系列].PRENTICE_HALL-A_Practical_Guide_To_Linux_Commands_Editors_And_Shell_Program [Linux英文原版图书系列].PRENTICE_HALL-Building_Applications_With_The_Linux_Standard_Base [Linux英文...
Quectel_BC95_AT_Commands_Manual_V1.6.pdf Quectel_BC95_AT_Commands_Manual_V1.6.pdf Quectel_BC95_AT_Commands_Manual_V1.6.pdf
首先,文档的标题明确指出这是关于“Quectel EC20 TCPIP AT Commands”的手册,即移远EC20模块的TCP/IP AT命令手册。AT命令是一种用于控制调制解调器和其他通信设备的指令集,常用于无线通信模块中,通过串行端口...