Unix file permissions (chmod): Which command grants execute permission to user, group, and others for every file named 'letter' in the current directory?

Difficulty: Easy

Correct Answer: chmod ugo+x letter

Explanation:


Introduction / Context:
Unix permissions control who can read, write, and execute files. The chmod command changes these modes for the user (u), group (g), and others (o). Granting execute permission is commonly required for scripts and binaries before they can be run.



Given Data / Assumptions:

  • Target filename is literally 'letter' (potentially multiple files named 'letter' across directories, but here we act in the current directory).
  • We want execute permission for all classes: user, group, and others.
  • We assume standard POSIX chmod syntax.


Concept / Approach:

The symbolic chmod form uses u, g, o to denote permission classes and +x to add execute permission. Combining them as ugo+x applies the change to all three classes simultaneously for the specified file(s).



Step-by-Step Solution:

Identify permission classes: user (u), group (g), others (o).Determine operation: add execute permission = +x.Combine in one command: chmod ugo+x letterConfirm with ls -l to verify the x bits are set where intended.


Verification / Alternative check:

Run ls -l letter before and after the chmod. You should see mode bits change, for example, from -rw-r--r-- to -rwxr-xr-x if no other changes occurred. This validates that execute permission is now available to all classes.



Why Other Options Are Wrong:

  • chmod ugo+r letter: Adds read permission, not execute.
  • chmod ugo+rw letter: Adds read and write, but not execute.
  • chmod u+x letter: Grants execute only to the owner (user), not group and others.
  • None of the above: Incorrect because chmod ugo+x letter achieves the stated goal.


Common Pitfalls:

Forgetting that directories require execute (search) permission to enter; applying +x to data files that are not scripts/binaries is harmless but unnecessary. Also, ensure scripts have a proper shebang (for example, #!/bin/sh) when executed.



Final Answer:

chmod ugo+x letter

More Questions from Unix

Discussion & Comments

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