TOOL » LINUX » SYSTEMCTL

Service

Usage

Root privileges are often needed when running systemctl commands.

shell
systemctl OPTION ACTION my.service
OptionDescription
--userUse the user service manager.
ActionDescription
startStart the service.
stopStop the service.
restartRestart the service.
enableEnable automatic service startup on boot.
disableDisable automatic service startup on boot.

Creation

ScopePath
System/etc/systemd/system
User~/.config/systemd/user

System service

ini
## someservice.service
[Unit]
Description=some service
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
User=mateus
Environment=DISPLAY=:0
EnvironmentFile=/etc/someservice/someservice.conf
ExecStart=/path/to/script.py

[Install]
WantedBy=multi-user.target

User service

ini
## wallpaper.service
[Unit]
Description=set random wallpaper

[Service]
Type=oneshot
ExecStart=/home/mateus/.local/bin/wallpaper --random

[Install]
WantedBy=multi-user.target