Linux Commands

DU One Level Only

We all know that the disk usage command or the “du” command in Linux is used to monitor the disk usage of a system’s hard drive. However, it takes quite a long time to execute this command since it has to calculate the space occupied by all the directories as well as their sub-directories. However, at times, you might just want a brief overview of the space occupied by each directory only at the first level. Therefore, today’s article will guide you on the methods of running the disk usage (du) command for one level only.

How to Run the Disk Usage (DU) Command for One Level Only?

If you want to execute the disk usage (du) command for one level only, then you can make use of any of the following two methods:

Method # 1: By using the “max-depth” Option:

For this method, you will have to execute the command stated below:

$ du –h --max-depth=1

This command will display the disk usage of the hard disk of your system only up to the first level, as shown in the following image:

Method # 2: By using the “d” Flag:

This method is just an alternative to the method discussed above. To follow it, you will have to execute the command shown below:

$ du –h -d1

Again, the above-mentioned command will show the disk usage of the hard disk of your system for one level only, as shown in the following image:

In both of these methods, we have used the “-h” flag to display our output in a human-readable format.

Conclusion:

By picking either of the two methods explained in this tutorial, you can instantly manage to run the disk usage (du) command up to the first level only.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.