220-1102 exam dumps

220-1102 practice question 786 of 828

A+ Core 2. Associate level, CompTIA. Free question with the correct answer and a full explanation.

220-1102 Question 786

Single answer.sh

A Linux user downloads a maintenance script named cleanup.sh from the company file server. When the technician tries to run it by typing ./cleanup.sh, the terminal returns: "Permission denied." The technician verifies that the file is in the current directory and that the script contents look valid. Which action should the technician take FIRST to run the script directly from the shell?

  1. A

    Use chmod +x cleanup.sh to add execute permission to the script

  2. B

    Rename the file to cleanup.exe so the shell recognizes it as executable

  3. C

    Use chown root cleanup.sh to change ownership to root

  4. D

    Move the file to /bin so Linux treats it as a command

Show answer and explanation

Correct answer: A

Explanation

This question tests practical Linux file-permission troubleshooting for shell scripts, a relevant A+ Core 2 skill. A .sh file can often be executed in two ways: directly with ./scriptname if it has execute permission, or by invoking an interpreter explicitly, such as sh cleanup.sh or bash cleanup.sh. Because the question asks what should be done FIRST to run it directly from the shell, adding execute permission with chmod +x is the best answer. This aligns with standard Linux administration practices documented in common shell and chmod references, where execute permission is required for direct execution of scripts and binaries.

  • A. Correct.

    Correct. In Linux, a .sh file is typically a shell script and must have the executable permission bit set if you want to run it directly with ./cleanup.sh. The command chmod +x cleanup.sh adds execute permission, which is the most likely fix when the shell reports "Permission denied" for a script in the current directory.

  • B. Incorrect.

    Incorrect. Linux does not use the .exe extension to determine executability the way Windows does. Executability is controlled primarily by file permissions and, for scripts, by a valid interpreter line such as a shebang (for example, #!/bin/bash). Renaming the file would not resolve a permission problem.

  • C. Incorrect.

    Incorrect. Changing ownership to root does not make a script executable. In fact, unnecessarily changing ownership can create administrative or security problems. The issue described is most directly related to missing execute permission, not ownership.

  • D. Incorrect.

    Incorrect. Moving a script to /bin is not required to run it. Files can be run from the current directory with ./filename as long as they have the proper execute permission and a valid interpreter. Also, placing custom scripts in /bin is generally inappropriate for routine user troubleshooting.

Timed practice exam

Take a 220-1102 practice test under exam conditions

90 questions in 90 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam