A user reports that a script in /home/user/script.sh fails to execute. The output of 'ls -l script.sh' is '-rw-r--r-- 1 user user 1024 Apr 1 10:00 script.sh'. Which command should be used to make the script executable for all users?
Trap 1: chmod 644 script.sh
644 sets permissions to rw-r--r--, which does not include execute.
Trap 2: chmod u+x script.sh
This adds execute only for the owner, not all users.
Trap 3: chmod 755 script.sh
755 sets rwxr-xr-x, which adds execute for all, but it also changes other permissions unnecessarily. a+x is more precise.
- A
chmod 644 script.sh
Why it fails: 644 sets permissions to rw-r--r--, which does not include execute.
- B
chmod a+x script.sh
chmod a+x adds execute permission for user, group and other, changing the mode from 644 to 755. This makes the script executable by all users, satisfying the stem's requirement, whereas chmod +x alone would be subject to umask.
- C
chmod u+x script.sh
Why it fails: This adds execute only for the owner, not all users.
- D
chmod 755 script.sh
Why it fails: 755 sets rwxr-xr-x, which adds execute for all, but it also changes other permissions unnecessarily. a+x is more precise.