Which command is used to display disk usage for a directory and its contents?

df

du

The command used to display disk usage for a directory and its contents is "du". This command stands for "disk usage" and provides a summary of the amount of disk space used by files and directories. By default, when executed without any options, "du" will show the size of each subdirectory as well as the size of the directory itself, thus allowing you to assess how storage is allocated within that directory.

The strength of "du" lies in its ability to recursively analyze directories, providing a comprehensive overview of their disk usage. For instance, using "du -h" can present the sizes in a human-readable format, making it easier to understand the sizes in terms of kilobytes, megabytes, or gigabytes.

In contrast, the other commands listed serve different purposes: "df" displays the amount of disk space used and available on filesystem partitions, "ls" lists files and directories within a specific directory, and "find" is used to search for files in a directory hierarchy based on specific criteria. These commands do not provide a direct summary of disk usage like "du" does, highlighting its unique functionality in this context.

ls

find

Want more questions?

All options are one-time payments.

$25.99

30 day premium pass

All the basics to get you started

  • Ad-free experience
  • View your previous attempt history
  • Mobile app access
  • In-depth explanations
  • 30 day premium pass access
$59.99 $171.99 usd

6 month DELUXE pass (most popular)

Everything with the 30 day premium pass FOR 6 MONTHS! & the ultimate digital PDF study guide (BONUS)

  • Everything included in the premium pass
  • $171.99 usd value for $59.99! You save $106!
  • + Access to the ultimate digital PDF study guide
  • + 6 months of premium pass access
  • + Priority support
$15.99 $24.99

Ultimate digital PDF study guide

For those that prefer a more traditional form of learning

  • Available for instant download
  • Available offline
  • Hundreds of practice multiple choice questions
  • Comprehensive content
  • Detailed explanations
Image Description
Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy