Ubuntu

How to Start Service on Boot on Ubuntu 22.04

There are different services that are used in Ubuntu to perform different types of tasks. Either they can be web servers like Apache2, Nginx, or it can be firewall services. If the users are interested in starting these services on Boot of the Ubuntu Jammy Jellyfish which means when the machine is turned on and the operating system is loaded, the service should also be enabled.

The method of starting service in the new release of Ubuntu, that is Ubuntu Jammy Jellyfish has been explained in this blog.

How to Start Service on Boot on Ubuntu 22.04

In this blog, the service of Apache2 has been taken as an example so that the users can understand the method of starting service on boot on Ubuntu. The users are requested to replace the Apache2 with the specific service name, they want to start on boot on Ubuntu.

A systemctl utility is by default available in Ubuntu to manages the services so first using it, find out the status of the service:

$ sudo systemctl status apache2

In the output, it can be that the service is running but it’s disabled on the boot, so to make it enable to run the command:

$ sudo systemctl enable apache2

After enabling the service, validate the status of the service:

$ sudo systemctl status apache2

Now the service status is changed to enabled that means it will be started when the Ubuntu is booted, however, the status of enable can also be revert back to disabled using the command:

$ sudo systemctl disable apache2

The service is disabled, now, if the user wants to enable the service with immediate action, then use the flag of “–now” with the enable command:

$ sudo systemctl enable apache2 --now

The service’s status is again changed to enable.

Conclusion

The systemctl utility is used to start the service on boot by enabling the service using the command “sudo systemctl enable [service name]” on Ubuntu 22.04. This blog demonstrated the method by which services can be started on the boot of Ubuntu using the terminal.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.