Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:manage-systemd-services [2017/09/01 15:22] michaellinux:manage-systemd-services [2019/03/07 12:50] (current) – [Systemctl Examples] michael
Line 1: Line 1:
-====== Manage Systend Services ======+====== Manage Systemd Services ======
 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.
 +
 +{{:linux:systemctl.png?nolink&500|}}
 +
 +**//Um eigene Systemd Unite Files zu erstellen bitte hier schauen://** -> <btn type="danger" modal="modal-systemd">Systemd Service konfigurieren</btn>
 + 
 +<modal id="modal-systemd" size="lg" remote="linux:systemd"></modal>
 +
  
 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.+''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.+''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
 </sxh> </sxh>
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
 </sxh> </sxh>
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.+''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
 </sxh> </sxh>
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
 </sxh> </sxh>
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.+''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 '/etc/systemd/system/multi-user.target.wants/chronyd.service' rm '/etc/systemd/system/multi-user.target.wants/chronyd.service'
 [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:
    Loaded: masked (/dev/null)    Loaded: masked (/dev/null)
    Active: inactive (dead)    Active: inactive (dead)
 +   
 [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 '/etc/systemd/system/chronyd.service' rm '/etc/systemd/system/chronyd.service'
 +
 [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.+''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:
 </sxh> </sxh>
  
-A list of all services can be viewed to see if they are currently enabled with the command below.+''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:
 </WRAP> </WRAP>
  
- 
----- 
  
 ===== 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.</wrap>
  
 As systemd gains popularity and replaces older alternatives, it is more important to understand how to work with services with systemctl. As systemd gains popularity and replaces older alternatives, it is more important to understand how to work with services with systemctl.
  
- 
- 
----- 
- 
-https://www.rootusers.com/how-to-manage-linux-systemd-services-with-systemctl/ 
  • linux/manage-systemd-services.1504272176.txt.gz
  • Last modified: 2017/09/01 15:22
  • by michael