Courseiva
Essential CommandsmediumMultiple ChoiceObjective-mapped

LFCS Essential Commands Practice Question

A backup script must create a compressed archive of the /etc directory, preserving file permissions and timestamps. Which command should be used?

⚠ Common exam trap

Many exam-takers confuse `gzip` (which compresses individual files) with `tar` (which archives directories), or they think `rsync` creates an archive file when it actually creates a directory copy, not a compressed archive.

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

tar -czvf backup.tar.gz /etc

The `tar -czvf` command creates a compressed archive (via gzip) that preserves file permissions and timestamps by default when run as root. The `-c` flag creates the archive, `-z` compresses it with gzip, `-v` provides verbose output, and `-f` specifies the archive filename. Tar is the standard Unix tool for bundling files into a single archive while retaining metadata like ownership, permissions, and timestamps.

Answer analysis

Option-by-option breakdown

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

  • gzip -r /etc > backup.tar.gz

    Why it's wrong here

    gzip compresses individual files recursively but does not create an archive.

  • cpio -ov < /etc > backup.cpio

    Why it's wrong here

    cpio requires additional options to preserve permissions and does not produce a single archive file easily.

  • rsync -av /etc /backup/etc

    Why it's wrong here

    rsync is for mirroring or transferring files, not creating a standalone archive.

  • tar -czvf backup.tar.gz /etc

    Why this is correct

    tar with -czvf creates a gzipped archive preserving permissions and timestamps.

About these practice questions

One of 507 original LFCS 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 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.