Disabling unnecessary services for faster boot Linux

More and more operating systems become 'cumbersome' with lots of services running in the background. Although they may not use too much CPU resources, they increase boot time and RAM usage.

Some Linux distributions include everything, with the aim of making user use easier. This makes things like file sharing or printing increasingly creative. Unfortunately, the only way to do it is to create hundreds of utilities for people to find what they need.

Fortunately, open source operating systems give you the ability to disable or delete anything that isn't needed. The first option, how to disable services - is what will be covered in this article. When disabled instead of removing components, the risk of everything being permanently broken is less likely to occur. And you can reactivate the service if you find something useful has stopped working.

Make Linux boot faster by disabling unnecessary services

  1. Analyze the time needed to load a service
  2. Use systemctl to disable unnecessary services
  3. Use systemctl to hide a service

Analyze the time needed to load a service

Most Linux-based operating systems have switched to Systemd. Among Systemd's utilities, there is a program that allows users to analyze the system boot speed. Specifically, it shows the user the total time needed to boot and the time required to load each service. Note that some services load in parallel. So if the first service takes 2 seconds and another service needs 3 seconds to load, it doesn't mean it takes 5 seconds to load those 2 services.

Open a terminal and enter this command:

 systemd-analyze 

Disabling unnecessary services for faster boot Linux Picture 1

This shows how long it takes to load the basic system services and the Linux kernel, not counting the boot time of the graphical interface. In other words, it is a necessary time, since the kernel is loaded until the user reaches the Linux control panel, as described below:

Disabling unnecessary services for faster boot Linux Picture 2

If you have not installed a graphical interface, this is what you will see on your screen.

However, you can also see the time that the graphical interface requires initialization with the following command:

 systemd-analyze critical-chain graphical.target 

Disabling unnecessary services for faster boot Linux Picture 3

This command shows that the graphical user interface is loaded in 2,126 seconds, not counting the time needed to load desktop utilities. To enable or disable those utilities, launch the desktop environment startup manager.

Finally, perhaps the most useful command to help Linux boot faster is:

 systemd-analyze blame 

Disabling unnecessary services for faster boot Linux Picture 4

You can navigate the list with the arrow keys or the PAGE UP and PAGE DOWN keys. Press q to exit.

Use systemctl to disable unnecessary services

As you can see in the previous image, service snapd takes 1.295 seconds to load. On an SSD, this time period is negligible. But on a hard drive, these services will in turn lose certain load times and the total time needed to load them is not small. In addition, on SSDs, many services are loaded in parallel, resulting in amazing results. On the contrary, on a hard drive, parallel service loads are difficult to implement. Readers place on the platter (the platter is a circular disk where the magnetic data stored in the hard drive) must switch from one sector to another, so parallel data reading is almost impossible. .

To make it easier to understand, imagine the following: If on SSD there are 5 services, each service needs a second to boot, then the total time needed to load all these services is less than 1.2 seconds. But on a hard drive, with 5 similar services, the total load time will be more than 5 seconds.

Suppose you do not need service snapd, can disable it with this command:

 sudo systemctl disable snapd.service 

But, if you reboot, you will see the daemon snap is still running. The reason may be because other dependencies have started it, even if it is disabled. Try to see what could be the cause of this problem:

 systemd-analyze blame | grep snap 

Disabling unnecessary services for faster boot Linux Picture 5

snapd.seeded.service and snapd.socket are the culprits here. A child service may require its original service to be launched. When disabling a service, it simply requires that it not automatically start when you boot. But there is an effective method to solve this problem.

Use systemctl to hide a service

 sudo systemctl mask snapd.service 

This basically makes the service file empty so that the application has no way to launch the service.

In most cases, disabling a service is not too complicated. The example below is chosen to show you how to handle more difficult situations. In this case, snapd.seeded.service and snapd.socket should be disabled or hidden.

The following figure shows the boot time has improved.

Disabling unnecessary services for faster boot Linux Picture 6

Boot time has decreased from 4,078 seconds to 0.52 seconds, down to 15%. Not too bad. And this only considers a service disabled on SSD. On a hard drive, it's easy to get much better results.

In this particular example, many services will be disabled with a command like:

 sudo systemctl mask avahi-daemon.service ModemManager.service thermald.service pppd-dns.service 

If you like a graphical application to manage your services, you can consider Systemd Manager. However, what you can do will be limited to this tool, because the command line offers much more flexibility.

Good luck!

See more:

  1. 6 ways to speed up the Ubuntu system
  2. 10 ways to help Linux boot faster
  3. 10 Linux tools for rescue, restore Linux, Window, Mac
4 ★ | 132 Vote

May be interested

  • How to remove the Windows boot screen on Windows 10How to remove the Windows boot screen on Windows 10
    windows 10 boot time can be reduced by turning off or disabling splash screen in windows 10, using the system configuration dialog box. after disabling splash screen, windows 10 will boot faster.
  • How to check all services running in LinuxHow to check all services running in Linux
    need to know all the services running on the system. in this article, tipsmake.com will show you all possible ways to list the services running on linux computers.
  • How to install Kali Linux dual boot on macOSHow to install Kali Linux dual boot on macOS
    since the release of kali linux 1.0.8, kali linux supports adding efi. this additional feature simplifies the process of installing and running potassium on various apple macbook air, pro and retina models. modeling the device will determine the level of success when users experience with newer devices. refind preinstallation can also increase the success rate on older devices. this tutorial will show you dual osx booting with kali linux using refind and encryption options
  • How to install Kali Linux on macOSHow to install Kali Linux on macOS
    since the release of kali linux 1.0.8, kali linux supports efi. this additional feature simplifies the process of installing and running potassium on various apple macbook air, pro and retina models.
  • How to free up RAM to help your computer run smootherHow to free up RAM to help your computer run smoother
    freeing up ram helps your computer run more smoothly, reduces lag, and optimizes performance. methods such as turning off background applications, disabling unnecessary services, and optimizing your browser help save memory effectively.
  • 5 measures to increase Linux boot speed5 measures to increase Linux boot speed
    linux users can be proud that the speed of operating on linux is quite fast when compared to other operating systems. not only that, linux does not seem to suffer the bogging down effect that windows has always encountered when users install hundreds of applications on the system.
  • How to use Systemctl to list all Linux servicesHow to use Systemctl to list all Linux services
    when administering a linux system, it is important to understand how to control and monitor system services. systemd, the system and service manager for most linux distributions, provides a powerful set of tools for this purpose.
  • 'Clear the way' for Win XP to boot faster (Part 1)'Clear the way' for Win XP to boot faster (Part 1)
    the computer is a slow start that makes users uncomfortable. here are some ways to help your windows xp-based computer boot faster.
  • Immediately turn off these services on Windows 10 to play games smootherImmediately turn off these services on Windows 10 to play games smoother
    by disabling unnecessary services in windows 10, free up ram and system resources, optimize the system and experience smoother gameplay, lag free.
  • How to troubleshoot Ubuntu problems does not startHow to troubleshoot Ubuntu problems does not start
    sadly, although linux is very reliable, it sometimes encounters problems, like windows 10 or macos. in most cases, you can solve this problem.