How to start service on boot on Ubuntu 22.04

In this tutorial you will learn how to start a service on boot on Ubuntu 22.04 Jammy Jellyfish Linux. Ubuntu uses systemd service manager to manage services which means to enable and disable services is an easy and straightforward task.

In this tutorial you will learn:

  • How to check if a service is enabled or disabled
  • How to enable service to start on boot
  • How to disable service to start on boot
How to start service on boot on Ubuntu 22.04 Jammy Jellyfish Linux
How to start service on boot on Ubuntu 22.04 Jammy Jellyfish Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 22.04 Jammy Jellyfish
Software systemd (installed by default)
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to start service on boot on Ubuntu 22.04 step by step instructions




In this tutorial we will be using the apache2 service as an example. Therefore, replace the apache2 name with the name of the service you intend to start on boot.

In case you do not know the name of the service you wish to start on boot then follow our guide on how to list services on Ubuntu 22.04.

  1. First, check the current state of the service to see whether it is enabled to start on boot. To do so, open a command line terminal and execute the following command:
    $ systemctl status apache2
    
    Currently this particular service is disabled to start during the system boot time
    Currently this particular service is disabled to start during the system boot time

    Note that the “vendor preset” text tells you whether the service starts automatically by default or not. This is just the default value when the service is installed, and not necessarily what the service is currently set to.

  2. Use the systemctl command to start the service on boot. For example:
    $ sudo systemctl enable apache2
    

    Alternatively, if you also wish to enable and start the service at the same time you may execute:

    $ sudo systemctl enable --now apache2
    
  3. Once the service is enabled to start on boot you can confirm its status once again by executing:
    $ sudo systemctl status apache2
    
  4. To disable service to start on boot use systemctl command again. For example:
    $ sudo systemctl disable apache2
    

Closing Thoughts




In this tutorial, we saw how to enable a service to start automatically upon boot in Ubuntu 22.04 Jammy Jellyfish Linux. Ubuntu, like most other modern Linux distros, uses systemd in order to manage services. Once you know how to use the systemctl enable and systemctl disable commands, you can set any service to start automatically upon boot or not.