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

Prepare for the Linux Professional Institute Certification Level 1. Use flashcards and multiple choice questions, complete with hints and explanations. Enhance your understanding and get ready to ace the exam!

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.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy