Courseiva

LPIC-1 Devices, Filesystems and FHS Practice Question

A system administrator notices that the /tmp directory is filling up quickly, causing applications to fail. The administrator wants to ensure that files in /tmp are automatically cleaned after a certain period. Which of the following is the best approach without installing additional software?

⚠ Common exam trap

Many candidates confuse the sticky bit (which only prevents deletion by other users) with automatic cleanup, or assume that a brute-force cron job is acceptable, while the correct answer leverages a built-in systemd service that is already present on most modern Linux distributions.

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

✓

Configure the systemd-tmpfiles service with a configuration file to clean /tmp regularly.

Systemd-based Linux distributions include the systemd-tmpfiles service, which can be configured via files in /etc/tmpfiles.d/ to automatically clean temporary files based on age, size, or other criteria. This approach uses built-in systemd functionality without requiring additional software, and it is the recommended method for managing /tmp cleanup on modern systems.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Add a cron job that runs 'rm -rf /tmp/*' every hour.

    Why it's wrong here

    A blanket rm -rf /tmp/* deletes every file regardless of age, including ones applications are actively using, and ignores the required retention period. It tempts as a quick cron fix, and would suit clearing a directory whose contents are genuinely disposable immediately.

  • ✗

    Install tmpwatch and configure it to clean files older than 1 day.

    Why it's wrong here

    tmpwatch is not part of a base installation, so installing it breaches the no-additional-software constraint; systemd-tmpfiles already provides age-based cleaning. It tempts because tmpwatch does exactly the required age-based deletion, and would be valid where extra packages are permitted.

  • ✗

    Set the sticky bit on /tmp to automatically delete old files.

    Why it's wrong here

    The sticky bit only restricts who may delete files in a shared directory; it performs no age-based deletion at all. It tempts because /tmp conventionally carries mode 1777, so administrators associate the sticky bit with /tmp housekeeping, but it is a permission control, not a cleanup mechanism.

  • ✓

    Configure the systemd-tmpfiles service with a configuration file to clean /tmp regularly.

    Why this is correct

    Configuring systemd-tmpfiles uses the distribution's built-in age-based cleanup: a drop-in under /etc/tmpfiles.d/ with a `d /tmp 1777 root root 10d` line makes systemd-tmpfiles-clean.timer purge entries older than the specified age. This satisfies the no-additional-software constraint, since systemd already ships with the system.

About these practice questions

Courseiva writes every LPIC-1 question from scratch — 402 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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 LPIC-1 practice question is part of Courseiva's free LPI 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 LPIC-1 exam.