2017-12-20 14:37:20 +00:00
[#starting-stopping-and-querying-systemd-services]
= Starting, stopping, and querying Systemd services
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.
.Prerequisites
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
.Procedure
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
----
* Show the status of a service including if it is running or not:
+
----
2018-01-21 17:04:05 +00:00
# systemctl status foo
2017-12-20 14:37:20 +00:00
----
* Enable a service to be started on bootup:
+
----
2018-01-21 17:04:05 +00:00
# systemctl enable foo
2017-12-20 14:37:20 +00:00
----
* Disable a service to not start during bootup:
+
----
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
----
* Check if a service is already enabled or not:
+
----
2018-01-21 17:04:05 +00:00
# systemctl is-enabled foo
2017-12-20 14:37:20 +00:00
----
.Related Information
2018-01-21 17:04:05 +00:00
* Run `man systemctl` for more details.