nerdexam
Cisco

350-201 · Question #20

An engineer has created a bash script to automate a complicated process. During script execution, this error occurs: permission denied. Which command must be added to execute this script?

The correct answer is A. chmod +x ex.sh. The 'permission denied' error indicates the script file lacks execute permission. The chmod +x command grants that permission so the script can be run directly.

Automation

Question

An engineer has created a bash script to automate a complicated process. During script execution, this error occurs: permission denied. Which command must be added to execute this script?

Options

  • Achmod +x ex.sh
  • Bsource ex.sh
  • Cchroot ex.sh
  • Dsh ex.sh

How the community answered

(35 responses)
  • A
    91% (32)
  • B
    3% (1)
  • C
    6% (2)

Why each option

The 'permission denied' error indicates the script file lacks execute permission. The chmod +x command grants that permission so the script can be run directly.

Achmod +x ex.shCorrect

chmod +x modifies the file's permission bits to add the execute flag for the owner, group, and others, which directly resolves a 'permission denied' error when attempting to run a shell script. Without this flag set, the operating system refuses to execute the file as a program regardless of its content.

Bsource ex.sh

source reads and executes the script in the current shell context without requiring the execute bit, but it does not grant execute permission and is not the standard fix for a permission denied error.

Cchroot ex.sh

chroot changes the apparent root directory for a running process and has no relationship to file execute permissions.

Dsh ex.sh

sh ex.sh invokes the shell interpreter directly with the script as an argument and bypasses the execute permission check, but it does not add execute permission to the file itself as the question requires.

Concept tested: Linux file execute permissions using chmod

Source: https://www.gnu.org/software/coreutils/manual/html_node/chmod-invocation.html

Topics

#bash scripting#chmod#file permissions#Linux commands

Community Discussion

No community discussion yet for this question.

Full 350-201 Practice