So behind all these systemd units there is configuration, and you can manage that.
The systemctl cat command is showing current unit configuration, as this information
is coming from multiple locations. It's recommended to use systemctlcat because that
concatenates all the information so that you have everything in one view.
Many parameters can be used in systemctl, and systemctl
show will show all the available configuration parameters.
Systemctl Edit allows you to edit the service configuration after modifying service configuration. If you do
it the right way, you don't have to do anything. It will be activated immediately.
But if you are directly editing configuration files, it's a smart idea to use
systemctl daemonreload which is telling systemd to pick up all of the changes.
You might also want to use systemctl restart on a service, which is required if you have changed configuration of
the service itself. That means not in the unit file, but in the service configuration file. That's because of a
golden rule in Linux. If you change anything, you need to restart something to be aware of it.
Let me demonstrate how this works.
I would like to show you systemctl cat for SSHD drop because I know SSHD service
is something that I like a lot and that is here in the service definition.
And let me copy these two lines because I want to put that in my HTTPD configuration.
So I'm using sudo systemctl edit on HTTPD service and there we can see it's using the
nano editor. I don't like that very much, but I'm not going to complain about it. What
I need to do is paste the two lines that copied and I need to put them
in a service section as well, because otherwise we risk them not being recognized correctly.
What are these lines doing? Well, these lines are making sure that the service is going to restart
if it fails by default. The setting was for 42 seconds. I don't like that too much.
I'm setting it to 21 seconds, I'm saving my changes and
then I'm going to use sudo systemctl cat on HTTPD service.
What do we see? Well, we see the concatenated content of all the configuration.
Here is the default service file as it comes from the packages.
And in this default service file we have all the configuration. And
then here we have what was created by my edit operation.
So etc systemd system HTTPD service d override config and that will automatically be
included and it will be applied with a higher priority than the default configuration.
So in case of conflicts.
The configuration you created yourself will always win.
So let me get out of here by using Q.
Well, as I told you, if you use systemctl edit you don't have to restart or reboot anything.
We should just be all right.
So what am I going to do? Well, I need to get
back to systemctl status for HTTPD and oh yeah, it's not loaded.
Well I need to start it obviously and let me use sudo systemctl enable now
httpd to start and enable it and then I'm using my status again and this
is showing that the main process is running using process ID 23204 let me kill
-9 that process. I'll tell you more about that later, but for now I'm just
going to do it kill -9 23204 because what do we want to know? We
want to know if my auto restart is active. And here you can see it
activating auto restart because of the parameter that I just changed, it is going to
restart it on failure so it will be back within 20 seconds or so.
And as you can see it's running again since eight seconds. That's what the auto restart is
doing. It's an awesome option and that alone is a good reason why you should like systemd.