File permissions in UNIX: Which chmod command adds executable permission for the owner of the file named 'letter' (without altering group or others)?

Difficulty: Easy

Correct Answer: chmod u+x letter

Explanation:


Introduction / Context:
UNIX permissions control who can read, write, or execute files. The chmod command modifies these permissions for the owner (u), group (g), and others (o). Knowing precise symbolic modes is essential when granting just the needed rights.



Given Data / Assumptions:

  • Target file: letter.
  • Goal: add execute permission for the owner only.
  • No changes should be made to group or others.


Concept / Approach:
Symbolic mode in chmod uses entity (u, g, o, a), operator (+, -, =), and permission (r, w, x). To add execute permission for owner only, use chmod u+x letter. This augments existing permissions rather than replacing them.



Step-by-Step Solution:

Identify entity: owner → uOperation: add → +Permission: execute → xCommand: chmod u+x letter


Verification / Alternative check:
List permissions with ls -l letter before and after; the first field’s owner triad should gain x (e.g., from rw- to rwx).



Why Other Options Are Wrong:
chmod ugo+x: Grants execute to everyone (owner, group, others). chmod u+w: Adds write, not execute. chmod g+x: Changes group, not owner. None of the above: Incorrect because chmod u+x letter is right.



Common Pitfalls:
Using = which replaces permissions entirely; accidentally granting execute to all users; forgetting that scripts also may need a valid shebang and executable bit.



Final Answer:
chmod u+x letter

Discussion & Comments

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