1. Home
  2. Linux
  3. Linux Files
  4. Linux – systemctl command

Linux – systemctl command

Linux systemctl command

The systemctl command is a new tool to control the systemd system and service. This is the replacement of old SysV init system management. Most of modern Linux operating systems are using this new tool. If you are working with CentOS 7, Ubuntu 16.04 or later or Debian 9 system. They have opted systemd now.

Syntax

systemctl [OPTION] [SERVICE]

For this tutorial, All commands are written to show the service management of mysql service on Linux system. Where you can use mysql or mysql.service as a service name.

Start and Stop Service

Use these options to start and stop any service using systemctl.

sudo systemctl start mysql.service
sudo systemctl stop mysql.service
  • Start: To start stopped service
  • Restart: To stop running service
  • Restart or Reload Service

    Use this to reload or restart any service. It also provides reload-or-restart to restart service if reload is not available for any service.

    sudo systemctl reload mysql.service
    sudo systemctl restart mysql.service
    sudo systemctl reload-or-restart mysql.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
  • Status of Service

    Use this to check the status of any service.

    sudo systemctl status mysql.service
    
  • Status: Used to check current status of a service
  • Enable or Disable Service

    Use this to enable or disable any service on your system. The enabled service autostarts on system boot. This is the similar option for systemd than chkconfig for the SysV init.

    sudo systemctl enable mysql.service
    sudo systemctl disable mysql.service
    

    Enable: Used to enable service to start on system boot
    Disable: Used to disable service to not to start on system boot

    Check Service is Enabled or Disabled

    Use this to check if any service is currently active or enabled.

    sudo systemctl is-active mysql.service
    sudo systemctl is-enabled mysql.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
  • Tags , , , ,
    Was this article helpful to you? Yes 24 No 5
    Advertisement