ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 116 - XK0-005 discussion

Report
Export

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 cleanupsystemctl is-enabled cleanup
Answers
A.
Create a unit file in the /etc/default/ directory.systemctl enable cleanupsystemctl is-enabled cleanup
B.
Create a unit file in the /etc/ske1/ directory.systemctl enable cleanupsystemctl is-enabled cleanup
Answers
B.
Create a unit file in the /etc/ske1/ directory.systemctl enable cleanupsystemctl is-enabled cleanup
C.
Create a unit file in the /etc/systemd/system/ directory.systemctl enable cleanupsystemctl is-enabled cleanup
Answers
C.
Create a unit file in the /etc/systemd/system/ directory.systemctl enable cleanupsystemctl is-enabled cleanup
D.
Create a unit file in the /etc/sysctl.d/ directory.systemctl enable cleanupsystemctl is-enabled cleanup
Answers
D.
Create a unit file in the /etc/sysctl.d/ directory.systemctl enable cleanupsystemctl is-enabled cleanup
Suggested 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 "multiuser. target", which means that the service will be started when the system reaches the multi-user mode.

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

Run the command systemctl 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. Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 15:

Managing System Services, pages 457-459.

asked 02/10/2024
Ismaiel Al-Mufleh
47 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first