How to start service on boot on Ubuntu 20.04

In this tutorial you will learn how to start service on boot on Ubuntu 20.04 Focal Fossa. 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 service enabled/disabled/ state
  • How to enable service to start on boot
  • How to disable service to start on boot

How to start service on boot on Ubuntu 20.04 Focal Fossa

How to start service on boot on Ubuntu 20.04 Focal Fossa

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Installed Ubuntu 20.04 or upgraded Ubuntu 20.04 Focal Fossa
Software systemd
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 20.04 step by step instructions

In this tutorial we will be using apache2 service as an example. Therefore, replace the apache2 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 20.04.

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

    Currently this particular service is disabled to start during the system boot time.

  2. Use 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 confirm its status once again by:
    $ sudo systemctl status apache2
    
  4. To disable service to start on boot use systemctl command again. For example:
    $ sudo systemctl disable apache2