Here are some useful notes about systemd.
- Display the current version of systemd
# systemctl --version
- Display boot process duration
# systemd-analyze
- Get the time spent by each task during the boot process
# systemd-analyze blame
- Get the list of the dependencies
# systemctl list-dependencies
- Get the list of dependencies for a particular service
# systemctl list-dependencies sshd.service
- Get the content of systemd journal
# journalctl
- Get all the events related to the crond process in the journal
# journalctl /sbin/crond
- Get all the events since the last boot
# journalctl -b
- Get all the events that appeared today in the journal
# jornalctl --since=today
- Get all the events with a syslog priority of err
# journalctl -p err
- Get the 10 last events and wait for any new one ‘(like tail -f /var/log/messages)’
# journalctl -f
- By default journald ared stored in the /var/run/log/journald directory and disapear after reboot.
# mkdir /var/log/jornald
# echo "SystemMaxUse=50M" >> /etc/systemd/journald.conf
# systemctl restart systemd-journald
- Display the disk space used by jornald
# journalctl --disk-usage
- Get the full hierarchy of control groups
# systemd-cgls
- Get the list of control group ordered by CPU, memory and disk I/O load
# systemd-cgtop
- Kill all the processes associated with an apache server
# systemctl kill httpd
- Put resource limits on a service (here 500 CPUShares)
# systemctl set-property httpd.service CPUShares=500
- Get the current CPUShares service value
# systemctl show -p CPUShares httpd.service
- Service managment ‘(you can omit .service if you wish)’
# systemctl 'status|enable|disable|start|stop|restart|reload' sshd.service
- Display if service is enabled
# systemctl is-enabled sshd
- If you change a service configuration, you will need to reload systemd
# systemctl daemon-reload
# systemctl list-unit-files
- Get the list of services that failed at boot
# systemctl --failed
- Get the status of a service on a remote server
# systemctl -H root@jason.local status sshd.service
- Get all the configuration details about a service
# systemctl show sshd
# localectl
# localectl set-locale LANG=en_US.utf8
- Change the console keymap
# localectl set-keymap en_US
# localectl set-x11-keymap en_US
- Get current date and time
# timedatectl
# timedatectl set-time YYYY-MM-DD
# timedatectl set-time HH:MM:SS
# timedatectl list-timezones
# timedatectl set-timezone America/Sao_Paulo
# loginctl list-users
# loginctl list-sessions
- Display properties from a user
# loginctl show-user kdiegorsantos
- Set runlevel 3 as default
# systemctl set-default -f multi-user.target
# systemctl rescue
# systemctl isolate runlevel3.target
# systemctl isolate graphical.target
- Poweroff, restart, suspend or hibernate.
# systemctl 'poweroff|restart|suspend|hibernate'