Exam4Training

Which of the following processes would accomplish this task?

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?
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

Answer: C

Explanation:

The process that will accomplish the task of creating a custom script to run at boot as part of the system services is:

Create a unit file in the /etc/systemd/system/ directory. A unit file is a configuration file that defines the properties and behavior of a systemd service. The systemd is a system and service manager that controls the startup and operation of Linux systems. The /etc/systemd/system/ directory is the location where the administrator can create and store custom unit files. The unit file should have a name that matches the name of the script, such as cleanup.service, and should contain the following sections and options:

[Unit]: This section provides the general information about the service, such as the description, dependencies, and conditions. The administrator should specify the following options in this section:

Description: A brief description of the service, such as “Custom cleanup script”.

After: The name of another unit that this service should start after, such as “network.target”.

ConditionPathExists: The path of the file or directory that must exist for the service to start, such as “/opt/scripts/cleanup.sh”.

[Service]: This section defines how the service should be started and stopped, and what commands should be executed. The administrator should specify the following options in this section:

Type: The type of the service, such as “oneshot”, which means that the service will run once and then exit.

ExecStart: The command that will start the service, such as “/bin/bash /opt/scripts/cleanup.sh”.

RemainAfterExit: A boolean value that indicates whether the service should remain active after the command exits, such as “yes”.

[Install]: This section defines how the service should be enabled and under what circumstances it should be started. The administrator should specify the following option in this section:

WantedBy: The name of another unit that wants this service to be started, such as “multi-user.target”, which means that the service will be started when the system reaches the multi-user mode.

Run the command systemct1 enable cleanup. This command will enable the service and create the necessary symbolic links to start the service at boot.

Run the command systemct1 is-enabled cleanup. This command will check the status of the service and confirm that it is enabled.

This process will create a custom script, cleanup.sh, to run at boot as part of the system services. This is the correct process to use to accomplish the task. The other options are incorrect because they either use the wrong directory for the unit file (/etc/default/, /etc/skel/, or /etc/sysctl.d/) or do not create a unit file at all.

References: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 15: Managing System Services, pages 457-459.

Latest XK0-005 Dumps Valid Version with 136 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Exit mobile version