10 Useful du (Disk Usage) Commands to Find Disk Usage of Files and Directories
2014-10-28 09:52
711 查看
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.
Check Disk Usage of Files and Folders In Linux
This article explains 10 useful “du” commands with
their examples, that might helps you to find out the sizes of files and
directories in Linux. The information provided in this article are taken
from the man pages of du command.
Read Also:
12 “df” Command to Check Linux System Disk Space
1. To find out the disk usage summary of a /home/tecmint directory tree and each of its sub directories. Enter the command as:
The output of the above command displays the number of disk blocks in the /home/tecmint directory 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.
3. To get the summary of a grand total disk usage size of an directory use the option “-s” as follows.
4. Using “-a” flag with “du” command displays the disk usage of all the files and directories.
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 in Kilobytes, Megabytes etc.
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).
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.
8. The “-c” flag provides a grand total usage disk space at the last line. If your directory taken 674MB space, then the last last two line of the output would be.
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.
10. Display the disk usage based on modification of time, use the flag “–time” as shown below.
Check Disk Usage of Files and Folders In Linux
This article explains 10 useful “du” commands with
their examples, that might helps you to find out the sizes of files and
directories in Linux. The information provided in this article are taken
from the man pages of du command.
Read Also:
12 “df” Command to Check Linux System Disk Space
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/tecmint directory 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 in Kilobytes, 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 taken 674MB 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
相关文章推荐
- Linux_10 Useful du (Disk Usage) Commands to Find Disk Usage of Files and Dir
- Find The Largest Top 10 Files and Directories on Linux
- How to cleanup and shrink disk space usage of a Windows KVM virtual machine
- To find names containing exactly five characters, use “^”and “$”to match the beginning and end of the name, and five instances of “.”in between: mysql
- 【10】Find nth to last element of a singly linked list
- How to diff and merge files or directories on Linux
- Placement of Voting disk and OCR Files in Oracle RAC 10g and 11gR1 [ID 293819.1]
- Top 10 Most Useful iOS Libraries to Know and Love
- A Novel Approach to Improvingthe Efficiency of Storing and Accessing Small Files on Hadoop: a Case S
- 10 Tips to Survive and Progress in the Field of Software Testing
- How to get started with WebRTC and iOS without wasting 10 hours of your life
- Files and Strings(Chapter 10 of Python 3 Object Oriented Programming)
- Reset textruemap _path of ZIP and copy allfiles to samepackage
- 【原创】The solutional manual of the Verilog HDL: A Guide to Digital Design and Synthesis (2nd)--ch10
- Top 10 Most Useful iOS Libraries to Know and Love
- Java Iterate directory to find files and edit
- Placement of Voting disk and OCR Files in Oracle RAC 10g and 11gR1 [ID 293819.1]
- Placement of Voting disk and OCR Files in Oracle RAC 10g and 11gR1 [ID 293819.1]
- 25 Useful Basic Commands of APT-GET and APT-CACHE for Package Management
- making 11 connections and the number of simultaneous builds has been throttled to 10