chmod operators (symbolic mode) Which operator with chmod assigns absolute permissions by setting them exactly (replacing previous bits) for the specified classes?

Difficulty: Easy

Correct Answer: =

Explanation:


Introduction / Context:
File permissions in UNIX/Linux can be modified using chmod in symbolic or numeric modes. Symbolic mode uses operators to add, remove, or set permissions for user (u), group (g), others (o), or all (a). Understanding these operators is vital for secure configuration and reproducible scripts.


Given Data / Assumptions:

  • Symbolic notation: classes u, g, o, a and permissions r, w, x.
  • Operators available: +, -, =.
  • Goal: assign an exact set of permissions, replacing previous ones.


Concept / Approach:
The operator = sets the permissions absolutely, meaning only the listed bits remain for the targeted classes. In contrast, + adds bits and - removes bits relative to the current state. Numeric mode (e.g., 750) is also “absolute,” but in symbolic syntax, = is the exact-set operator.


Step-by-Step Solution:
To set group to read-only exactly: chmod g=r fileTo set user read/write, group read, others none: chmod u=rw,g=r,o= fileCompare with additive: chmod g+r leaves any existing x intact.Verify permissions: ls -l file


Verification / Alternative check:
Use stat or ls -l before and after to confirm that = replaced previous bits instead of toggling incrementally.


Why Other Options Are Wrong:
+ (Option A) adds bits without clearing others.- (Option B) removes bits without affecting the rest.% (Option D) is not a chmod operator.


Common Pitfalls:

  • Using + when you intend to reset the class entirely.
  • Omitting a class (defaults to a, which may be broader than intended).
  • Forgetting commas between multiple specifications.


Final Answer:
=

Discussion & Comments

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