Forrest logo
back to the du tool

du:tldr:048a1

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

The command "du -h -d ${2} ${path-to-directory}" is used to find the disk usage of a directory in a human-readable format.

Here's a breakdown of the command:

  • "du" stands for "disk usage" and is a command-line utility in Unix-like operating systems used to estimate file, directory, or overall filesystem usage.
  • "-h" is an option that tells the "du" command to display the sizes in a human-readable format. It automatically converts the sizes into friendly units like kilobytes(KB), megabytes(MB), etc.
  • "-d" is another option that specifies the depth or level of directory depth to display the disk usage information. The variable "${2}" is passed as the argument for this option. The variable is expected to be provided when executing the command in order to determine the level of details to display.
  • "${path-to-directory}" is a placeholder for the actual path to the directory for which you want to find the disk usage. You need to replace it with the relevant path on your system.

So, by running this command, you can see the disk usage of the specified directory with the desired level of details in a human-readable format.

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