Skip to content

/commands/systemd/systemctl-enable-now

systemctl enable --now: start a service and enable it at boot

The commands on this page have not been executed by our verification runner yet.updated
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

bash
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 sudo

After 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 outputMeaning
enabledStarts at boot through the symlinks from its [Install] section
disabledHas an [Install] section but is not enabled
staticNo [Install] section; it can only start as a dependency of another unit or by hand
maskedLinked to /dev/null; every start is refused
indirectNot enabled itself, but enabled through Also= or a template instance
generatedCreated at boot by a generator, for example from /etc/fstab
aliasThe name is an alias of another unit
CommandEffect
systemctl enable NAMEStart at boot, not now
systemctl enable --now NAMEStart at boot and now
systemctl reenable NAMEDisable and enable again, after changing [Install]
systemctl daemon-reloadReload unit files after editing them (needed before enable for new files)
systemctl list-unit-files --state=enabledAll units enabled at boot
systemctl enable NAME@fooEnable 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 nginx shows 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 with sudo, or use --user for 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.

Sources