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


Managing services to be started and stopped at boot



Download 1.85 Mb.
View original pdf
Page37/67
Date26.02.2024
Size1.85 Mb.
#63678
1   ...   33   34   35   36   37   38   39   40   ...   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
Managing services to be started and stopped at boot
Services can be enabled or disabled that is, the services will or won’t be activated on system startup.
If you’re familiar with the previous tools available in Red Hat Enterprise Linux (RHEL), it was common to use chkconfig to define the status of services based on their default rc.d/ settings.

Managing system services with systemd
109
The sshd service can be enabled via the following command:
#systemctl enable sshd
It can also be disabled via the following command:
#systemctl disable sshd
This 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.
Tip
Although 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 sshd
To stop it, use the following command:
#systemctl stop sshd
Of 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 daemon
This 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.

Download 1.85 Mb.

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




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

    Main page