/commands/systemd/systemctl-enable-now
systemctl enable --now: start a service and enable it at boot
- tool
- systemd
- versions
- systemd 220+
- os
- linux
sudo systemctl enable --now nginx starts the nginx service immediately and configures it to start at every boot. enable alone only sets up the start at boot (it creates symlinks from the unit's [Install] section, usually under /etc/systemd/system/multi-user.target.wants/), and start alone only runs it now. Check the result with systemctl is-enabled nginx and systemctl is-active nginx. The reverse is sudo systemctl disable --now nginx.
Commands
sudo systemctl enable --now nginx # start now and at every boot
systemctl is-enabled nginx # enabled / disabled / masked / static
systemctl is-active nginx # active / inactive / failed
systemctl status nginx # state, main PID, last log lines
sudo systemctl disable --now nginx # stop now and do not start at boot
sudo systemctl mask nginx # forbid any start until unmasked
sudo systemctl unmask nginx
systemctl --user enable --now syncthing # a user service, no sudoAfter enable, systemctl prints the symlink it created, for example Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
Enable states
| is-enabled output | Meaning |
|---|---|
| enabled | Starts at boot through the symlinks from its [Install] section |
| disabled | Has an [Install] section but is not enabled |
| static | No [Install] section; it can only start as a dependency of another unit or by hand |
| masked | Linked to /dev/null; every start is refused |
| indirect | Not enabled itself, but enabled through Also= or a template instance |
| generated | Created at boot by a generator, for example from /etc/fstab |
| alias | The name is an alias of another unit |
Related options
| Command | Effect |
|---|---|
| systemctl enable NAME | Start at boot, not now |
| systemctl enable --now NAME | Start at boot and now |
| systemctl reenable NAME | Disable and enable again, after changing [Install] |
| systemctl daemon-reload | Reload unit files after editing them (needed before enable for new files) |
| systemctl list-unit-files --state=enabled | All units enabled at boot |
| systemctl enable NAME@foo | Enable one instance of a template unit |
Errors you may see
Failed to enable unit: Unit file nginx.service does not exist.: the name is wrong or the package is not installed.systemctl list-unit-files | grep -i nginxshows the real name.- A message starting with
The unit files have no installation config: the unit has no[Install]section; enable does nothing. Add one or start the unit by hand. System has not been booted with systemd as init system (PID 1). Can't operate.: you are in a container or WSL without systemd; use the init system that is there.Interactive authentication required.: run the command withsudo, or use--userfor user services.
Confirm it worked
systemctl is-enabled NAME should print enabled and systemctl is-active NAME active. To prove the start at boot, reboot and run systemctl status NAME, or journalctl -u NAME -b to see its log for the current boot.
FAQ
What is the difference between enable and start?
start runs the service now, for this boot only. enable creates the symlinks that make systemd start it at every boot, but does not start it now. enable --now does both in one command.
Why does enable say the unit has no installation config?
The unit file has no [Install] section, or no WantedBy= or RequiredBy= in it, so systemctl does not know where to hook it in. Add [Install] with WantedBy=multi-user.target, run systemctl daemon-reload, then enable it.
How do I stop a service from starting at boot without uninstalling it?
sudo systemctl disable --now NAME stops it and removes the boot symlinks. systemctl mask NAME goes further and prevents any start, even by hand or as a dependency, until you unmask it.