Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:systemd [2020/04/24 22:09] – [Systemctl] tmadelinux:systemd [2024/01/24 00:25] (current) – [Service Units] tmade
Line 1: Line 1:
 ===== Systemctl ===== ===== Systemctl =====
 +
 +==== Commands ====
  
   systemctl disable service                                    #Disable service from autostart e.g. "systemctl disable dhcpcd.service"   systemctl disable service                                    #Disable service from autostart e.g. "systemctl disable dhcpcd.service"
Line 20: Line 22:
   journalctl   journalctl
   journalctl -xe   journalctl -xe
-  journalctl -u sshd -f                                        # "-f" -> follow such als "tail -f file"+  journalctl -u sshd -f                                        # "-f" -> follow such as "tail -f file"
   journalctl -u kubelet.service   journalctl -u kubelet.service
   systemctl list-units --state=failed   systemctl list-units --state=failed
Line 51: Line 53:
   ln -sf /usr/lib/systemd/system/multi-user.target /etc/systemd/system/default.target    ln -sf /usr/lib/systemd/system/multi-user.target /etc/systemd/system/default.target 
  
-===== Service Units =====+==== Service Units ====
  
 Service units are located on SLES12 in: Service units are located on SLES12 in:
Line 69: Line 71:
   systemctl daemon-reload   systemctl daemon-reload
      
-to make it active.+to update it.
      
 **Warning: Always do systemd customization in "/etc/systemd/system/", never in "/usr/lib/systemd/system/". Otherwise your changes will be overwritten by the next update of systemd!** **Warning: Always do systemd customization in "/etc/systemd/system/", never in "/usr/lib/systemd/system/". Otherwise your changes will be overwritten by the next update of systemd!**
Line 132: Line 134:
 <code> <code>
 [Unit] [Unit]
-Description=Load iptables Rules +Description=iptables  
-After=bind9.service+DefaultDependencies=no 
 +Wants=network-pre.target systemd-modules-load.service local-fs.target 
 +Before=network-pre.target shutdown.target 
 +After=systemd-modules-load.service local-fs.target 
 +Conflicts=shutdown.target
  
 [Service] [Service]
 Type=oneshot Type=oneshot
 RemainAfterExit=yes RemainAfterExit=yes
-ExecStart=/bin/sh -c "/sbin/iptables-restore < /etc/iptables.up.rules"+#ExecStartPre= 
 +ExecStart=/bin/sh -c "/sbin/iptables-restore < /etc/iptables
 +ExecStartPost=/usr/bin/echo -e "\033[0;33m Start routing! \033[0m" 
 +ExecStartPost=/bin/sh -c "/usr/bin/echo "1" > /proc/sys/net/ipv4/ip_forward" 
 + 
 +ExecStop=/usr/bin/echo -e "\033[0;33m Stop routing! \033[0m" 
 +ExecStop=/bin/sh -c "/usr/bin/echo "0" > /proc/sys/net/ipv4/ip_forward" 
 +ExecStop=/bin/sh -c "/sbin/iptables -F && /sbin/iptables -X && /sbin/iptables -t nat -F && /sbin/iptables -t nat -X && /sbin/iptables -t mangle -F && /sbin/iptables -t mangle -X && /sbin/iptables -P INPUT ACCEPT && /sbin/iptables -P FORWARD ACCEPT && /sbin/iptables -P OUTPUT ACCEPT" 
 +ExecStop=/usr/bin/echo -e "\033[0;33m iptables deleted! \033[0m"
  
 [Install] [Install]
 WantedBy=multi-user.target WantedBy=multi-user.target
-WantedBy=network-online.target+#WantedBy=network-online.target
 </code> </code>
  
Line 222: Line 236:
 to service unit! to service unit!
  
-===Targets===+====systemd targets====
  
   multi-user.target                  #multiuser + network   multi-user.target                  #multiuser + network
linux/systemd.1587758958.txt.gz · Last modified: 2020/04/24 22:09 by tmade
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki