Categories: Ubuntu

How to Disable a Service in Ubuntu?

In many situations, we need to disable some unnecessary services in Ubuntu to keep the system well maintained. Disabling redundant services helps to improve the system’s efficacy as some of these services use the processor and a portion of the memory in the background. Services can be disabled temporarily or permanently, but it depends upon your need.

Before we discuss how we can disable services in Ubuntu, let’s understand the initialization system of Ubuntu. There are two different initialization systems Ubuntu uses. The first one is the “upstart” and the second is “systemd”.

The “upstart” is now deprecated and was last used in Ubuntu 15.04. The init system of current Ubuntu and many other distributions is “systemd”.

Sponsored
Both systems have their own methods to enable and disable services. Since the latest distributions have been widely adopted, we will use “systemd” method to disable a service.

How to Disable a Service in Ubuntu 20.04(LTS), 20.10:

Let’s begin by listing the running services in Ubuntu. To list the services, use the command mentioned below:

$ systemctl list-units –type=service

The services can be filtered by involving the “grep” command:

$ systemctl | grep running

All the services which are running will be displayed in standard output. To disable a service, use:

$ systemctl disable [service_name]

Use the service name you want to disable in place of “[service_name]”. The command will disable the service and would not enable it even if you restart the system. For example, I am disabling the “apacehe2” service from my system; I will use:

$ sudo systemctl disable apache2.service

To verify if the service is disabled or not, use:

$ sudo systemctl status apache2.service

The above method will permanently disable the “apache2” service; even upon restarting the system, the service will remain inactive.

Sponsored

To temporarily disable the service, use:

$ sudo systemctl stop [service_name]

I am disabling “apache2” service:

$ sudo systemctl stop apache2.service

Upon rebooting, you will notice that the service will be enabled again since it was temporarily stopped.

How to Enable a Service in Ubuntu 20.04(LTS), 20.10:

You can temporarily start a disabled service using:

$ systemctl start [service_name]

The above command can be used in a situation when you want to use a service momentarily. For example, the “apache2” can be enabled temporarily using:

$ systemctl start apache2.service

To permanently enable a service, use:

$ systemctl enable [service_name]

Replace the “[service_name]” with the service name you want to enable permanently. I am again enabling “apache2”, so the command would be:

$ systemctl enable apache2.service

The “apache2” service will remain active even upon restarting the system.

Conclusion:

There are two different init systems Ubuntu used, the “upstart” and the “systemd”. Both have different methods to manage the running services.  The “systemd” is a widely adopted init system as “upstart” has been deprecated. This guide showed how to disable a service momentarily and permanently in Ubuntu. Many services in our system just run in the background and use the machine’s resources. Disable them and free-up memory to improve the system’s booting time and overall efficiency.

Ubuntu Server Admin

Recent Posts

Canonical Releases Ubuntu 25.04 Plucky Puffin

The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…

2 days ago

Ubuntu 25.04 (Plucky Puffin) Released

Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…

3 days ago

Extended Security Maintenance for Ubuntu 20.04 (Focal Fossa) begins May 29, 2025

Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…

3 days ago

Ubuntu 20.04 LTS End Of Life – activate ESM to keep your fleet of devices secure and operational

Focal Fossa will reach the End of Standard Support in May 2025, also known as…

4 days ago

Ubuntu MATE 25.04 Release Notes

Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…

4 days ago

Ubuntu Weekly Newsletter Issue 887

Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…

5 days ago