Hello! I'm Labby, and I'm happy to help you with your question!
To limit the depth of reporting in the du command, you use the --max-depth option.
This option allows you to control how many levels of subdirectories the du command will display. Here is how it works:
- Level 0: Shows only the total for the directory you specified (or the current directory if none is specified).
du -h --max-depth=0 - Level 1: Shows the total for the current directory and its immediate subdirectories.
du -h --max-depth=1 - Level N: You can replace
Nwith any number to see that many levels deep into the folder structure.
Why is this useful?
If you are investigating a large disk with thousands of nested folders, a regular du command might scroll off your screen for minutes. Using --max-depth=1 helps you quickly identify which major folder is taking up the most space without getting lost in the details of every single subfolder.
Keep up the great work with the Linux commands! Feel free to ask if you have more questions.