Letzte Änderung: 13. Juli 2021
MySQL/MariaDB Logo



systemd, das neue Init System und noch viel mehr.
Es startet, überwacht, und beendet alle weiteren Services, ist für das mitloggen von Servicerückmeldungen und Benutzerinteraktionen zuständig.
Zudem verwaltet systemd die Mounts, und beherrscht die Abhängigkeitsauflösung beim Starten von zusätzlichen Services.
Unit-Dateien, die auf .target enden, definieren Gruppen aus Units.


systemctl Kommandos


Hier nun die wichtigsten Befehle: Unit starten: $ systemctl start unit Unit stoppen: $ systemctl stop unit Unit neustarten: $ systemctl restart unit Unit Konfiguration neuladen: $ systemctl reload unit Statusanzeige einer Unit: $ systemctl status unit Reboot $ systemctl reboot Shutdown $ systemctl poweroff Boot Prozess dauer: $ systemd-analyze Boot Prozess dauer jedes einzelnen Dienstes: $ systemd-analyze blame --- Checken ob die Unit beim Neustart gestartet wird: $ systemctl is-enabled unit Unit zum start beim booten markieren: $ systemctl enable unit Unit beim booten zum nicht starten markieren: $ systemctl disable unit Anleitung für die Unit aufrufen: $ systemctl help unit Reload systemd, scannt nach neuen oder geänderten Units: $ systemctl daemon-reload --- Alle Units auflisten: $ systemctl oder systemctl list-units oder systemctl list-unit-files Alle Failed Units auflisten: $ systemctl --failed Alle Autostart Units auflisten: $ systemctl list-unit-files | grep ".service" | grep enabled --- To kill all the processes associated with an apache server (CGI scripts included), type: # systemctl kill httpd

journalctl Kommandos


systemd hat ein eigenes Logsystem, gennant Journal. Hier einige wichtige Befehle ... Alle Meldungen vom letzten Bootvorgang anzeigen. This is possible through optional offset parameter of the -b flag: journalctl -b -0 shows messages from the current boot, journalctl -b -1 from the previous boot, journalctl -b -2 from the second previous and so on : $ journalctl Fehler anzeigen: $ journalctl -p err $ journalctl -b -0 $ journalctl -b -0 -p err $ journalctl -f -b -p err Alle Meldung ab Datum/Zeit: $ journalctl --since="2012-10-30 18:17:16" $ journalctl --since=2014-12-22 --until="2014-12-23 19:30:45" $ journalctl --since=today $ journalctl -u avahi-daemon.service --since=19:30 --until=20:30 Alle aktuellen Meldungen im Live View: $ journalctl -f Alle Meldungen eines bestimmten Programmes: $ journalctl /sbin/crond Alle Meldungen eines bestimmten Prozesses: $ journalctl _PID=1 Alle Meldungen einer bestimmten Unit: $ journalctl -u nginx.service -u mysql.service Alle Bootvorgägne anzeigen: $ journalctl --list-boots Show kernel ring buffer: $ journalctl -k by PID: $ journalctl _PID=1537

runlevel


How do I change the target (runlevel) ? systemd has the concept of targets which is a more flexible replacement for runlevels in sysvinit. Run level 3 is emulated by multi-user.target. Run level 5 is emulated by graphical.target. runlevel3.target is a symbolic link to multi-user.target and runlevel5.target is a symbolic link to graphical.target. You can switch to 'runlevel 3' by running $ systemctl isolate multi-user.target You can switch to 'runlevel 5' by running $ systemctl isolate graphical.target How do I change the default target? $ systemctl set-default .target graphical.target is the default. You might want multi-user.target for the equivalent of non graphical (runlevel 3) from sysv init. The full list of targets can be accessed via systemctl list-units --type=target systemd does not use /etc/inittab file. How do I know the current target? $ systemctl get-default How do I know the current run level? $ runlevel runlevel command still works with systemd. You can continue using that however runlevels is a legacy concept in systemd and is emulated via 'targets' and multiple targets can be active at the same time. So the equivalent in systemd terms is $ systemctl list-units --type=target

localectl


localectl To get the current locale, virtual console keymap and X11 layout, type: # localectl System Locale: LANG=en_US.UTF-8 VC Keymap: en_US X11 Layout: en_US To assign the en_GB.utf8 value to the locale, type: # localectl set-locale LANG=en_GB.utf8 To assign the en_GB value to the virtual console keymap, type: # localectl set-keymap en_GB

timedatectl


timedatectl To get the current date and time, type: # timedatectl Local time: Fri 2014-01-24 22:34:05 CET Universal time: Fri 2014-01-24 21:34:05 UTC RTC time: Fri 2014-01-24 21:34:05 Timezone: Europe/Madrid (CET, +0100) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: no Last DST change: DST ended at Sun 2013-10-27 02:59:59 CEST Sun 2013-10-27 02:00:00 CET Next DST change: DST begins (the clock jumps one hour forward) at Sun 2014-03-30 01:59:59 CET Sun 2014-03-30 03:00:00 CEST To set the current date, type: # timedatectl set-time YYYY-MM-DD To set the current time, type: # timedatectl set-time HH:MM:SS To get the list of time zones, type: # timedatectl list-timezones To change the time zone to America/New_York, type: # timedatectl set-timezone America/New_York

loginctl


loginctl To get the users’ list, type: # loginctl list-users UID USER 42 gdm 1000 tom 0 root To get the list of all current user sessions, type: # loginctl list-sessions SESSION UID USER SEAT 1 1000 tom seat0 1 sessions listed. To get the properties of the user tom, type: # loginctl show-user tom UID=1000 GID=1000 Name=tom Timestamp=Fri 2014-01-24 21:53:43 CET TimestampMonotonic=160754102 RuntimePath=/run/user/1000 Slice=user-1000.slice Display=1 State=active Sessions=1 IdleHint=no IdleSinceHint=0 IdleSinceHintMonotonic=0
nach oben