How To Enable and Disable Services Using SystemD

Table of Contents

Are services becoming too bloat for you? Yea, you should probably disable some if you like. Just in case you are new to Linux overall, systemd is a system and service manager for Linux operating systems that is designed to start and stop services, monitor and manage system processes, and handle system events. One of the most common tasks that Linux junkies and even admins perform with systemd is enabling and disabling services. Yes, you can even permanently disable annoying services from start. In this article, we will explore how to use systemctl to enable and disable Linux services even from boot!

Enabling

Just a little background on service units… When you enable and disable services, all that really happens is a symbolic link is created in a special place systemd likes to check and store its .service unit files. Seriously, that’s it!

Anyway, this is the command you would use to enable a service. Obviously, replace service-name with the name of the service you want to enable.

				
					sudo systemctl enable <service-name>
				
			
As mentioned before, systemctl will enable the service and create a symbolic link between the service file and the appropriate directory in the /etc/systemd/system/ directory.

Disabling

You didn’t think disabling would be any different did you? If you want to disable a service, simply do the inverse! Here is the command:

				
					sudo systemctl disable <service-name>
				
			

And that’s it! But there is one more step you need to be aware of when doing this.

Reloading SystemD

When you enable/disable services, it is like systemd for some reason is not self aware enough… shame. Therefore, we do have to reload the systemd daemon to be aware of the changes we just made. Here is how we do it:

				
					sudo systemctl daemon-reload
				
			

Do It Now?

There is one little nifty trick I admittedly did not know about until recently. Before, I would enable/disable a service and then start/stop it. However, with the handy --now option, you can force systemd to do your bidding without question.

				
					sudo systemctl enable --now <service-name>
sudo systemctl disable --now <service-name>
				
			

Now, systemd will not only enable/disable the service but also start/stop it at the same time!

As you can see, not everything in Linux is scary. Enabling and disabling services is actually pretty easy, if you ask me. There is much more you can do if you want to get all fancy but we’re keeping it simple for now.

And with that, I leave you with this…

				
					sudo share --with friends --target everywhere
				
			

Meet the Author

Leave a Reply