Courseiva
Essential Commands →mediumMultiple Choice

LFCS Essential Commands Practice Question

A support engineer must copy the file /etc/hosts to /tmp/hosts.backup but only if /tmp/hosts.backup does not already exist, so that an existing backup is never overwritten. Which command performs this conditionally?

⚠ Common exam trap

Many candidates confuse --update with --no-clobber; --update compares timestamps and can still overwrite a backup, whereas --no-clobber keys purely on whether the destination already exists.

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

✓

cp --no-clobber /etc/hosts /tmp/hosts.backup

The --no-clobber option makes cp skip the operation entirely when the destination already exists, leaving the existing backup intact while still performing the copy when the destination is absent. The other options either ignore existence altogether, base the decision on timestamps, or rename the old file, all of which still result in the destination being replaced.

Answer analysis

Option-by-option breakdown

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

  • ✓

    cp --no-clobber /etc/hosts /tmp/hosts.backup

    Why this is correct

    The --no-clobber option instructs cp not to overwrite an existing destination file. If /tmp/hosts.backup is already present, cp skips the copy and exits without replacing it, preserving the old backup. If the destination is absent, the file is copied normally. This precisely implements the required conditional copy and avoids destroying any existing backup content.

  • ✗

    cp --update /etc/hosts /tmp/hosts.backup

    Why it's wrong here

    The --update option tells cp to copy only when the source is newer than the destination or when the destination is missing. Because /etc/hosts is frequently modified, it may well be newer than an old backup, causing the backup to be overwritten. The decision is based on timestamps rather than existence, so this does not guarantee that an existing backup remains untouched, failing the stated condition.

  • ✗

    cp --backup /etc/hosts /tmp/hosts.backup

    Why it's wrong here

    The --backup option makes cp rename an existing destination to a backup name before writing the new file. The original /tmp/hosts.backup is still replaced by the new copy, and an extra backup file appears alongside it. Since the scenario requires that an existing backup never be overwritten, this behaviour is incorrect; it preserves data under a different name but still clobbers the requested destination.

  • ✗

    cp --preserve=all /etc/hosts /tmp/hosts.backup

    Why it's wrong here

    The --preserve=all option only controls which attributes such as ownership, permissions, and timestamps are retained during the copy. It has no effect on whether an existing destination is overwritten. Running this command will replace /tmp/hosts.backup if it already exists, which is exactly the destructive behaviour the scenario wants to prevent. Therefore it does not satisfy the conditional requirement.

About these practice questions

Courseiva writes every LFCS question from scratch — 406 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 and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Linux Foundation exam blueprint

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.