Assess your understanding of disk usage analysis and space management using command-line tools. This quiz covers essential commands, output interpretation, and practical scenarios for maintaining disk health on systems via CLI.
Which command would you use to quickly display the sizes of directories in the current location, sorted from largest to smallest, to investigate space usage issues?
Explanation: The correct answer is 'du -sh * | sort -hr', which combines disk usage summary with sorting in human-readable form, making it easy to see which directories consume the most space. 'df -lh' shows file system-level usage, not individual directories. 'ls -ltr' lists files by modification time, unrelated to size sorting. 'diskstat -sv' is not a standard disk usage command.
If you want to check total, used, and available disk space for all mounted filesystems in a human-readable format, which option for the 'df' command should you use?
Explanation: 'df -h' displays disk space information in human-readable form such as GB or MB, which is ideal for reviewing storage. 'df -a' includes dummy file systems and is usually unnecessary. 'df --sum' is not a valid option, and 'df -s' summarizes disk usage per argument, rather than listing all file systems.
After noticing your home directory is nearly full, which command can you use to interactively remove unnecessary files and free up space using a CLI utility?
Explanation: 'ncdu ~' launches an interactive disk usage analyzer in your home directory, allowing you to view and delete files safely. 'dd if=/dev/zero...' actually creates a file and adds data, using more space. 'touch cleanup' just creates an empty file. Creating a directory with 'mkdir deleted_files' does not remove any existing data.
If a system is running low on disk space and you suspect large log files in /var/log, which single command helps you list all files in that directory larger than 100 megabytes?
Explanation: 'find /var/log -type f -size +100M' finds files over 100 MB inside /var/log. 'ls -lhS' lists by size but doesn't filter specifically by 100 MB. The 'du' and 'sort' pipeline shows directory sizes, not individual files, and 'grep 100M /var/log/*' looks for the text '100M' in files, not their size.
When comparing disk usage across multiple mounted filesystems, which 'df' output column should you primarily consult to see available free space?
Explanation: The 'Available' column shows how much free space remains for new data storage on each filesystem, which is essential for space management. The 'Used' column displays only what's currently in use. '1K-blocks' or similar columns show the total capacity. 'Filesystem' identifies the mount point, not its space specifics.