Home  >  Article  >  Operation and Maintenance  >  How to use systemctl command to manage systemd service

How to use systemctl command to manage systemd service

不言
不言Original
2019-03-19 14:03:263580browse

This article will introduce how to use the systemctl command to manage systemd services. Systemd is a system and service manager for Linux-based operating systems used to manage services. Systemd is more powerful and popular than the old Sysvinit.

How to use systemctl command to manage systemd service

Most newer versions of Linux-based operating systems (for example: CentOS/Redhat 7, Fedora 25, Ubuntu 16.04) use Systemd as the default service management tool.

Before using the following example command, you need to change the c7e7ea64493f98a92f8b3b7bcfd14bdf with the actual service name (such as httpd, mysql, apache2 or ssh).

Start or stop a service:

Syntax:

$ sudo systemctl start <service name> .service 
$ sudo systemctl stop <service name>.service

start: Used to start a stopped service.

stop: Used to stop running services.

For example:

$ sudo systemctl startssh.service
$ sudo systemctl stopssh.service

Restart or reload the service:

$ sudo systemctl reloadssh.service
$ sudo systemctl restartssh.service
$ sudo systemctl reload-or-restartssh.service

Reload: Configuration for reloading the running service

Restart: Used to restart (Stop/Start) a running service

reload-or-restart: Used to reload the service default value, but if the service cannot be reloaded, it will Restart it

Check the service status:

$ sudo systemctl statusssh.service

Status: Used to check the current status of the service

Enable or disable the service:

$ sudo systemctl enablessh.service
$ sudo systemctl disablessh.service

Enable: Used to enable the service to start when the system starts

Disable: Used to disable the service to not start when the system starts

Check the service The enabled/disabled status:

$ sudo systemctl is-activessh.service
$ sudo systemctl is-enabledssh.service

is-active: used to check the current service status of the service

is-enabled: used to check whether the service is enabled when the system starts

This article has ended here. For more exciting content, you can pay attention to the Linux Tutorial Video column on the PHP Chinese website!

The above is the detailed content of How to use systemctl command to manage systemd service. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn