Fedora

How to Manage Startup Services with Systemd in Fedora

Systemd is a software suite that offers an array of system components for Linux systems that can perform service configuration and system behavior management. It consists of an init system, various tools for device management, network connection management, login management, and event logging.

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.

$ systemctl --version

The following command will also reveal the location of the systemd on the system.

$ whereis systemd

To find the location of systemctl, run the following command.

$ whereis systemctl

It’s possible to verify whether systemd is currently running.

$ ps -eaf | grep systemd

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.

$ systemctl list-units --type=service --all

It’s possible to list services based on their state.

$ systemctl list-units --state=<state>

To list services based on multiple states, use the following command structure.

$ systemctl list-units --state=<state_1>,<state_2>

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.

$ systemctl list-unit-files --type=service

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.

$ systemctl status <service>

Alternatively, use the following “service” command.

$ service <service> status

Starting a service
To start a service, run the following command.

$ sudo systemctl start <service>

Alternatively, the following “service” command will do the same task.

$ sudo service <service> start

Stopping a service
To stop a running service, use the following command.

$ sudo systemctl stop <service>

Alternatively, use the following “service” command.

$ sudo service <service> stop

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.

$ sudo systemctl restart <service>

Alternatively, use the following “service” command.

$ sudo service <service> restart

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.

$ sudo systemctl reload <service>

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.

$ sudo systemctl reload-or-restart <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.

$ sudo systemctl enable <service>

To disable a service, run the following systemctl command.

$ sudo systemctl disable <service>

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.

$ systemd-analyze blame

Using systemd-analyze, you can also analyze the critical chain at boot. Run the following command to see the report.

$ systemd-analyze critical-chain

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!

About the author

Sidratul Muntaha

Sidratul Muntaha

Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.