Systemd Unit Configuration Files Explained
Systemd uses unit configuration files to manage system services and processes. There are three types of unit configuration files: default, system-specific, and run-time. The following table lists their locations.
| Type of unit configuration files | Location |
| Default unit configuration files | /usr/lib/systemd/system |
| Run-time unit configuration files | /run/systemd/system |
| System-specific unit configuration files | /etc/systemd/system |
- Default unit configuration files contain the default configuration of units. When we install software packages, the installation process automatically creates them.
- Run-time unit configuration files contain the configuration units required to function. Linux automatically generates and deletes them when we start and stop units.
- System-specific unit configuration files contain overrides and custom configurations. These configuration files allow us to override the default functions.
When we start, stop, enable, or disable a service or process, the systemd reads and executes its unit configuration file in the following sequence.
System-specific unit configuration files => Run-time unit configuration files => Default unit configuration files.

Run-time unit configuration files take precedence over the default unit configuration files, and the system-specific unit configuration files take priority over the run-time unit configuration files. The system reads the next in the sequence configuration file only when the current configuration does not exist. For example, if all three unit configuration files are available, it uses only the system-specific configuration file. This pre-defined order allows users to customize services and processes per their requirements.
You should never customize a default unit configuration file. The installation process updates it when you update the software packages. Instead of updating the default configuration file, copy it in the /etc/systemd/system directory and modify it as required.
This tutorial is part of the tutorial series Systemd service in Linux. Other parts of this series are the following.
Chapter 01 Differences between SysVinit, Upstart and SystemdChapter 02 Systemd Units Explained with Types and States
Chapter 04 Systemd Target Units Explained
Chapter 05 How to use the systemctl command to manage Systemd services
Systemd unit configuration files syntax and format
A systemd unit configuration file contains all required information to control the process, such as the configuration file's path, the name of services or processes that the system needs to start before and after, documentation location, dependency information, conflict information, etc. A unit configuration file organizes information into three sections: [Unit], [Type], and [Install].
Let's understand these sections in detail. Access a root shell and run the following command.
#cat /usr/lib/systemd/system/sshd.service
It displays the default unit configuration file of the SSH service.

[Unit]
This section usually contains the Description, Documentation, After, Before, Wants, and Require directives.
Description This statement provides a brief description of the unit.
Documentation This statement provides the location of the man (help document) page and the command to access the man page.
After This statement lists the units which should be activated before this unit.
Before This statement lists the units which should be activated after this unit.

Wants This statement lists the units/services that should be started before this unit.
Requires This statement lists the units/services that must be started before this unit.
Conflicts This statement lists the units/services that must be stopped before starting this unit.
Key points
- Systemd starts and manages all system units.
- After and Before statements define the order in which the unit should be started.
- Wants and Requires statements define the dependencies of the unit.
- Systemd automatically resolves the dependencies and activates the units/services listed in the Wants/Requires statements.
- When activating/starting a unit, Systemd first activates/starts the services/units listed in the Wants/Requires statements.
- If Systemd fails to activate the services listed in the Wants statement, it does not stop activating the unit. It simply starts the unit ignoring the failed services.
- But, if the systemd fails to activate the services listed in the Requires statement, it does not start the unit.
[Type]
The heading of this section (the keyword between the square brackets) shows the unit type. For example, if the unit type is the Service, this section uses the heading [Service]. Or if the unit type is the Socket, it uses the heading [Socket]. Statements of this section contain the control operations/commands of the unit.
The standard statements that you can find in this section are as follows:
ExecStart This command starts the unit.
ExecStop This command stops the unit.
ExecReload This command reloads the unit.
EnvironmentFile This statement lists the location of the unit's main configuration file.
[Install]
This section contains information about the target unit. Usually, it includes the following directives.
WantedBy It is the target unit that starts this unit. For example, if you see the multi-user.target in this statement, Systemd automatically starts this unit when the system enters the multi-user.target target level.
Conclusion
Systemd unit configuration files are essential in a Linux environment. By understanding these files, administrators can maintain a stable and manageable system. A solid grasp of these concepts enhances troubleshooting, optimizing, and securing services within a Linux system.
By ComputerNetworkingNotes Updated on 2026-01-25