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

systemd-disable UNIT...

PARAMETERS

UNIT...
    Specifies one or more unit names to disable. The unit names specified must refer to service or socket units.

DESCRIPTION

The systemd-disable command provides a convenient way to disable one or more systemd service or socket units, preventing them from being started automatically on boot. This command effectively removes the symbolic links in the appropriate /etc/systemd/system/*.wants/ directories, thereby disabling the automatic starting. It will search unit files in multiple directories. These could be the system wide unit directory or one of the multiple user directories. Note that it does not stop currently running services; you would need to use systemctl stop for that.

It is crucial to understand that disabling a service with systemd-disable only prevents its automatic startup at boot time. If the service is currently running, it will continue to run until manually stopped or the system is rebooted. Moreover, any other services or units that depend on the disabled service might fail to function correctly. Always review dependencies before disabling services. It is common to use systemctl status to investigate the current status, start and dependencies of a systemd service. If there exists multiple unit definitions, the command will operate on all unit files that match the supplied names.

CAVEATS

Disabling a service only prevents it from starting automatically at boot. It does not stop a currently running service. Always review dependencies before disabling a service as it can potentially break other services.

The command searches for unit files in multiple directories, system wide as well as user specific unit directories.

IMPACT ON DEPENDENCIES

Disabling a service can affect other services that depend on it. Before disabling, use systemctl list-dependencies to check which services depend on the one you're disabling. If critical services depend on the disabled service, consider disabling the dependent services as well or finding alternative solutions.

RE-ENABLING SERVICES

To re-enable a service that was previously disabled with systemd-disable, use the systemd-enable command. This command will re-create the necessary symbolic links in the *.wants/ directories.

HISTORY

systemd-disable is part of the systemd suite of system and service manager tools, which have become increasingly prevalent on Linux distributions since their introduction. It was designed to provide a consistent and centralized way to manage system services, replacing older init systems like SysVinit.

SEE ALSO

systemctl(1), systemd-enable(1), systemd(1)

Copied to clipboard