Understanding systemd User Services
systemd allows users to create and manage their own services without needing root access. This is particularly useful for running applications that only need to operate under a specific user account.
Key Features of User Services
- User-Specific: User services are linked to a specific user account and are stored in the user’s home directory.
- Location: User services are typically found in ~/.config/systemd/user/. This is where you create your service files.
- Startup Behavior: These services start automatically when the user logs in and stop when the user logs out.
Create the Service file
touch ~/.config/systemd/user/myservice.service
Edit the Service File
[Unit]
Description=My Custom Service
[Service]
ExecStart=/path/to/your/application
[Install]
WantedBy=default.target
Enable the Service
systemctl —user enable myservice.service
Start the Service
systemctl —user start myservice.service
Check Status
systemctl —user status myservice.service
Stop the Service
systemctl —user stop myservice.service