Forrest logo
back to the du tool


List the human-readable sizes of a directory and any subdirectories, up to N levels deep.
$ du -h --max-depth=N ${path-to-directory}
try on your machine

The command "du -h --max-depth=N ${path-to-directory}" is used to display disk usage of the specified directory. Here's what each part of the command means:

  • "du" stands for "disk usage" and is a command used in Unix-like operating systems to estimate file space usage.
  • "-h" is a parameter that stands for "human-readable" format. It is used to display file sizes in a more easily understandable format, such as "2.5G" for gigabytes.
  • "--max-depth=N" is another parameter that sets the maximum depth of the directory tree to display. Replace "N" with the desired numeric value. For example, "--max-depth=1" will only show the disk usage of the immediate files and directories within the specified directory.
  • "${path-to-directory}" is the path to the directory you want to get the disk usage for. Replace it with the actual path to the directory you want to analyze.

When you run this command, it will calculate and display the disk usage in human-readable format for the specified directory, including the sizes of all files and subdirectories. By adjusting the "--max-depth" parameter, you can control the level of detail in the output.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the du tool