systemctl-enable
Enable services to start on boot
TLDR
Enable a service to run on boot
Enable a service to run on boot and start it now
SYNOPSIS
systemctl enable [OPTIONS...] NAME...
PARAMETERS
NAME...
The name of one or more service unit files to enable. For example, `nginx.service`.
--now
Enable the unit and also start it right away. If you need to also stop, use --also and the equivalent disable parameter with start.
--also
Enables all unit files listed in the Install section's Also= setting in the unit file.
--preset
Enable only according to preset policies.
--no-reload
Do not ask systemd to reload.
--quiet
Suppress output messages.
--dry-run
Simulate the operation. This will only show what will happen without performing the modification.
--root=ROOT
Operate on files located in the specified root directory.
--system
Connect to the system manager. This is the default.
--user
Connect to the user manager.
--machine=MACHINE
Operate on a remote machine.
DESCRIPTION
The `systemctl enable` command is a crucial utility for managing system services in Linux distributions using systemd as the init system. It's primary function is to create symbolic links in the appropriate target directories (typically `/etc/systemd/system/*.wants/`) that point to the service unit file (usually found in `/usr/lib/systemd/system/`). These symbolic links instruct systemd to start the service during the boot process or when a specific target is reached.
Enabling a service ensures that it will be started automatically whenever the system boots up. Without enabling a service, it can only be started manually using `systemctl start`.
The command handles dependencies. If a service requires other services to be running, systemd will ensure those dependencies are met before starting the enabled service.
It does *not* start the service immediately; it only configures systemd to start it at boot or when a target is reached. To immediately start a service, you must use `systemctl start`. Enabling a service that is already running is permissible and ensures the service will start up during the next system boot.
CAVEATS
Enabling a service doesn't automatically start it immediately. Use the `--now` option for that. Incorrectly enabling services can lead to boot problems. Always check dependencies.
UNDERSTANDING TARGETS
Systemd uses the concept of 'targets,' which are similar to runlevels in traditional init systems. Enabling a service typically links it to a specific target, such as `multi-user.target` (for normal multi-user system operation) or `graphical.target` (for systems with a graphical user interface). Systemd determines when to start services based on these targets.
HISTORY
The `systemctl` command and the systemd init system were developed as a replacement for older init systems like System V init. systemd was created by Lennart Poettering and Kay Sievers. systemd was first released in 2010. Over time, it became the default init system for many major Linux distributions, including Fedora, Ubuntu, Debian, and RHEL. `systemctl enable` is a core part of systemd's service management capabilities.