Linux systemd Service Files Cheat Sheet/Create custom service file

Open a new service file under /etc/systemd/system.

Section: Authoring Basics

Create custom service file

bash
bash
sudo nano /etc/systemd/system/myapp.service
Explanation

Custom local units usually belong under /etc/systemd/system.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Authoring Basics
Basic service file example
Minimal custom service unit.
OpenIn sheetinisame section
Reload after creating unit
Refresh manager state after writing a new service.
OpenIn sheetbashsame section
Enable and start custom unit
Activate the new custom service.
OpenIn sheetbashsame section
Set working directory
Run service from a specific directory.
OpenIn sheetini2 tag match
Load variables from EnvironmentFile
Use an external env file.
OpenIn sheetini1 tag match
Restart on failure
Automatic restart policy.
OpenIn sheetini1 tag match