Hello and welcome to this presentation on the systemd System and Service Manager on
Oracle Linux 8.
In this video, you are introduced to systemd, which is the initialization system and service
manager in Oracle Linux 8.
For our objectives today, after viewing this video, you should be able to:
Describe the systemd process and what it manages Describe systemd units and unit configuration
files directories List the many features of systemd
And use the systemctl command to start and stop systemd service units
This slide provides an introduction to systemd.
systemd is the initialization system and service manager in Oracle Linux 8.
systemd is backward compatible with the System V init scripts that were used in earlier versions
of Oracle Linux.
In Oracle Linux 8, systemd is the first process that starts after the system boots, and is
the final process that is running when the system shuts down.
systemd controls the final stages of booting and prepares the system for use.
It also speeds up booting by loading services concurrently.
systemd allows you to manage various types of units on a system.
For example, systemd service units start and control daemons and the processes they consist
of.
Service unit file names have a .service extension.
systemd target units group units or provide well-known synchronization points during boot-up.
Target unit file names have a .target extension.
systemd device units expose kernel devices and can be used to implement device-based
activation.
Mount units control mount points in the file system.
Socket units encapsulate local interprocess communication or network sockets, which are
useful for socket-based activation.
Additional systemd unit types include automount, path, scope, slice, snapshot, swap, and timer.
We will not be covering all of these unit types in detail in this video but there is
a man page available for each of these that you can refer to.
systemd units are defined by unit configuration files located in the directories listed on
the slide.
/usr/lib/systemd/system contains systemd units included with installed RPM packages.
/run/systemd/system contains systemd units created by a running program.
These take precedence over units in the /usr/lib directory.
/etc/systemd/system contains systemd units created and managed by the system administrator.
These take precedence over units in all other directories.
This slide describes some features of systemd.
Listening sockets are created at boot time for certain system services.
These services can start in parallel and can also be restarted without losing any message
content.
System services can be started on-demand when a client attempts to communicate, when a piece
of hardware becomes available, and when a file or directory
state changes.
Processes are tracked by using Control Groups, or cgroups.
A cgroup is a collection of processes that are bound together so that you can control
their access to system resources.
Snapshotting of the system state and restoration of the system state from a snapshot is supported.
And mount and automount points can be monitored and managed by systemd.
This slide introduces the systemctl utility.
Use the systemctl utility to control the systemd system and service manager.
A few examples are shown on the slide.
Use the systemctl list-units command to list units that systemd currently has in memory.
You can included the --type option and provide a unit type, such as service, target, socket,
and so forth, to limit the display to certain unit types.
Include the --all option with the list-units command to also show inactive units.
Without including the --all option, only units which are active, or have pending jobs, or
have failed are shown.
Use the systemctl list-unit-files command to list unit files installed on the system.
Use the systemctl command to enable or disable a service to start at boot time.
Use the systemctl command to start or stop a service.
You can also use the systemctl status command to show runtime status information about one
or more units, followed by the most recent log data from the journal.
There are many systemctl commands and options not shown.
Refer to the systemctl man page for more information.
Now lets run a few of these systemctl commands.
I'm logged on to my Oracle Linux 8 system.
I'll run the systemctl list-units command to list units that systemd currently has in
memory.
Notice we're getting all systemd unit types, such as automount, device, mount, path, scope,
service.
The LOAD column shows that these units are loaded into memory.
There is also an ACTIVE column which shows these are all active.
The SUB column information varies based on the unit type.
And there is a DESCRIPTION column which provides a brief description of the unit.
I'll scroll down to the end of the report and we get some summary information.
I'll run the command again, but this time I just want to see service unit types.
Now we see only units with a .service extension in the name.
Also notice that all of these are active.
I'll scroll down and see the total number of loaded units listed.
I'll run the command again with the --all option to include inactive units.
Now we see some service units that are inactive, and some that are not-found, meaning the unit
file for this unit was not-found.
I'll run the systemctl list-unit-files command to list unit files installed on the system.
Here we get a list of all unit files on the system and the state of each.
Notice we're seeing mount units, path units, scope units, service units, and so on.
I'll run the command again, but this time I just want to see service unit files.
Instead of the --type option, you can use just the -t option and provide the service
argument.
Now we're just seeing service unit files and their state.
Services that are enabled, start at boot time.
I'll scroll down to the end and see the total unit files listed.
You can use the systemctl --state=help command to view the available states for each unit
type.
I'll scroll up and view these.
You can view the status of a specific service by running the systemctl status command.
I'll run the systemctl status command for the chronyd service.
Notice this service is enabled and loaded into memory.
The unit file is /usr/lib/systemd/system/chronyd.service.
This service is active or running.
Output also shows that there are man pages for chronyd and for chrony.conf.
The process ID is shown.
Control group, or cgroup information is shown.
And at the bottom is the most recent log data from the journal.
You can also disable, enable, start, and stop a service by using the systemctl command.
I'll run systemctl stop to stop the chronyd service.
I'll view the status again and see that chronyd is now inactive or dead, but it is still loaded
or enabled.
When a service is enabled, it will automatically start at boot time.
I'll run systemctl disable command to disable the chronyd service from starting at boot
time.
Notice that disabling a service removes a systemd target file.
I'll run the systemctl enable command to enable chronyd.
And notice that enabling a service creates a systemd target file.
We'll discuss systemd targets in another video.
One important thing to remember is that enabling a service does not immediately start the service.
Enabling a service means start the service at boot time.
To start a service immediately, use the systemctl start command.
I'll start the chronyd service and then view the status.
Now the service is back to where it was when we began this demonstration.
It is enabled and active.
Oracle provides an extensive number of resources which you can use to learn more about this
subject and others.
Look for additional videos on the Oracle Linux 8 boot process covering systemd targets and
other Linux boot process topics.
This concludes this presentation.
Thank you for watching.