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
- A. chmod u+x /home/user/script.sh
- B. chmod 600 /home/user/script.sh
- C. chmod 007 /home/user/script.sh
- D. chmod o+r /home/user/script.sh
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.