On Unix/Linux, which command makes all files and subdirectories within the directory named 'progs' executable by all users (recursively)?
-
Achmod -R a+x progs
-
Bchmod -R 222 progs
-
Cchmod -1 a+x progs
-
Dchmod -x a+x progs
-
ENone of the above
Answer
Correct Answer: chmod -R a+x progs
Explanation
Introduction / Context:Permissions control who can read, write, and execute files. When distributing scripts or binaries within a directory tree, administrators often need to grant execute permission broadly so that users can run these files without permission errors. A recursive and user-agnostic approach is typically used.
Given Data / Assumptions:
- Target directory is 'progs' with nested content.
- You want execute permission for user, group, and others.
- You want to apply permissions recursively.
Concept / Approach:'chmod -R a+x progs' applies the execute bit for all classes (a = u,g,o) on every file and subdirectory under 'progs'. This grants traversal on directories and execution on executable files and scripts. It does not remove other permissions; it only adds +x. Alternatives shown are either invalid or set inappropriate modes.
Step-by-Step Solution:
Inspect current permissions: ls -lR progsGrant execute recursively: chmod -R a+x progsVerify changes: find progs -maxdepth 1 -exec ls -ld {{}} \;Adjust more granularly if needed (for example, only on files): find progs -type f -exec chmod a+x {{}} \;Verification / Alternative check:Run a representative script or binary to confirm it executes for non-owner accounts. Check directory traversal by ensuring 'x' is set on directories users must enter.
Why Other Options Are Wrong:
- chmod -R 222 progs: Sets write-only bits, removing execute; unusable.
- chmod -1 a+x progs: Invalid syntax; '-1' is not a valid option.
- chmod -x a+x progs: Conflicting and nonsensical combined flags.
- None of the above: Incorrect because the first option is right.
Common Pitfalls:Blindly setting execute on non-executable documents, or forgetting that directories require 'x' for traversal while files require 'x' for execution.
Final Answer:chmod -R a+x progs