Services in systemd

Whether you call them services or daemons, in systemd the background processes you want running on your Linux installation are wrapped up as units. Unit files for services are stored in the folder /etc/systemd/system with the extention .service

Useful commands

List unit files of services

systemctl list-unit-files --type=service

List unit files of services matching search (wildcard is *)

systemctl list-unit-files --type=service "{:SearchQuery:}"

Get unit status

systemctl status {:UnitName:}

Start/stop/restart unit

systemctl start {:UnitName:}
systemctl stop {:UnitName:}
systemctl restart {:UnitName:}

Enable/disable unit

systemctl enable {:UnitName:}
systemctl disable {:UnitName:}

Get if unit enabled/disabled (exit code 0 for enabled and 1 for disabled)

systemctl is-enabled {:UnitName:}

List unit file contents

systemctl cat {:UnitName:}

Edit unit default file

systemctl edit --full {:UnitName:}

Edit unit override file

systemctl edit {:UnitName:}

Create new service

systemctl edit --full --force {:UnitName:}.service

Reloading systemd after making changes outside of systemctl (i.e. deleting a service)

systemctl daemon-reload

Tags: #Os #Linux #Systemd