Courseiva
GNU and Unix CommandshardMultiple ChoiceObjective-mapped

LPIC-1 GNU and Unix Commands Practice Question

A developer wants to change the ownership of all files in a directory tree to the user 'www-data' and group 'www-data', but only files that are currently owned by user 'nobody'. Which command accomplishes this?

⚠ Common exam trap

The trap here is that candidates often forget the `-R` flag for recursion or overlook the `--from` option, leading them to choose a brute-force approach like `chown -R` (option D) that changes all files regardless of current ownership, or a more complex `find`-based solution (option B) that works but is not the most direct command tested.

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

chown -R --from=nobody www-data:www-data /path

The `chown -R --from=nobody www-data:www-data /path` command recursively changes ownership of files and directories only if they are currently owned by the user 'nobody'. The `--from` option specifies the current owner (and optionally group) to match before applying the change, and `-R` ensures recursion into subdirectories. This exactly meets the requirement to change ownership only for files owned by 'nobody'.

Answer analysis

Option-by-option breakdown

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

  • chown --from=nobody www-data:www-data /path

    Why it's wrong here

    Missing -R, so it does not work recursively.

  • find /path -user nobody -exec chown www-data:www-data {} \;

    Why it's wrong here

    This works but is less efficient and not a single command; chown --from is preferred.

  • chown -R --from=nobody www-data:www-data /path

    Why this is correct

    Correctly uses recursive mode and the --from option to limit changes to files owned by nobody.

  • chown -R www-data:www-data /path

    Why it's wrong here

    This changes ownership of all files, not just those owned by nobody.

About these practice questions

This LPIC-1 question is part of Courseiva's 527-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 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.