Enabling and disabling systemd services
Publication Date: 18 Jan 2024 on https://documentation.suse.com/smart/systems-management/html/reference-systemctl-enable-disable-services/index.html
This document applies to the following products and product versions:
- SUSE Linux Enterprise Server 15 SP5, 15 SP4, 15 SP3, 15 SP2, 12 SP5
- SUSE Linux Enterprise Server for SAP Applications 15 SP5, 15 SP4, 15 SP3, 15 SP2, 12 SP5
- SUSE Linux Enterprise High Availability 15 SP5, 15 SP4, 15 SP3, 15 SP2, 12 SP5
- SUSE Linux Enterprise High Performance Computing 15 SP5, 15 SP4, 15 SP3, 15 SP2
- SUSE Linux Enterprise Desktop 15 SP5
- SUSE Linux Enterprise Real Time 15 SP5
2 Enabling and disabling services with systemctl
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
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
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