CompTIA Linux+ (XK0-005) — Question 220

A user created the following script file:

#!/bin/bash
# FILENAME: /home/user/script.sh

echo "hello world"
exit 1

However, when the user tried to run the script file using the command ~/script.sh, an error returned indicating permission was denied. Which of the following should the user execute in order for the script to run properly?

Answer options

Correct answer: A

Explanation

The correct answer is A, as it grants the user execute permissions on the script, allowing it to run. Option B only provides read and write permissions, not execute. Option C grants minimal permissions and is not appropriate for execution. Option D only allows read permissions for others, which does not enable execution.