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 the old SysV inits system management. Most 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 systems now.

Syntax

systemctl [OPTION] [SERVICE]

For this tutorial, All commands are written to show the service management of MySQL service on the 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 the 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 the 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 the system boot. This is a similar option for the system 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
  • Reactions

    Post a Comment

    0 Comments

    close