3 Basic Commands and Simple Shell Scripts Once you have your first Red Hat Enterprise Linux rhel


TipDon’t feel overwhelmed by the different systemd unit types. In general, the most common ones are service



Download 1.85 Mb.
View original pdf
Page36/67
Date26.02.2024
Size1.85 Mb.
#63678
1   ...   32   33   34   35   36   37   38   39   ...   67
Pablo Iranzo Gómez, Pedro Ibáñez Requena, Miguel Pérez Colino, Scott McCarty - Red Hat Enterprise Linux 9 Administration-Packt Publishing (2022) -chap 3 82 - 180
Tip
Don’t feel overwhelmed by the different systemd unit types. In general, the most common ones are service, timer, socket, and target.
Of course, these unit files are expected to be found in some specific folders, as shown here:
Table 4.2 – System folders containing systemd files
As we mentioned earlier about sockets, unit files for path, bus, and more are activated when a system’s access to that path is performed, allowing services to be started when another one is requiring them. This adds more optimization for lowering system startup times.
With that, we have learned about systemd unit types. Now, let’s focus on the file structure of unit files.
systemd unit file structure
Let’s get our hands dirty with an example a system has been deployed with sshd enabled, and we need to get it running once the network has been initialized in the runlevels, which provide connectivity.
As we mentioned previously, systemd uses unit files, and we can check the aforementioned folders or list them with systemctl list-unit-files. Remember that each file is a configuration file that defines what systemd should do for example, /usr/lib/systemd/system/chronyd.
service, as shown in the following screenshot:

Managing system services with systemd
107
Figure 4.1 – chronyd.service contents
This file defines not only the traditional program to start and the process identifier (PID) file, but the dependencies, conflicts, and soft dependencies, which provides enough information to systemd to decide on the right approach.
If you’re familiar with INI files, this file uses that approach, in that it uses square brackets, [ and ], for sections and then pairs of key=value for the settings in each section.
Section names are case-sensitive, so they will not be interpreted correctly if the proper naming convention is not used.
Section directives are named like so Unit [Install]
There are additional entries for each of the different types, as follows Service Socket Mount [Automount]

Tools for Regular Operations Swap Path Timer [Slice]
As you can see, we have specific sections for each type. If we execute man systemd.unit, it will give you examples, along with all the supported values, for the systemd version you’re using, as illustrated in the following screenshot:
Figure 4.2 – Manual (man) page of systemd.unit
With that, we have reviewed the file structure of unit files. Now, let’s use systemctl to actually manage the service’s status.

Download 1.85 Mb.

Share with your friends:
1   ...   32   33   34   35   36   37   38   39   ...   67




The database is protected by copyright ©ininet.org 2024
send message

    Main page