Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
linux:manage-systemd-services [2017/09/01 15:22] – michael | linux:manage-systemd-services [2019/03/07 12:50] (current) – [Systemctl Examples] michael | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Manage | + | ====== Manage |
In many Linux based operating systems such as Debian 8, Red Hat Enterprise Linux (RHEL) and CentOS 7 systemd is now the default init system and is used for service management. | In many Linux based operating systems such as Debian 8, Red Hat Enterprise Linux (RHEL) and CentOS 7 systemd is now the default init system and is used for service management. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | **//Um eigene Systemd Unite Files zu erstellen bitte hier schauen:// | ||
+ | |||
+ | <modal id=" | ||
+ | |||
Here we will cover service management with the systemctl command, which is used to control the state of the systemd system and service manager. | Here we will cover service management with the systemctl command, which is used to control the state of the systemd system and service manager. | ||
Line 9: | Line 16: | ||
- | Here are some examples outlining how to use the systemctl command to manage various services. | + | '' |
<WRAP center box 100%> | <WRAP center box 100%> | ||
==== Check the Status of a Service ==== | ==== Check the Status of a Service ==== | ||
- | The current status of a service can be checked as shown below. | + | '' |
<sxh plain; gutter: false;> | <sxh plain; gutter: false;> | ||
Line 33: | Line 40: | ||
<sxh plain; gutter: false;> | <sxh plain; gutter: false;> | ||
[root@admin-server ~]# systemctl is-active chronyd | [root@admin-server ~]# systemctl is-active chronyd | ||
- | |||
active | active | ||
</ | </ | ||
Line 41: | Line 47: | ||
<sxh plain; gutter: false;> | <sxh plain; gutter: false;> | ||
[root@admin-server ~]# systemctl is-enabled chronyd | [root@admin-server ~]# systemctl is-enabled chronyd | ||
- | |||
enabled | enabled | ||
</ | </ | ||
Line 51: | Line 56: | ||
==== Starting, Stopping and Restarting Services ==== | ==== Starting, Stopping and Restarting Services ==== | ||
- | Systemctl can be used to start, stop and restart services as demonstrated. | + | '' |
Here we stop the chronyd service and confirm that it is no longer actively running. | Here we stop the chronyd service and confirm that it is no longer actively running. | ||
Line 58: | Line 63: | ||
[root@admin-server ~]# systemctl stop chronyd | [root@admin-server ~]# systemctl stop chronyd | ||
[root@admin-server ~]# systemctl is-active chronyd | [root@admin-server ~]# systemctl is-active chronyd | ||
- | |||
inactive | inactive | ||
</ | </ | ||
Line 67: | Line 71: | ||
[root@admin-server ~]# systemctl start chronyd | [root@admin-server ~]# systemctl start chronyd | ||
[root@admin-server ~]# systemctl is-active chronyd | [root@admin-server ~]# systemctl is-active chronyd | ||
- | |||
active | active | ||
</ | </ | ||
Line 82: | Line 85: | ||
[root@admin-server ~]# systemctl is-active chronyd | [root@admin-server ~]# systemctl is-active chronyd | ||
active | active | ||
+ | |||
[root@admin-server ~]# systemctl stop chronyd | [root@admin-server ~]# systemctl stop chronyd | ||
[root@admin-server ~]# systemctl is-active chronyd | [root@admin-server ~]# systemctl is-active chronyd | ||
inactive | inactive | ||
+ | |||
[root@admin-server ~]# systemctl try-restart chronyd | [root@admin-server ~]# systemctl try-restart chronyd | ||
[root@admin-server ~]# systemctl is-active chronyd | [root@admin-server ~]# systemctl is-active chronyd | ||
inactive | inactive | ||
+ | |||
[root@admin-server ~]# systemctl restart chronyd | [root@admin-server ~]# systemctl restart chronyd | ||
[root@admin-server ~]# systemctl is-active chronyd | [root@admin-server ~]# systemctl is-active chronyd | ||
Line 105: | Line 111: | ||
==== Enabling and Disabling Services ==== | ==== Enabling and Disabling Services ==== | ||
- | If a service is enabled it will be started automatically during system boot, however if a service is disabled it will not automatically start up during system boot. It is possible for a user or another service to manually start up the disabled service. | + | '' |
Below we can see that the chronyd service is enabled, after disabling it the symlink is removed. Once disabled the service will still be actively running, however if the system is rebooted the service will not start up unless manually started. | Below we can see that the chronyd service is enabled, after disabling it the symlink is removed. Once disabled the service will still be actively running, however if the system is rebooted the service will not start up unless manually started. | ||
Line 112: | Line 118: | ||
[root@admin-server ~]# systemctl is-enabled chronyd | [root@admin-server ~]# systemctl is-enabled chronyd | ||
enabled | enabled | ||
+ | |||
[root@admin-server ~]# systemctl disable chronyd | [root@admin-server ~]# systemctl disable chronyd | ||
rm '/ | rm '/ | ||
[root@admin-server ~]# systemctl is-enabled chronyd | [root@admin-server ~]# systemctl is-enabled chronyd | ||
disabled | disabled | ||
+ | |||
[root@admin-server ~]# systemctl is-active chronyd | [root@admin-server ~]# systemctl is-active chronyd | ||
active | active | ||
Line 148: | Line 156: | ||
[root@admin-server ~]# systemctl is-active chronyd | [root@admin-server ~]# systemctl is-active chronyd | ||
active | active | ||
+ | |||
[root@admin-server ~]# systemctl stop chronyd | [root@admin-server ~]# systemctl stop chronyd | ||
[root@admin-server ~]# systemctl start chronyd | [root@admin-server ~]# systemctl start chronyd | ||
Line 160: | Line 169: | ||
| | ||
| | ||
+ | |||
[root@admin-server ~]# systemctl is-active chronyd | [root@admin-server ~]# systemctl is-active chronyd | ||
inactive | inactive | ||
Line 169: | Line 179: | ||
[root@admin-server ~]# systemctl unmask chronyd | [root@admin-server ~]# systemctl unmask chronyd | ||
rm '/ | rm '/ | ||
+ | |||
[root@admin-server ~]# systemctl start chronyd | [root@admin-server ~]# systemctl start chronyd | ||
[root@admin-server ~]# systemctl is-active chronyd | [root@admin-server ~]# systemctl is-active chronyd | ||
Line 181: | Line 192: | ||
==== View Status of all Services ==== | ==== View Status of all Services ==== | ||
- | A list of the current status of all services can be viewed with the command below, remove --all to only list active services. | + | '' |
<sxh plain; gutter: false;> | <sxh plain; gutter: false;> | ||
Line 187: | Line 198: | ||
</ | </ | ||
- | A list of all services can be viewed to see if they are currently enabled with the command below. | + | '' |
<sxh plain; gutter: false;> | <sxh plain; gutter: false;> | ||
Line 196: | Line 207: | ||
</ | </ | ||
- | |||
- | ---- | ||
===== Summary ===== | ===== Summary ===== | ||
- | With systemctl we can check if a service is currently active or enabled to start up automatically during system boot. We can start, stop, restart and reload services, as well as disable them from starting up during system boot and even mask them to prevent them being started up completely. | + | <wrap hi>With systemctl we can check if a service is currently active or enabled to start up automatically during system boot. We can start, stop, restart and reload services, as well as disable them from starting up during system boot and even mask them to prevent them being started up completely.</ |
As systemd gains popularity and replaces older alternatives, | As systemd gains popularity and replaces older alternatives, | ||
- | |||
- | |||
- | ---- | ||
- | |||
- | https:// |