How to automatically start a service on Linux (systemd)

Why automatically start a service on Linux?

The question might be obvious. Why would you *not* want to automatically start a service on Linux?

The answer is sometimes a particular Linux installation is problematic and after a restart all services do not start up. This is mostly because someone forgot to set the service to automatic startup.

Linux startup sequences are either systemd or sysvinit. In the following environments we have found that systemd can be made to start services automatically:

  • openSUSE Tumbleweed
  • Ubuntu

Command to make a service start automatically

The command to make a service start automatically is:

# systemctl enable saslauthd
Created symlink /etc/systemd/system/multi-user.target.wants/saslauthd.service → /usr/lib/systemd/system/saslauthd.service.
# systemctl enable saslauthd

You’ll notice we’ve done it twice. The first time was to actually make it start, and the second time is to see if the command worked. If you get different output from the first command, the service might already be set to startup.

Reference

  • ChatGPT

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top