Systemd helps us to keep & managing the services in easy way or keep the services running or start on boot.
Here are the simple commands which will help you to manage systemd services.
Where systemd services are located?
Most of the systemd services are located in these locations.
/etc/systemd/system/* /run/systemd/system/* /lib/systemd/system/*
How to view the status of systemd service
The running or stopped status of systemd service can be monitored by the following command.
systemctl status SERVICE Name
systemctl status umami
How to view the list of running and enabled systemd services
This command will show the list of enabled systemd services
systemctl list-unit-files | grep enabled
How to find the location of systemd service
systemctl show NAME.service | grep Path
systemctl show umami.service | grep Path
How to create systemd service
Replace NAME with your Preferred service name
and paste the below lines into the file
[Unit] Description= Description of the Service Requires=network.target After=network.target [Service] Type=simple User=$USER WorkingDirectory= PATH OF THE FOLDER ExecStart= START COMMAND Restart=always RestartSec=3 [Install] WantedBy=multi-user.target
Here is the Example:
Save and close it. Press Ctrl + O to save. Press Ctrl + X to close
Then, Start and Enable
systemctl start NAME
systemctl enable NAME
That's it for this article.