CompTIA Linux+ (XK0-004) — Question 183

Joe, a user, creates a short shell script, shortscript.sh, and saves it in his home directory with default permissions and paths. He then attempts to run the script by typing ./shortscript.sh, but the command fails to execute.
Which of the following commands would have allowed the script to run?

Answer options

Correct answer: A

Explanation

The command 'chmod u+x shortscript.sh' adds execute permissions for the user, which is necessary for the script to run. The 'source' command runs the script in the current shell but does not change permissions, so it wouldn't solve the issue. The 'chmod 155 ~/shortscript.sh' command sets specific permissions that do not include execute for the user, and 'chgrp shortscript.sh Joe' changes the group ownership, which is irrelevant to running the script.