CentOS

How to Start, Stop or Restart Services in CentOS 8

How to Start, Stop or Restart Services in CentOS 8

In the old CentOS distribution, you use the service command or directly run a service on your system using the “/etc/init.d/<service-name> start” command. In modern distributions, you can easily start, stop or restart a service on your CentOS system using the systemctl command. The systemctl command is a very useful tool through which you can examine and control the service manager and systemd system. A collection of system management tools, libraries, and daemons gives us complete information about server-wide and systemd services utilization. If systemctl command successfully runs on your system, it will display any output on the terminal window.

We will describe in this tutorial, how to start, stop and restart services on CentOS 8 system using the systemctl utility. Let us implement the useful systemctl commands on CentOS 8 system.

Prerequisites

Users need sudo privileges to start, stop and restart a service.

Start service on CentOS using systemctl command

To start a service on your system, use the following syntax:

$ sudo systemctl start {service-name}

For example, to start the httpd service on your system run the below-given command:

$ sudo systemctl start httpd

Check service status using systemctl command

To check the service running status on your CentOS 8 system, follow the following command syntax:

$ sudo systemctl status {service-name}
$ sudo systemctl status httpd

The above command will show the running or deactivate status on the terminal window. If the specified service is running on your system then, active (running) status should display on the screen as follows:

Stop service on CentOS using systemctl command

Sometimes, we need to stop service on your system to start a new service. So, to stop or deactivate the running service on your system, use the following syntax:

$ sudo systemctl stop {service-name}
$ sudo systemctl stop httpd

After executing the above command, the running service will stop on your system. Now, check the status. The service deactivate (dead) status will display on the terminal window as follows:

Restart a service using systemctl on CentOS 8

To restart a service on CentOS 8, use the below-mentioned syntax:

$ sudo systemctl restart {service-name}

For example, to restart the stopped httpd service, run the following command:

$ sudo systemctl restart httpd

Reload service using systemctl command 

To reload all the configuration files forcefully on your system, type the following command to reload a service:

$ sudo systemctl reload {service-name}

To reload the httpd service on your CentOS system, run the below-given command:

$ sudo systemctl reload httpd

Enable and disable service using systemctl command

Systemctl service also helps users to enable and disable a service. To enable the httpd service on your system use the below-given command:

$ sudo system enable httpd

If you want to disable the httpd service due to some port issues. Then, run the below-mentioned command to disable it:

Conclusion

We have shown in this article how to start, stop and restart the httpd service on CentOS 8 system with the help of the systemctl command. Using this utility, you can easily control any systemd and server-wide service on your system. Give us your suggestions or feedback about this article. Thanks!

 

Similar Posts