nerdexam
CompTIA

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.

System Management

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)
  • B
    5% (2)
  • C
    93% (37)
  • D
    3% (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.

ACreate a unit file in the /etc/default/ directory.

The /etc/default/ directory typically stores environment variable definitions for system-wide scripts and services, not unit files.

BCreate a unit file in the /etc/ske1/ directory.

The /etc/skel/ directory contains skeleton files copied to new user home directories upon creation, not systemd unit files.

CCreate a unit file in the /etc/systemd/system/ directory.Correct

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.

DCreate a unit file in the /etc/sysctl.d/ directory.

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

#systemd#service management#boot process#custom scripts

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice