One of the major changes in Rhel/centos 7.0 is the switch to systemd. It is used to replace SYSV and upstart in previous versions of Red Hat Enterprise Linux and to manage systems and services. SYSTEMD is compatible with startup scripts for SYSV and Linux standard groups.
Systemd is a system and service Manager under a Linux operating system. It is designed to be backwards compatible with SYSV startup scripts and provides a number of features, such as starting system services in parallel when booting, starting daemons on demand, supporting system state snapshots, or relying on dependent service control logic.
Previous Red Hat Enterprise Linux versions using SYSV initialization or upstart were managed using the Bash init script located in the/etc/rc.d/init.d/directory. In Rhel 7/centos 7, these startup scripts were replaced by service units. The service unit ends with a. service file extension, providing the same purpose as the initialization script. To view, start, stop, restart, enable, or disable system services, you use SYSTEMCTL instead of the old service commands.
Note: For backwards compatibility, the old service command is still available in CentOS 7, which redirects all commands to the new Systemctl tool.
Use Systemctl to start/stop/restart services
To start a service, you need to use the following command:
Systemctl Start Httpd.service
This will start the httpd service, as far as we are concerned, the Apache HTTP server.
To stop it, you need to use the command as root:
Systemctl Stop Httpd.service
To restart, you can use the Restart option, which will restart the service if the service is running, and it will start if the service is not running. You can also use the Try-start option, which restarts the service only when the service is already running. Also, the reload option you can have, it will reload the configuration file.
systemctl Restart Httpd.servicesystemctl try-restart Httpd.servicesystemctl Reload Httpd.service
Check Service status
To check the status of the service, you can use the status option to see here:
Systemctl Status Httpd.service
The output is like this:
It tells you every aspect of the service that you are running.
Use the Enable/disable service to control boot boot
You can also use the enable/disable option to control whether a service starts up, with the following command:
Systemctl Enable httpd.servicesystemctl Disable Httpd.service
Output results See here:
Although the adoption of SYSTEMD has been controversial over the past few years, most mainstream distributions have been gradually adopted or intended to be used in the next release. So, it's a useful tool and we need to get familiar with it.
Linux systemd--Start/stop/restart services in Rhel/centos 7