CompTIA Linux+ (XK0-005) — Question 139
A Linux engineer needs to create a custom script, cleanup.sh, to run at boot as part of the system services. Which of the following processes would accomplish this task?
Answer options
- A. Create a unit file in the /etc/default/ directory. systemctl enable cleanup systemctl is-enabled cleanup
- B. Create a unit file in the /etc/ske1/ directory. systemctl enable cleanup systemctl is-enabled cleanup
- C. Create a unit file in the /etc/systemd/system/ directory. systemctl enable cleanup systemctl is-enabled cleanup
- D. Create a unit file in the /etc/sysctl.d/ directory. systemctl enable cleanup systemctl is-enabled cleanup
Correct answer: C
Explanation
The correct answer is C because systemd unit files should be placed in the /etc/systemd/system/ directory to manage services. Options A, B, and D reference incorrect directories that do not serve the purpose of defining systemd services, thus they will not work for setting up the script to run at boot.