How to use systemctl command to manage systemd service

不言
Release: 2019-03-19 14:03:26
Original
3584 people have browsed it

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 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
Copy after login

start: Used to start a stopped service.

stop: Used to stop running services.

For example:

$ sudo systemctl startssh.service
$ sudo systemctl stopssh.service
Copy after login

Restart or reload the service:

$ sudo systemctl reloadssh.service
$ sudo systemctl restartssh.service
$ sudo systemctl reload-or-restartssh.service
Copy after login

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
Copy after login

Status: Used to check the current status of the service

Enable or disable the service:

$ sudo systemctl enablessh.service
$ sudo systemctl disablessh.service
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!