Linux Kernel EMD-start/stop/restart the service in RHEL/CentOS 7 and systemdrel

Source: Internet
Author: User

Linux Kernel EMD-start/stop/restart the service in RHEL/CentOS 7 and systemdrel

One of the major changes in RHEL/CentOS 7.0 is switchingSystemd. It is used to replace SysV and Upstart in the previous versions of Red Hat Enterprise Edition Linux to manage systems and services. Systemd is compatible with the startup scripts of SysV and Linux Standard groups.

SystemdIs a system and service manager in a Linux operating system. It is designed to be backward compatible with the SysV STARTUP script and provides a large number of features, such as parallel startup of system services at startup, startup of daemon as needed, and support for system status snapshots, or dependency-based service control logic.

In the previous Red Hat Enterprise Linux version that uses SysV initialization or Upstart, use the bash initialization script in the/etc/rc. d/init. d/directory for management. In RHEL 7/CentOS 7, these startup scripts are replaced by service units. The service unit ends with the extension of the. service file and provides the same purpose as the initialization script. To view, start, stop, restart, enable, or disable system services, use systemctl instead of the old service command.

Note: For backward compatibility, the old service command is still available in CentOS 7, And It redirects all commands to the new systemctl tool.

Use systemctl to start/stop/restart the service

To start a service, run the following command:

  1. # Systemctl start httpd. service

This will start the httpd service, as far as we are concerned, the Apache HTTP Server.

To stop it, use this command as root:

  1. # Systemctl stop httpd. service

To restart, you can use the restart option. if the service is running, it restarts the service. If the service is not running, it starts. You can also use the try-start option to restart the service only when the service is running. You can also have the reload option, which reloads the configuration file.

  1. # Systemctl restart httpd. service
  2. # Systemctl try-restart httpd. service
  3. # Systemctl reload httpd. service

The commands in our example will look like the following:

Check service status

To check the service status, you can use the status option. Here:

  1. # Systemctl status httpd. service

The output result is as follows:

It tells you all aspects of the running service.

Use enable/disable services to control startup

You can also use the enable/disable option to control whether a service is started upon startup. The command is as follows:

  1. # Systemctl enable httpd. service
  2. # Systemctl disable httpd. service

The output result is as follows:

You can also run the is-enabled command to check whether the service is automatically started when it is started. The command is as follows:

1. # systemctl is-enabled servicename. service

Although the adoption of systemd has been controversial over the past few years, most mainstream releases have gradually adopted or intend to use it in the next release. Therefore, it is a useful tool and we need to be familiar with it.

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.