This article will help you to how to manage services using the systemctl command for Systemd services. Systemd is a system and service manager for Linux-based operating systems for managing services. Systemd is more powerful and getting more popularity over older SysVinit. Most of newer release of the Linux-based operating system (eg: CentOS/Redhat 7, Fedora 25, Ubuntu 16.04) using Systemd as a default service management tool.
Before using the following example commands change <
Advertisement
Start or Stop Service:
Syntax:
$ sudo systemctl start <servicename >.service $ sudo systemctl stop <servicename >.service
start: Used to start a stopped serviceStop: Used to stop a running service
Example:
$ sudo systemctl startssh .service $ sudo systemctl stopssh .service
Restart or Reload Service:
$ sudo systemctl reloadssh .service $ sudo systemctl restartssh .service $ sudo systemctl reload-or-restartssh .service
Reload: Used to reload configuration of a running serviceRestart: Used to restart (Stop/Start) a running servicereload-or-restart: Used to reload a service default, but if reload is not available for that service. It will restart it
Check Status of Service:
$ sudo systemctl statusssh .service
Status: Used to check current status of a service
Enable or Disable Service:
$ sudo systemctl enablessh .service $ sudo systemctl disablessh .service
Enable: Used to enable service to start on system bootDisable: Used to disable service to not to start on system boot
Check Enable/Disable Status of Service:
$ sudo systemctl is-activessh .service $ sudo systemctl is-enabledssh .service
is-active: Used to check if service current service statusis-enabled: Used to check if service is enabled to start on system boot
Reference:
https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet