XK0-005 · Question #482
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?
The correct answer is C. Create a unit file in the /etc/systemd/system/ directory. To run a custom script as a system service at boot using systemd, a unit file needs to be created and placed in the appropriate directory.
Question
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?
Options
- ACreate a unit file in the /etc/default/ directory.
- BCreate a unit file in the /etc/ske1/ directory.
- CCreate a unit file in the /etc/systemd/system/ directory.
- DCreate a unit file in the /etc/sysctl.d/ directory.
How the community answered
(40 responses)- B5% (2)
- C93% (37)
- D3% (1)
Why each option
To run a custom script as a system service at boot using systemd, a unit file needs to be created and placed in the appropriate directory.
The /etc/default/ directory typically stores environment variable definitions for system-wide scripts and services, not unit files.
The /etc/skel/ directory contains skeleton files copied to new user home directories upon creation, not systemd unit files.
Systemd service unit files, which define how a service starts and behaves, are typically stored in the /etc/systemd/system/ directory for custom services. After creating the .service file here, it needs to be enabled and started using `systemctl` commands to integrate it into the boot process.
The /etc/sysctl.d/ directory stores configuration files for kernel parameters that can be changed at runtime using `sysctl`, not systemd unit files.
Concept tested: Systemd custom service creation
Source: https://www.freedesktop.org/software/systemd/man/systemd.service.html
Topics
Community Discussion
No community discussion yet for this question.