How to use/manage systemd in Centos 7?

Systemd! who doesn’t know about it eh? But do you really know how to use it to find service names, service statuses, binary associated to the service, reloading systemd config etc etc .. may be not. Well lets try to address that today:

How to list all the services:

systemctl list-units --all

You can then use “/STRINGNAME” to find the service you are concerned about or if you are a GREP< fan you can use systemctl list-units –no-pager | grep “mariadb”

The above can be useful for nagios or zabbix checks.

How to start the service:

systemctl start mariadb

How to stop the service:

systemctl stop mariadb

How to enable service on boot:

systemctl enable mariadb

How to disable service on boot:

systemctl disable mariadb

How to find file associated to a service:

systemctl show mariadb --no-pager | grep Fragment

FragmentPath=/usr/lib/systemd/system/mariadb.service

How to cat the service file associated to a file:

systemctl cat mariadb

Leave a Reply

Your email address will not be published. Required fields are marked *