2017-12-20 14:37:20 +00:00
[#starting-stopping-and-querying-systemd-services]
2018-02-26 16:43:59 +00:00
= Starting, stopping, and querying systemd services
2017-12-20 14:37:20 +00:00
2020-08-05 15:59:16 +00:00
You can perform various management tasks to control _systemd_ services using the `systemctl` command. The following is a set of example commands to demonstrate how to use `systemctl` to manage _systemd_ services.
2017-12-20 14:37:20 +00:00
2020-07-26 18:35:01 +00:00
[discrete]
2020-08-05 13:14:35 +00:00
== Prerequisites
2017-12-20 14:37:20 +00:00
2018-01-21 17:04:05 +00:00
You are logged in as a user with administrator-level permissions.
2017-12-20 14:37:20 +00:00
2020-07-26 18:35:01 +00:00
[discrete]
2020-08-05 13:14:35 +00:00
== Procedure
2017-12-20 14:37:20 +00:00
The following commands control the `foo` service:
* Activate a service immediately:
+
----
2018-01-21 17:04:05 +00:00
# systemctl start foo
2017-12-20 14:37:20 +00:00
----
* Deactivate a service immediately:
+
----
2018-01-21 17:04:05 +00:00
# systemctl stop foo
2017-12-20 14:37:20 +00:00
----
* Restart a service:
+
----
2018-01-21 17:04:05 +00:00
# systemctl restart foo
2017-12-20 14:37:20 +00:00
----
2020-08-05 15:59:16 +00:00
* Show the status of a service including, whether it is running or not:
2017-12-20 14:37:20 +00:00
+
----
2018-01-21 17:04:05 +00:00
# systemctl status foo
2017-12-20 14:37:20 +00:00
----
2020-08-05 15:59:16 +00:00
* Enable a service to be started on boot:
2017-12-20 14:37:20 +00:00
+
----
2018-01-21 17:04:05 +00:00
# systemctl enable foo
2017-12-20 14:37:20 +00:00
----
2020-08-05 15:59:16 +00:00
* Disable a service to not start during boot:
2017-12-20 14:37:20 +00:00
+
----
2018-01-21 17:04:05 +00:00
# systemctl disable foo
2017-12-20 14:37:20 +00:00
----
* Prevent a service from starting dynamically or even manually unless unmasked:
+
----
2018-01-21 17:04:05 +00:00
# systemctl mask foo
2017-12-20 14:37:20 +00:00
----
2020-08-05 15:59:16 +00:00
* Check if a service is enabled or not:
2017-12-20 14:37:20 +00:00
+
----
2018-01-21 17:04:05 +00:00
# systemctl is-enabled foo
2017-12-20 14:37:20 +00:00
----
2020-07-26 18:35:01 +00:00
[discrete]
2020-08-05 13:14:35 +00:00
== Related Information
2017-12-20 14:37:20 +00:00
2018-01-21 17:04:05 +00:00
* Run `man systemctl` for more details.