Managing system services with systemd
109
The sshd service can be enabled via the following command:
#systemctl enable sshdIt can also be disabled via the following command:
#systemctl disable sshdThis results in creating or removing /etc/systemd/system/multi-user.target.wants/
sshd.service. Notice multi-user.target in the path, which is the equivalent of the runlevel we used to configure other approaches such as initscripts.
TipAlthough traditional usage of chkconfig (once installed) is provided for compatibility so that chkconfig sshd on/off or service start/stop/status/restart sshd is valid, it is better to get used to the systemctl approach described in this chapter.
The previous commands enable
or disable the service at boot, but for executing an immediate action, we need to issue different commands.
To start the sshd service, use the following command:
#systemctl start sshdTo stop it, use the following command:
#systemctl stop sshdOf course, we can also check the service’s status. Here is an example of looking at systemd via systemctl status sshd:
Tools for Regular Operations
110
Figure 4.3 –
Status of sshd daemonThis status information provides details about the unit file defining the service, its default status at boot,
if it is running or not, its PID, some other details about its resource consumption, and some of the most recent log entries for the service, which are quite useful when you’re debugging simple service start failures.
One important thing to check is the output of systemctl list-unit-files as it reports the defined
unit files in the system, as well as the current status and the vendor preset for each one.
Now that we have covered how to start/stop and status check services, let’s work on managing the actual system boot status itself.
Share with your friends: