Courseiva
Essential CommandseasyMultiple ChoiceObjective-mapped

LFCS Essential Commands Practice Question

Exhibit

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        20G   20G     0 100% /var

Refer to the exhibit. The /var partition is 100% full. Which command can be used to find the largest files in /var/log to free up space?

⚠ Common exam trap

Candidates often choose `ls -lS` (option A) because it sorts by size, but they overlook that it does not recurse into subdirectories, making it ineffective for a directory tree like /var/log that typically contains multiple subdirectories.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

du -ah /var/log | sort -rh | head

It uses `du -ah` to list all files and directories in /var/log with human-readable sizes, pipes the output to `sort -rh` to sort them in reverse numerical order (largest first), and then uses `head` to display only the top entries. This combination efficiently identifies the largest files consuming space, allowing the administrator to target specific files for cleanup.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ls -lS /var/log

    Why it's wrong here

    ls -lS lists files in the current directory sorted by size, but does not recurse into subdirectories and may not show the largest items overall.

  • find /var/log -size +100M

    Why it's wrong here

    This finds files larger than 100M but does not sort them by size.

  • du -ah /var/log | sort -rh | head

    Why this is correct

    du recursively calculates disk usage, sorts by size human-readable, and head shows the top entries.

  • df -h /var/log

    Why it's wrong here

    df shows filesystem usage, not the size of individual files or directories.

About these practice questions

This LFCS question is part of Courseiva's 507-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This LFCS practice question is part of Courseiva's free Linux Foundation certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LFCS exam.