A service on Linux is a process that runs in the background that you can start, stop, enable, and disable. For modern operating systems, we interact with them using the “systemctl” tool, which interfaces with the systemd subsystem, which in turn manages the “init” system and service manager. As Linux admins, we don’t need to worry too much about what happens in the backend – all we need to know is how to enable and disable services.
Enabling a Service Using systemctl on Linux
To enable a service using systemctl, use the command:
sudo systemctl enable <service>
Where <service> is the name of the service you want to enable.
What it Means to “Enable” a Service
Enabling a service in Linux means you want it to start automatically when the system boots. It does not mean that the service starts automatically. We have specific flags for when we want to enable and start a service at the same time. Specifically:
sudo systemctl enable --now <service>
This command tells Linux to both enable the service you want as well as to start running it immediately. Here are the various “statuses” in which we find a service:
- enabled – Will start automatically on boot
- disabled – Won’t start on boot
- active – Currently running
- inactive – Not running right now
- static – Can’t be enabled directly (no [Install] section)
- masked – Completely disabled (can’t even be started manually)
Some of these statuses can be valid at the same time as others. For example, a service can be “enabled”, and also “inactive”, meaning that it’ll start the next time the OS reboots, but isn’t running now.
Checking the Status of an Existing Service
Before you enable a service, it’s a good idea to check and see what its current status is. Let’s take the “rsync” service, for example. To see what the status is, we type:
systemctl status rsync
This gives us the following output:
Let’s see what this output means. It says “disabled”. This means that the service won’t start on boot. It also says “inactive”, which means that it’s not currently running. From this state, we could start it, enable it, or both.
Checking to See if Enabling Works
Currently, the rsync service is neither enabled nor active. Let’s enable it and see what happens via the following command:
sudo systemctl enable rsync
After executing this command, I get the status again using:
systemctl status rsync
And here’s the output:
You can see that the service “rysnc” is now enabled. Crucially, it still says “inactive”, which means that it’s not yet running. This goes to show that a service can be both “enabled” as well as inactive.
Now let’s reboot the system and see what happens:
sudo reboot
After the system starts up, we can once again check the status of the service and see what it says:
As you can see, I restarted the system after I enabled “rsync”, and have run the status command again. This time, it still says that it’s inactive, but that’s because it tried to start and failed! The reason is given in the description, which says that rsync needs to have a configuration file to start, so this is by design. It’s not important for us, because we just wanted to test it and see if the service would have started if everything went well, and we can see that it did.
Now that we’ve seen it works, we can safely disable the rsync service again:
sudo systemctl disable rsync
Don’t forget to use “sudo” here, since the command might run without sudo, but some subprocesses might fail even when you authenticate correctly, so it’s best to use sudo in the initial command.
Getting a List of Currently Disabled Services
If you’re looking to enable a service, but aren’t sure exactly what it’s called, you can use this command to see which services on the system are currently enabled or disabled:
systemctl list-unit-files --type=service --state=disabled
This gives the following output:
Each of the currently disabled services shows up as a “.service” file. The two columns represent the current state of the service, and the other column is the recommended preset by the vendor. If the two don’t match, it’s because either you or some other process changed the enabled status – most likely it wasn’t you!
Note that each of these services is a file with the “.service” extension. While enabling or disabling services, you don’t need to include the “.service” part, unless there’s another kind of file with the same name and a different extension.
What systemctl enable Actually Does
The mantra in Linux is that “everything is a file”, and this is true for services as well. Not only are services represented as files, but the enable/disable functionality is implemented through files, too. For example, on my system, the service files reside in the following directory:
/lib/systemd/system/
And when we enable them via systemctl, the tool simply creates a symbolic link to the service file in the following directory:
/etc/systemd/system/multi-user.target.wants/
We can see this by listing the files in the target directory via:
ls /etc/systemd/system/multi-user.target.wants/
And here’s the output:
You can see that these are all symbolic files by the default color. So the systemctl tool isn’t doing anything mysterious. There’s no concept of a “registry”, like we have in Windows, that contains the settings in a centralized manner. Everything’s a file, and we can create symbolic links to files in directories to indicate which services need to run when we boot the system.
Starting, Enabling, and –now
When it comes to deciding when services run, there are three options of which you need to be aware:
- Starting services
- Enabling services
- Enabling and starting services
We’ve already seen how starting a service isn’t the same as enabling it. Enabling it means you’re telling it to start the next time it runs, while starting a service makes it run immediately. If you want to enable a service and have it start immediately, then use the following command:
sudo systemctl enable --now <service>
Static Services
Some services aren’t meant to be enabled. They’re called “static” services and are started automatically when another process needs them. You can get a list of static services on your system using the following command:
systemctl list-unit-files --state=static
This gives the following output:
As you can see, the list is quite long. It seems many services in Linux aren’t meant to be enabled by users! These services can still be started manually, but you’ll get an error if you try and enable one of them. Here’s an example:
As you can see, the system generates an error when we try and enable static services.
Masked services take things even further by disabling even manual starts!
Conclusion
Most of the time, you’ll be enabling/disabling services on Linux using systemctl for packages that you install on your own. This isn’t the same as starting the service, though you can do both at the same time using the “–now” parameter. Enabling a service means that it starts on boot. Linux achieves this by including a symbolic link to the file in the appropriate directory.

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!
Leave a Reply