Skip to content

How to Use Systemctl Command to Manage Systemd Services

Advertisement

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 <servicename> with your actual service name like httpd, mysql, apache2 or ssh.

Start or Stop Service:

Syntax:

$ sudo systemctl start <servicename>.service
$ sudo systemctl stop <servicename>.service
  • start: Used to start a stopped service
  • Stop: Used to stop a running service

Example:

$ sudo systemctl start ssh.service
$ sudo systemctl stop ssh.service

Restart or Reload Service:

$ sudo systemctl reload ssh.service
$ sudo systemctl restart ssh.service
$ sudo systemctl reload-or-restart ssh.service
  • Reload: Used to reload configuration of a running service
  • Restart: Used to restart (Stop/Start) a running service
  • reload-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 status ssh.service
  • Status: Used to check current status of a service

Enable or Disable Service:

$ sudo systemctl enable ssh.service
$ sudo systemctl disable ssh.service
  • Enable: Used to enable service to start on system boot
  • Disable: Used to disable service to not to start on system boot

Check Enable/Disable Status of Service:

$ sudo systemctl is-active ssh.service
$ sudo systemctl is-enabled ssh.service
  • is-active: Used to check if service current service status
  • is-enabled: Used to check if service is enabled to start on system boot

Reference:
https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top