LinuxCommandLibrary

systemctl-disable

Disable a systemd unit 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...] NAME...

PARAMETERS

--now
    Immediately stop the service after disabling it.

--quiet
    Suppress output messages.

--dry-run
    Simulate the disable operation without actually making changes to the system. Useful for testing.

--no-reload
    Do not trigger a daemon reload after disabling the unit. This can be used if the reload is not needed or if it would cause problems.

--root=PATH
    Operate on the specified root directory.

--system
    Connect to the system manager. This is the default.

--user
    Connect to the user's service manager.

DESCRIPTION

The systemctl disable command disables one or more system unit files (services, targets, etc.), preventing them from being automatically started during system boot. It achieves this by removing symbolic links (symlinks) to the unit files from the relevant target directories (typically multi-user.target.wants and graphical.target.wants) that control the default system state.
This command only affects future boots; it does not stop already running services. To stop a running service, use the 'systemctl stop' command.
Disabling a service makes it inactive, meaning it won't be started automatically. The unit files themselves remain on the system, so the service can still be started manually using 'systemctl start'. Using 'systemctl enable' will re-establish the automatic startup links and undo the effects of 'systemctl disable'.

CAVEATS

Disabling a service does not prevent it from being started manually or as a dependency of another enabled service. You need to mask a service to completely prevent it from being started.
Using the command without the unit name may lead to an error

EXIT CODES

On success, 0 is returned; otherwise, a non-zero failure code is returned.

HISTORY

systemctl is a systemd utility. systemd itself replaced System V init in many Linux distributions, and thus systemctl disable replaced similar functionality previously provided by distribution-specific tools for managing services. systemd was first released around 2010 and has seen widespread adoption. The disable command provides a standardized way to prevent services from starting at boot across systemd-based distributions.

SEE ALSO

systemctl(1), systemctl-enable(1), systemctl-start(1), systemctl-stop(1), systemctl-mask(1)

Copied to clipboard