Practice Setup
Linux Architecture
Basic Commands
Basic file management or operations on file
User administration
Linux Interview Questions



du - disk usage

du command examples and its explanation:

Du command represents the disk usage in the Linux system.

Du command is used to list the directories or files along with their storage consumption.


Difference between du command and df command:

"df command" explains the memory utilization at the filesystem levels.

"du command" explains the memory used by each file and its corresponding directories.


Disk usage of a particular directory:


du directory-name

sample command output is given below,


[root@sys1 /]# du /repo/
16       /repo/lost+found
3354380  /repo/Packages
36156    /repo/isolinux
17256    /repo/repodata
264      /repo/EFI/BOOT
272      /repo/EFI
64       /repo/LoadBalancer/repodata
76       /repo/LoadBalancer
68       /repo/ScalableFileSystem/repodata
80       /repo/ScalableFileSystem
280      /repo/ResilientStorage/repodata
292      /repo/ResilientStorage
34584    /repo/images/pxeboot
207492   /repo/images
16720    /repo/Server/repodata
16864    /repo/Server
248      /repo/HighAvailability/repodata
260      /repo/HighAvailability
3635968  /repo/


In the above output, the digits represent the number of disk blocks of the files.



The above output is same as du -k option as well.


Disk usage of a particular directory in human readable format:

By using the "du –h" command we can list the disk usage of the particular directory.

[root@sys1 ~]# du -h /repo/
16K           /repo/lost+found
3.2G          /repo/Packages
36M           /repo/isolinux
17M           /repo/repodata
264K          /repo/EFI/BOOT
272K          /repo/EFI
64K           /repo/LoadBalancer/repodata
76K           /repo/LoadBalancer
68K           /repo/ScalableFileSystem/repodata
80K           /repo/ScalableFileSystem
280K          /repo/ResilientStorage/repodata
292K          /repo/ResilientStorage
34M           /repo/images/pxeboot
203M          /repo/images
17M           /repo/Server/repodata
17M           /repo/Server
248K          /repo/HighAvailability/repodata
260K          /repo/HighAvailability
3.5G          /repo/


Human readable format means the usage of the files or directories in,

K- kilo bytes, M- megabytes and G- gigabytes.


Display total directory size:

By using the "du –sh" command we can know the grand total disk usage of a particular directory.
“-s” option will give the summary of the size.

[root@sys1 ~]# du -sh /repo
3.5G     /repo


[root@linbox1 etc]# du -sh /var
627M     /var


Display the biggest file in a directory:

du -h /var | sort -n | tail -n 5


Display all files and their sizes in a directory:

By using the du –a command we can list the disk usage of all file sand directories

[root@sys1 ~]# du -a /repo
16864       /repo/Server
140         /repo/RELEASE-NOTES-te-IN.html
0           /repo/5
88          /repo/RELEASE-NOTES-ru-RU.html
4           /repo/HighAvailability/repodata/repomd.xml
248         /repo/HighAvailability/repodata
4           /repo/HighAvailability/TRANS.TBL
4           /repo/HighAvailability/listing
260         /repo/HighAvailability
12          /repo/EULA_pt
8           /repo/EULA_zh
0           /repo/EULA
0           /repo/4


Topics Summary