XK0-005 · Question #1559
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…
The correct answer is B. Create a unit file for the new service in /etc/systemd/system/ with the name helpme.service in the C. Add #!//bin/bash to the top of the script. Two issues must be fixed: (1) The script is missing a shebang line at the very top. A shebang (e.g., #!/bin/bash) must be the first line of the script - it tells the kernel which interpreter to use. Option A is wrong because placing it at the bottom does nothing; Option C…
Question
Exhibit
Options
- AAdd #!/bin/bash to the bottom of the script.
- BCreate a unit file for the new service in /etc/systemd/system/ with the name helpme.service in the
- CAdd #!//bin/bash to the top of the script.
- DRestart the computer to enable the new service.
- ECreate a unit file for the new service in /etc/init.d with the name helpme.service in the location.
- FShut down the computer to enable the new service.
How the community answered
(21 responses)- B86% (18)
- D10% (2)
- F5% (1)
Explanation
Two issues must be fixed: (1) The script is missing a shebang line at the very top. A shebang (e.g., #!/bin/bash) must be the first line of the script - it tells the kernel which interpreter to use. Option A is wrong because placing it at the bottom does nothing; Option C correctly places the shebang at the top (the double slash in '#!//bin/bash' is a typo in the question but the intent is the correct first-line shebang). (2) To run the script as a service at startup under systemd, a unit file must be created in /etc/systemd/system/ with a .service extension (Option B). Option E is incorrect because /etc/init.d/ is the legacy SysV init directory, not used by modern systemd-based systems. Restarting or shutting down the computer (D, F) is not a fix for either issue.
Topics
Community Discussion
No community discussion yet for this question.
