Courseiva
Essential CommandsmediumMultiple ChoiceObjective-mapped

LFCS Essential Commands Practice Question

Exhibit

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        50G   45G   5.4G  90% /
/dev/sdb1       100G   20G   80G   20% /data

Refer to the exhibit. The administrator receives alerts that the root filesystem is almost full. Which command could free up space by removing old log files?

⚠ Common exam trap

Linux Foundation often tests the distinction between commands that merely display disk usage (like `du`) versus those that actually remove files, and the danger of using `rm -rf` with wildcards on system directories like /var/log.

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 -name '*.log' -mtime +30 -delete

The `find` command with `-name '*.log'` targets log files, `-mtime +30` selects files modified more than 30 days ago, and `-delete` removes them. This safely frees space by purging only old logs, preserving recent logs needed for troubleshooting.

Answer analysis

Option-by-option breakdown

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

  • find /var/log -name '*.log' -mtime +30 -delete

    Why this is correct

    Removes old log files safely.

  • truncate -s 0 /var/log/syslog

    Why it's wrong here

    Only truncates one file, not all old logs.

  • rm -rf /var/log/*

    Why it's wrong here

    Removes all log files, including current ones, potentially causing data loss.

  • du -sh /var/log

    Why it's wrong here

    Shows disk usage but does not free space.

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.