ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 78 - XK0-005 discussion

Report
Export

A systems administrator is implementing a new service task with systems at startup and needs to execute a script entitled test.sh with the following content:

The administrator tries to run the script after making it executable with chmod +x; however, the script will not run. Which of the following should the administrator do to address this issue? (Choose two.)

A.
Add #!/bin/bash to the bottom of the script.
Answers
A.
Add #!/bin/bash to the bottom of the script.
B.
Create a unit file for the new service in /etc/systemd/system/ with the name helpme.service in the location.
Answers
B.
Create a unit file for the new service in /etc/systemd/system/ with the name helpme.service in the location.
C.
Add #!//bin/bash to the top of the script.
Answers
C.
Add #!//bin/bash to the top of the script.
D.
Restart the computer to enable the new service.
Answers
D.
Restart the computer to enable the new service.
E.
Create a unit file for the new service in /etc/init.d with the name helpme.service in the location.
Answers
E.
Create a unit file for the new service in /etc/init.d with the name helpme.service in the location.
F.
Shut down the computer to enable the new service.
Answers
F.
Shut down the computer to enable the new service.
Suggested answer: B, C

Explanation:

The administrator should do the following two things to address the issue:

Add #!/bin/bash to the top of the script. This is called a shebang line and it tells the system which interpreter to use to execute the script. Without this line, the script will not run properly. The shebang line should be the first line of the script and should start with #! followed by the path to the interpreter. In this case, the interpreter is bash and the path is /bin/bash. The other option (A) is incorrect because the shebang line should be at the top, not the bottom of the script.

Create a unit file for the new service in /etc/systemd/system/ with the name helpme.service in the location. This is necessary to register the script as a systemd service and enable it to run at startup. A unit file is a configuration file that defines the properties and behavior of a service, such as the description, dependencies, start and stop commands, and environment variables. The unit file should have the extension .service and should be placed in the /etc/systemd/system/ directory. The other option (E) is incorrect because /etc/init.d is the directory for init scripts, not systemd services.

Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 14: Managing Processes and Scheduling Tasks, pages 429-430.

asked 02/10/2024
waleed Haridi
34 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first