Courseiva
Shells, Scripting and Data ManagementmediumMultiple ChoiceObjective-mapped

LPIC-1 Shells, Scripting and Data Management Practice Question

A developer has a directory /home/user/project with many files and subdirectories. They need to change the group ownership of all .txt files to 'developers' and set permissions to 640. Which single command accomplishes this?

⚠ Common exam trap

The trap here is that candidates often forget that `chmod` alone cannot change ownership, or they mistakenly think `chown :group` is invalid, leading them to pick an incomplete command like A or D, or they incorrectly assume `chmod -R` with a glob will recurse into subdirectories.

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

find /home/user/project -name '*.txt' -exec chown :developers {} \; -exec chmod 640 {} \;

It uses `find` to locate all `.txt` files under `/home/user/project`, then executes `chown :developers` to change the group ownership to 'developers' (the colon before the group name is the correct syntax for setting only the group), followed by `chmod 640` to set the permissions to read/write for the owner and read for the group. Using `-exec` twice in a single `find` command ensures both operations are applied to each matching file without needing a separate command.

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/project -name '*.txt' -exec chgrp developers {} \;

    Why it's wrong here

    Changes group only, not permissions.

  • chmod -R 640 /home/user/project/*.txt

    Why it's wrong here

    Only changes permissions, not group, and does not recurse into subdirectories.

  • find /home/user/project -name '*.txt' -exec chown :developers {} \; -exec chmod 640 {} \;

    Why this is correct

    Changes both group and permissions in a single find command.

  • find /home/user/project -name '*.txt' -exec chmod 640 {} \;

    Why it's wrong here

    Changes permissions only, not group.

About these practice questions

One of 527 original LPIC-1 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 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.