This document explains how to write a systemd service file, what each section means, common options, and best practices. This is a reference for DevOps engineers to understand systemd service architecture clearly.


1. What Is a Systemd Service?

A systemd service is a configuration file that tells Linux:

Systemd is the default init system on modern Linux systems (Ubuntu, Debian, CentOS, Amazon Linux 2).

Service files are stored in:

/etc/systemd/system/


2. Basic Structure of a Service File

A service file contains three main sections:

[Unit]
[Service]
[Install]

Each section has a specific purpose.


3. The [Unit] Section