And here we are then working on our AlmaLinux 8.5 system,
where we're going to challenge you to follow through with these
discoveries as we look at the systemd ecosystem.
So here we are on our glorious AlmaLinux 8 system.
It's a straight out virtual box,
but the only thing that I've added to it is I've added
in some Bash completion scripts,
and these scripts are really going to help us when we're using systemctl.
Often, it would be installed on a standard install,
but like most things, trying to keep a virtual machine small as possible,
it wasn't included by default, so I've already added this in.
But if you're not getting Bash completion,
so tab completion, when you're using systemctl,
make sure that you run the yum install and bash‑completion.
The easiest, once you've installed it, is just log out and log back in again,
and you'll read those scripts during your login script.
I can then go ahead and use systemctl and status.
Status by itself without any service names will show me all
services that are running and managed by the system.
So we get a great one‑stop shop that we can go to to list
all of our running services on our system,
irrelevant of the Linux distribution.
Systemctl and status and then putting in one or more service names,
here, I'm using chronyd, we can look then our time synchronization server.
.service is the default unit type,
so even though tab completion is going to put it in for me,
I can take the unit file out when we're working with service units.
The great thing about this status command is that I'm able to see that
it's running and that it's been running for 40 minutes.
It is also enabled, so it's going to start on system boot,
some really great information that I can get straight out of it.
We can also see the process IDs that it's running,
and we can go through and see any log file entries.
Currently, we're not seeing anything from the log file.
But this is a really, really useful command.
Now when working with our services,
we run sudo to gain our administrative privileges and then systemctl.
The status command doesn't need administrative privileges,
but we do if we're going to disable the service.
Disabling will disable the service so it won't start
on boot; it won't stop the service.
But if I include the option ‑‑now, it will both disable and stop the service,
so I can use one command to essentially run the disable and the stop.
When I go through now and take a look at my status,
we can see that it is not running, it's not active,
and the service is disabled, and we're seeing more information in the log,
as we stopped the service.
And it's the same sort of approach that I can use when enabling the service.
Rather than using an enable command and then a start command,
I can go through and run and enable ‑‑now,
and that will both enable and start the service.
And we can see now that our service has been running 2 seconds.
So that just shows you some of the service management commands,
some of which we've already seen as we've been going
through looking at our system so far.
But we can also go through and start analyzing the boot time on a system.
When we look at the systemd ‑analyze command,
we can see that we loaded the kernel, we loaded the RAM disk,
and then our service is 7.89 seconds, so a total of just under 11 seconds.
So we get a really good idea of how long the system took to boot.
However, if it was taking a long time,
we might want to try and work out a little bit more what
was taking the greatest amount of time.
So we can go through and see that with, I think,
sometimes unfairly named option but a good option,
isn't it,
blame and it lists then the service by the longest running service first.
So that was in this case the SSSD service,
our security subsystem service, and that was 2.1 seconds.
And then you can see we're gradually breaking down into the makecache.service,
the polkit, all taking slightly less time.
But to improve it,
we certainly want to be looking at those higher‑listed
services to tune those the most.
But this gives us uniformity in our service management across distributions,
but it also touches other aspects of our Linux administration life.
Rather than having to know where specifically a distribution
needs to have its hostname configured, we can use the hostnamectl command,
and that's going to be then consistent across all of our
Linux distributions that make use of systemd.
So with hostnamectl and set‑hostname,
this is where some of our tab completion starts
really coming in for the options.
I'm going to set it to almalinux.
Now of course, my prompt hasn't changed.
It will when I log out and log in again.
But if I go through and now run the hostnamectl command,
I've set the static hostname,
as well as it being set in the current running environment.
And I didn't need to know the file to write to.
And it's the same sort of approach we can take when
managing our time and date settings.
If I want to set the correct time zone,
I can then go ahead and use set‑timezone and then Europe,
and again, I get tab completion here.
Europe and London will suit me, so that's the correct time zone set.
We see that now that we've got GMT time specified,
so we're good to go with this.
And also, look at this, the localectl.
I can go through and set properties for my locale,
and I can go through and set the locale variable LANG.
And I can set LANG then to equal, and as we go through,
I get tab completion on the values that I can put in,
so en_, and I can see there that I've got GB,
and then let's clear the screen, move it to the top,
and we can see then GB.utf8.
And it's this uniformity and one way of setting things
that I really like about systemd, and we're going to find this on most modern Linux distributions.