Courseiva
mediumMultiple Choice

XK0-006 Practice Question: A system administrator notices that the /var…

A system administrator notices that the /var partition is full, causing log services to malfunction. Which command should be used to quickly reclaim space by removing compressed old log files?

⚠ Common exam trap

Many candidates choose `logrotate -f` thinking it cleans up old logs, but it actually triggers rotation and compression, which can fill the partition further instead of freeing space.

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

✓

find /var/log -type f -name '*.gz' -delete

It uses `find` to locate all files ending in `.gz` under `/var/log` and deletes them with `-delete`. Compressed old log files are typically archived with gzip, so removing them directly reclaims disk space without affecting active logs or requiring additional tools.

Answer analysis

Option-by-option breakdown

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

  • ✗

    journalctl --vacuum-size=100M

    Why it's wrong here

    journalctl --vacuum-size only prunes the systemd journal, not the separate compressed archives under /var/log that the stem asks about, so those files remain. Vacuuming is correct when the journal itself has grown too large; here the offending files sit outside journald's control.

  • ✓

    find /var/log -type f -name '*.gz' -delete

    Why this is correct

    The `find` command targets `/var/log`, filters with `-type f` and `-name '*.gz'` to match only compressed rotated logs, then `-delete` removes them in one pass. This directly reclaims space on the full `/var` partition without touching active uncompressed logs, satisfying the requirement to remove old compressed files quickly.

  • ✗

    rm -rf /var/log/*.gz

    Why it's wrong here

    rm -rf deletes the .gz archives but bypasses logrotate's state file, leaving stale entries that break future rotation and can corrupt the service's tracking. It is tempting because it does reclaim space instantly; the correct approach uses logrotate's own removal mechanism so rotation state stays consistent.

  • ✗

    logrotate -f

    Why it's wrong here

    logrotate -f forces an immediate rotation cycle, which renames and compresses current logs rather than deleting existing .gz archives, so no space is reclaimed. Rotation scheduling is logrotate's actual purpose; it would be the right tool for automating retention, not for emergency cleanup of already-compressed files.

About these practice questions

One of 781 original XK0-006 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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 XK0-006 practice question is part of Courseiva's free CompTIA 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 XK0-006 exam.