{{tag>Brouillon SystemD}} # Notes SystemD Voir : * [[Systemd journalctl journal logs|journalctl]] * [[redhat_acces_var_log_mariadb_mariadb.log_sans_etre_root|systemd service dépendant d'un autre service]] * https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units * https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files * https://linuxembedded.fr/2021/11/limiter-les-ressources-dune-ligne-de-commande-avec-systemd * [Durcir nginx et PHP avec systemd](https://linuxfr.org/users/samuel/journaux/durcir-nginx-et-php-avec-systemd) [Hardening Security focused systemd configuration](https://github.com/konstruktoid/hardening/blob/master/systemd.adoc) Lister les services ~~~bash systemctl list-unit-files systemctl list-units ~~~ Lister les services inactifs ~~~bash systemctl list-units -all --state=inactive ~~~ Lister les services KO ~~~bash systemctl -a | grep dead ~~~ Lister les services actifs ~~~bash # SystemD systemctl list-units --type service --state active # Avant SystemD chkconfig --list | grep -E '[1-5]:on' ~~~ Savoir si le service est activé ou désactivé ~~~bash systemctl is-active httpd systemctl is-enabled httpd ~~~ Relire la conf ~~~bash systemctl daemon-reload ~~~ Les différents types de services * http://doc.fedora-fr.org/wiki/Systemd#Type_de_service Runlevel et Target | **Runlevel** | **Target** | | ------------ | ----------------- | | 0 | poweroff.target | | 1 | rescue.target | | 2, 3, 4 | multi-user.target | | 5 | graphical.target | | 6 | reboot.target | ## Contrôler des services (Units) SystemD distants avec Hirte Voir : * Exemple ~~~bash hirtectl start rpi4 httpd.service ~~~ ## Debug ~~~bash systemctl show --property=Environment docker ~~~ ## Autres If you don't like systemctl's auto-paging feature ~~~bash export SYSTEMD_PAGER= ~~~ ### Logs entre deux date ~~~bash journalctl --since "2019-10-16 06:00" --until "2019-10-16 10:00" ~~~ ### Disable systemd redirection ~~~bash export _SYSTEMCTL_SKIP_REDIRECT=1 ~~~ ### tmpfile ~~~ini [Service] PrivateTmp=true ~~~ --- ~~~bash man -k tmpfiles ~~~ /etc/tmpfiles.d `/etc/tmpfiles.d/python.conf` ~~~ x /tmp/pymp-* ~~~ ### reboot ~~~bash systemctl reboot ~~~ ### Lang Locale Voir [[notes_langue_lang_locale_temps_timezone_tz|Notes langue lang locale - SystemD]] ~~~bash #timedatectl list-timezones timedatectl set-timezone Europe/Paris ~~~ ## Pb ### RemoveIPC - Quand Poettering fait des siennes Problème si compte UID > 1000 à cause de **RemoveIPC** https://linuxfr.org/users/neologix/journaux/systemd-attention-a-removeipc RemoveIPC Directive \\ A new option called RemoveIPC was introduced in RHEL 7.2 through Systemd v219. When set to yes, this option forces a cleanup of all allocated inter-process communication (IPC) resources linked to a user leaving his last session. If a daemon is running as a user with a uid number >=1000, it may crash. This option should always be set to no by default but, due to the logic of package upgrade, it is highly advisable to set RemoveIPC=no in the /etc/systemd/logind.conf file followed by # systemctl restart systemd-logind (source). Source : https://www.certdepot.net/rhel7-changes-between-versions/