Changing file permissions: make file named report executable for everyone Which chmod command grants execute permission to user, group, and others on a file named report (without altering other permissions)?

Difficulty: Easy

Correct Answer: chmod ugo+x report

Explanation:


Introduction / Context:
File permissions control who can read, write, or execute files on Unix/Linux systems. Making a script or program executable is a common administrative task. Using chmod with the correct symbolic mode ensures that only the intended permission bits are changed, preserving the rest of the file’s mode.



Given Data / Assumptions:

  • The file is named report in the current directory.
  • We want to add execute permission for user (u), group (g), and others (o).
  • We do not want to remove existing read or write permissions.


Concept / Approach:

chmod supports symbolic modes such as ugo+x to add execute permission to all three classes without disturbing other bits. This is safer than absolute numeric modes when you only want to add a specific capability. After applying, the executable bit is set for user, group, and others, enabling the file to be run as a program if its contents allow.



Step-by-Step Solution:

Identify required change: add execute for all classes.Use the additive symbolic form: chmod ugo+x report.Verify with ls -l report to see x bits added to user, group, and others.Optionally, use a numeric form such as chmod 755 if you also want to enforce specific read/write bits.


Verification / Alternative check:

Run ls -l before and after. If permissions were, for example, rw-r--r--, after the change they will become rwxr-xr-x. The only difference should be the addition of execute bits.



Why Other Options Are Wrong:

  • chmod u+x report: adds execute only for the user, not for group and others.
  • chmod ugo+rw report: adds read and write, not execute.
  • chmod ugo+r report: adds only read permission.
  • None of the above: incorrect because chmod ugo+x report is correct.


Common Pitfalls:

Confusing symbolic and numeric modes, unintentionally removing permissions by using an absolute numeric mode without considering current bits, or forgetting that scripts need a valid shebang line to run as expected even when marked executable.


Final Answer:

chmod ugo+x report

Discussion & Comments

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