CompTIA Linux+ (XK0-004) — Question 276
An end user is trying to execute a file within a different directory. The end user executes the following command:
[comptia@linux tmp]# ../myabc.sh
-bash: ../myabc.sh: Permission denied
[comptia@linux tmp]#
Which of the following commands should the Linux administrator use to run the shell script within that folder?
Answer options
- A. chmod 0644
- B. chmod g-x myabc.sh
- C. chmod 0755
- D. chmod u-x myabc.sh
Correct answer: C
Explanation
The correct command is 'chmod 0755', as this sets the script's permissions to allow the owner to read, write, and execute, while giving read and execute permissions to the group and others. The other options either do not provide execute permissions or restrict access, which does not resolve the issue.