How can you check disk usage in a specific directory?

Explore the Linux Fundamentals Test. Revise with flashcards and multiple choice questions, each with hints and explanations. Prepare thoroughly for your Linux exam!

To check disk usage in a specific directory, using the du command with the directory path is the most effective approach. The du (disk usage) command is specifically designed to estimate and report the file space usage of directories and their contents. When invoked with a directory path, it provides detailed information about the size of the directory and its subdirectories, allowing users to see how much disk space is being consumed.

For example, running du -sh /path/to/directory gives a summary of the total size of that directory in a human-readable format. This method is ideal for monitoring how much space individual directories are using, which can be particularly useful for maintenance and management of disk resources.

Other commands mentioned, such as df, ls, and top, do not provide this specific information in the same way. The df command gives an overview of disk space usage at the filesystem level rather than for specific directories, ls lists files and directories along with their properties but does not summarize disk usage, and top displays real-time system process information, which is unrelated to disk usage in a particular directory.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy