Run service from a specific directory.

Section: Environment, Users, Dependencies

Set working directory

ini
ini
[Service]
WorkingDirectory=/opt/myapp
Explanation

Useful for relative file access and app startup.

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
Run service as non-root user
Specify service user and group.
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 sheetbash2 tag match
Basic service file example
Minimal custom service unit.
OpenIn sheetini2 tag match