Linux systemd Service Files Cheat Sheet/Run service as non-root user

Specify service user and group.

Section: Environment, Users, Dependencies

Run service as non-root user

ini
ini
[Service]
User=myapp
Group=myapp
Explanation

Preferred for least privilege.

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 Environment, Users, Dependencies
Load variables from EnvironmentFile
Use an external env file.
OpenIn sheetinisame section
Set working directory
Run service from a specific directory.
OpenIn sheetinisame section
Start after another unit
Set ordering and dependency relationship.
OpenIn sheetinisame section
Require another unit
Fail if the required unit is absent or stopped.
OpenIn sheetinisame section
Create custom service file
Open a new service file under /etc/systemd/system.
OpenIn sheetbash1 tag match
Restart on failure
Automatic restart policy.
OpenIn sheetini1 tag match