Setting permissions for all user classes: Which UNIX command sets permissions on a file by specifying bits for user, group, and others in one operation?

Difficulty: Easy

Correct Answer: chmod

Explanation:


Introduction / Context:
File security in UNIX is enforced through ownership (user and group) and permissions (read, write, execute) for user, group, and others. Correctly choosing the tool for permission changes prevents configuration drift and security lapses.



Given Data / Assumptions:

  • We need to set or modify permissions for all three classes (u,g,o).
  • We are not changing group ownership or user ownership.
  • Standard POSIX-style utilities are available.


Concept / Approach:

The chmod command sets permission bits using octal or symbolic modes. chown changes file owner (and optionally group). chgrp changes the group association. There is no standard command named chusr.



Step-by-Step Solution:

Use chmod u=rwx,g=rx,o=r file to set an explicit policy.Alternatively use octal, for example chmod 754 file.Verify with ls -l.Use recursive option -R when applying to directories and their contents.Document the policy for repeatability.


Verification / Alternative check:

Run stat file to view detailed mode bits and confirm chmod changes applied as expected.



Why Other Options Are Wrong:

a: chgrp changes the group owner, not permission bits.

b: chown changes user/group ownership, not the permissions.

d: chusr is not a standard UNIX command.

e: Not applicable because chmod is correct.



Common Pitfalls:

Using chmod = (assignment) when intending to add or remove bits; forgetting execute bits on directories; omitting -R for nested trees.



Final Answer:

chmod

Discussion & Comments

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