Creating the systemd unit files
The unit files on our system define how systemd starts and runs services.
Each unit file represents a single component as a simple text file that describes its behavior, what needs to run before or afterward, and more.
Unit files are stored in a few different places on a system and systemd looks for them in this order:
/etc/systemd/system
/run/systemd/system
/usr/lib/systemd/system
Unit files that are in the earlier directories override the later ones. This lets us change what we need in the /etc
directory, where configuration is expected, leaving the default configuration files in /usr
, for example.
But what does a unit file look like? Let's find out.
First, we can get the location of a default unit file by asking systemd about it:
# systemctl status sshd ○ sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled; vendor preset: disabled...