LinuxCommandLibrary

systemd-disable

Disable systemd services from starting automatically

TLDR

Stop a service from running on boot

$ systemctl disable [unit]
copy

Stop a service from running on boot and stop its current execution
$ systemctl disable [unit] --now
copy

SYNOPSIS

systemctl disable [OPTIONS...] UNIT...
systemctl disable [OPTIONS...] PATH...

PARAMETERS

-h, --help
    Displays a short help text and exits.

--version
    Shows the version of systemd and exits.

--root=PATH
    Operates on a specific root directory PATH instead of the default root directory.

--runtime
    Makes changes only in the runtime directory (/run/systemd/system), which are lost on reboot.

--force
    Overrides specific refusals to disable units, such as disabling units that are masked.

--now
    Disables the unit(s) and also stops them immediately.

--quiet
    Suppresses output messages from the command.

DESCRIPTION

The action of "systemd-disable" refers to preventing systemd units (like services, sockets, or timers) from being automatically started at system boot. This operation is primarily performed using the systemctl disable command. When a unit is disabled, systemd removes the symbolic links from the appropriate .wants/ or .requires/ directories in the systemd configuration (e.g., /etc/systemd/system/*.wants/). This ensures that during subsequent boot processes, systemd will not activate the disabled unit automatically. It's the opposite of systemctl enable, which creates these links to ensure a unit starts automatically. Disabling a unit only affects its auto-start behavior; it does not stop the unit if it is currently running. To stop a running unit, systemctl stop must be used.

CAVEATS

The command "systemd-disable" itself does not exist as a standalone executable. The functionality to disable systemd units is provided by the systemctl disable command, which is the standard utility for controlling the systemd system and service manager. Disabling a unit prevents its automatic startup on subsequent boots but does not stop it if it is currently running. To stop a running unit, the systemctl stop command must be used separately, or the --now option can be used with systemctl disable.

HOW DISABLING WORKS INTERNALLY

When a unit is disabled using systemctl disable, systemd removes the symbolic links that point from /etc/systemd/system/*.wants/ or /etc/systemd/system/*.requires/ (or their equivalents in /usr/lib or /run) to the unit's definition file. These symlinks are what systemd uses to determine which units to activate automatically when a specific target (like multi-user.target) is reached during boot. Removing these links ensures the unit is no longer automatically pulled into the boot process.

HISTORY

The systemd initialization system, and consequently the systemctl utility, were introduced to Linux distributions starting in the early 2010s, gradually replacing older init systems like SysVinit and Upstart. systemctl was designed as the central command-line interface for controlling and querying the state of the systemd manager, making operations like enabling and disabling units a fundamental part of system administration in modern Linux environments.

SEE ALSO

systemctl(1), systemctl enable(1), systemctl start(1), systemctl stop(1), systemctl status(1), systemd.unit(5)

Copied to clipboard