Jump to content

Enabling and disabling systemd services

Publication Date: 11/25/2021

1 Environment

  • File Name: reference-systemctl-enable-disable-services.xml
  • ID: environment-systemd-enable-disable-services

This document applies to the following products and product versions:

  • SUSE Linux Enterprise Server 15 SP3, 15 SP2, 15 SP1, 15 GA, 12 SP5, 12 SP4, 12 SP3

  • SUSE Linux Enterprise Server for SAP Applications 15 SP3, 15 SP2, 15 SP1, 15 GA, 12 SP5, 12 SP4, 12 SP3

  • SUSE Linux Enterprise High Availability Extension 15 SP3, 15 SP2, 15 SP1, 15 GA, 12 SP5, 12 SP4, 12 SP3

  • SUSE Linux Enterprise High Performance Computing 15 SP3, 15 SP2, 15 SP1, 15 GA

  • SUSE Linux Enterprise Desktop 15 SP3, 15 SP2, 15 SP1, 15 GA, 12 SP5, 12 SP4, 12 SP3

  • SUSE Linux Enterprise Real Time 15 SP3, 15 SP2, 15 SP1, 15 GA, 12 SP5, 12 SP4, 12 SP3

2 Enabling and disabling services with systemctl

  • File Name: reference-systemctl-enable-disable-services.xml
  • ID: systemctl-enable-disable-services

systemctl is the systemd command for controlling how services start on a Linux system. A service can be enabled, disabled, or masked, and it can be configured to start at boot, on-demand, manually, or prevented from starting under any circumstances.

Enabling a service means it will start at boot. Disabling a service means it will not start at boot, but can be started manually, or as a dependency of another service. Enabling or disabling a running service does not automatically change its current state; if it is running it will continue to run, and if it is not running it will not start. When you enable or disable a service you have the option to stop or start the service with a separate command, or to enable/disable and start/stop with a single command.

A masked service cannot be started by any means, and must be unmasked to be usable.

3 systemctl commands to enable, disable, and mask services

  • File Name: reference-systemctl-enable-disable-services.xml
  • ID: no ID found
systemctl is-enabled SERVICE-NAME

Check if a service is enabled or disabled.

systemctl status SERVICE-NAME

Check if a service is running, stopped, enabled, or masked, and display the most recent log entries.

systemctl enable SERVICE-NAME

Enable a service, without starting it. It will start automatically at the next system restart, or it can be started manually, or as a dependency of another service.

systemctl enable --now SERVICE-NAME

Enable a service and start it immediately.

systemctl disable SERVICE-NAME

Disable a service. If it is running, it will continue to run until it is stopped manually. It will not start at the next system restart, but can be started manually, or as a dependency of another service.

systemctl disable --now SERVICE-NAME

Disable a service and stop it immediately.

systemctl re-enable SERVICE-NAME

Stop and restart a service, and restore its default start behavior.

systemctl mask SERVICE-NAME

Mask the service so that it cannot be started by any means. It must be stopped manually, or it will continue to run, possibly in an inconsistent state. The mask command does not take the --now option.

systemctl unmask SERVICE-NAME

Unmask the service. It will start after a system restart, or start it manually. The unmask command does not take the --now option.

See xref linkend="FOO" to learn how to stop, start, restart, and reload services manually.

Print this page