make system service script
[root@y500-fedora ~]# cat /etc/systemd/system/foo.service
[Unit]
Description=foo
[Service]
ExecStart=/bin/bash -c "while true; do /bin/inotifywait -qq --event close_write /sys/class/backlight/acpi_video0/brightness; su myusername -c '/bin/xbacklight -display :0 -set $(cat /sys/class/backlight/acpi_video0/brightness)'; done"
[Install]
WantedBy=multi-user.target
list all services
systemctl list-unit-files | grep enabled # list enabled services
systemctl list-units --type=service
# OR list all services
systemctl --type=service
systemctl list-units --type=service --state=active
# OR
systemctl --type=service --state=active
systemctl list-units --type=service --state=running
# OR
systemctl --type=service --state=running
make alias to list services
alias running_services='systemctl list-units --type=service --state=running'
disable, remove services
systemctl stop [servicename]
systemctl disable [servicename]
rm /etc/systemd/system/[servicename]
rm /etc/systemd/system/[servicename] # and symlinks that might be related
rm /usr/lib/systemd/system/[servicename]
rm /usr/lib/systemd/system/[servicename] # and symlinks that might be related
systemctl daemon-reload
systemctl reset-failed
install service
# copy to systemd folder
mv new_service /etc/systemd/system
# Reload systemd:
systemctl daemon-reload
# Enable the new service:
systemctl enable foo
Was this article helpful?
This article is viewed 77 times!