chmod practice: remove execute for the user and grant read to group and others For a file named 'letter', which command removes the user's execute permission while adding read permission for the group and others (without altering other bits)?

Difficulty: Easy

Correct Answer: chmod u - x, go + r letter

Explanation:


Introduction / Context:
Unix/Linux file permissions control access for the user (owner), group, and others. The chmod command supports symbolic changes that precisely add or remove specific rights without overwriting other bits. This question checks your ability to translate a verbal permission change into the correct chmod syntax.



Given Data / Assumptions:

  • Target file: letter.
  • Required changes: remove execute from user; add read to group and others.
  • No other permissions should be changed.


Concept / Approach:

Symbolic modes allow granular updates: u, g, o designate classes; + adds a permission; - removes it. You can combine multiple operations in one command by separating them with a comma, and chmod applies them left to right to the file's mode bits.



Step-by-Step Solution:

Translate “remove execute for user” to: u-x.Translate “add read for group and others” to: go+r.Combine both with a comma and supply the filename: chmod u - x, go + r letter.Confirm with: ls -l letter to observe updated permissions.


Verification / Alternative check:

Before and after comparisons using ls -l show x removed from the user field and r added to the group and others fields. No other bits should change because symbolic mode modifies only specified bits.



Why Other Options Are Wrong:

  • chmod go + x, u - x: adds execute for group/others, the opposite of the requirement.
  • chmod g - x, uo + r: removes execute from group, not user.
  • chmod go + r, u + x: adds execute to user, contradicting the removal requirement.
  • None of the above: incorrect because option with u - x, go + r is correct.


Common Pitfalls:

Using an absolute numeric mode (like 744) which may inadvertently change other bits, or reversing + and - signs under time pressure. Always read the requirement carefully.


Final Answer:

chmod u - x, go + r letter

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion