Courseiva
Essential CommandshardMultiple ChoiceObjective-mapped

LFCS find Practice Question

A system administrator needs to find all files in /home that are owned by user 'alice' and have been modified in the last 7 days. The administrator then wants to compress those files into a single archive named alice_recent.tar.gz. Which of the following commands accomplishes this?

⚠ Common exam trap

The trap is that candidates may think option A works because it uses `-exec tar -rf` to collect files, but they overlook that `tar -r` does not compress, so the resulting archive is not a .tar.gz file. Option C correctly uses `-z` for compression and process substitution to feed the file list.

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 -czf alice_recent.tar.gz -T <(find /home -user alice -mtime -7)

It uses `tar -czf` with process substitution to compress the files found by `find` into a gzipped tar archive named alice_recent.tar.gz. The `-z` flag enables gzip compression, and `-T <(...)` reads the list of files from the process substitution, which runs `find` to locate files owned by alice modified within the last 7 days. Options A, B, and D either do not compress or use incompatible formats.

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 /home -user alice -mtime -7 -exec tar -rf alice_recent.tar.gz {} +

    Why it's wrong here

    Uses `tar -rf` which appends files to a tar archive but does not compress them. The resulting file is a plain tar archive, not a .tar.gz compressed file, so it does not meet the requirement for compression.

  • find /home -user alice -mtime -7 -print | cpio -o > alice_recent.tar.gz

    Why it's wrong here

    Pipes `find` output to `cpio -o`, which creates a cpio archive, not a tar archive. The output is then redirected to a file named .tar.gz, but the content is not gzip compressed, resulting in an incorrect format.

  • tar -czf alice_recent.tar.gz -T <(find /home -user alice -mtime -7)

    Why this is correct

    Ly uses `tar -czf` with the `-T` option and process substitution to compress the found files into a gzipped tar archive, satisfying both the archiving and compression requirements.

  • find /home -user alice -mtime -7 | tar -cvf alice_recent.tar.gz

    Why it's wrong here

    Pipes `find` output directly to `tar -cvf`, but `tar` expects a list of files on the command line, not via stdin. This command will fail to create the archive because `tar -cvf` does not read file names from stdin.

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.