Starting, Stopping and Enabling

Now versus at boot

There are two different questions for any service, and two different commands:

CommandWhat it does
systemctl start / stopRun it (or stop it) right now
systemctl restartStop then start — to pick up a new configuration
systemctl enable / disableSet whether it starts at boot
systemctl is-enabledSay whether it's set to start at boot

Here's a demo service. Start it and check it's active, then stop it again:

sudo systemctl start demo.service
systemctl is-active demo.service
sudo systemctl stop demo.service
systemctl is-active demo.service

In the terminal (is-active prints inactive after stop, so the last command's exit status is 3)

student@vulntech:~$ sudo systemctl start demo.service
[sudo] password for student:
student@vulntech:~$ systemctl is-active demo.service
active
student@vulntech:~$ sudo systemctl stop demo.service
student@vulntech:~$ systemctl is-active demo.service
inactive

Enabling: start at every boot

start is forgotten on reboot; enable makes the choice permanent by linking the service into the boot sequence. enable --now does both at once:

sudo systemctl enable --now demo.service
systemctl is-enabled demo.service
systemctl is-active demo.service

In the terminal

student@vulntech:~$ sudo systemctl enable --now demo.service
[sudo] password for student:
Created symlink /etc/systemd/system/multi-user.target.wants/demo.service → /etc/systemd/system/demo.service.
student@vulntech:~$ systemctl is-enabled demo.service
enabled
student@vulntech:~$ systemctl is-active demo.service
active

Common mistake: start and enable are independent. A service you only start is gone after a reboot; one you only enable isn't running until the next boot. Use enable --now when you want both.

Remember: start/stop/restart act now; enable/disable set what happens at boot. enable --now does both; is-active and is-enabled report the two states.

HOME LEARN COMMUNITY DASHBOARD
Practice terminal Starting…