In this guide, check out how to manage startup services with systemd in Fedora.
Systemd on Fedora
Over the traditional init systems (UNIX System V and BSD), systemd offers flexibility and improvements. This is why most of the modern Linux distros have embraced systemd. Fedora is no exception. A key benefit of systemd is because it’s almost like a standard; the commands demonstrated on this guide will also work on any other Linux system that uses systemd.
To ensure that your Fedora system has systemd, run the following command.
The following command will also reveal the location of the systemd on the system.
To find the location of systemctl, run the following command.
It’s possible to verify whether systemd is currently running.
Managing services using systemd
To manage services, systemctl is an easy-to-use tool. For the most part, systemctl is what you’re going to use when it comes to service management.
List services
Generally, any Linux system has numerous services ongoing. It’s a hard task to keep all of them memorized. Thankfully, systemctl can list all the services on the system.
The following command will list all the services. It includes enabled, disabled, running, and stopped services.
It’s possible to list services based on their state.
To list services based on multiple states, use the following command structure.
Here’s a quick list of all the available service states.
- active
- inactive
- activating
- deactivating
- failed
- not-found
- dead
If you’re interested in “loaded”, “enabled”, “disabled”, and “installed” service files, then it requires the “list-unit-files” command instead. Run the following command.
Checking service status
Before performing any action on a service, it’s a good idea to check the target service’s status. The following command will report the status of a service.
Alternatively, use the following “service” command.
Starting a service
To start a service, run the following command.
Alternatively, the following “service” command will do the same task.
Stopping a service
To stop a running service, use the following command.
Alternatively, use the following “service” command.
Restarting a service
After making changes, a service requires a restart to put the changes into effect. To restart a service, run the following command.
Alternatively, use the following “service” command.
Reloading a service
In the case of some services, those can load the new configuration without a restart. If that’s the case, then reloading is the better action. To reload a service, use the following command.
Restart and reload
In case you’re not sure whether to restart or reload the service, then issue the “reload-or-restart” command. It’ll reload the configuration files in-place (if available). Otherwise, it’ll restart the service.
Enabling and disabling service
Based on whether the service starts at boot, there are two types of services.
- enabled: The service will start automatically when the system boots.
- disabled: The service won’t start when the system boots.
Note that any “disabled” service has to be started manually after the system boots.
To enable a service, run the following systemctl command.
To disable a service, run the following systemctl command.
Analyzing boot time
When booting, each service requires time to load completely. To determine how much time services spend during boot, run the following command.
Using systemd-analyze, you can also analyze the critical chain at boot. Run the following command to see the report.
Final thoughts
Systemd makes it easy to manage startup services. This guide only demonstrates some of the simplest methods of manipulating services on Fedora.
However, systemd is more than that. In essence, systemd is the father of all other processes. To understand systemd on a deeper level, check out this guide on how systemd starts the system.
Happy computing!