Start/stop/restart service in CentOS 7

Source: Internet
Author: User

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.service
# Systemctl Try-restart Httpd.service
# Systemctl 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

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.service
# systemctl Disable Httpd.service


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.

Start/stop/restart service in CentOS 7

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.