Get started with systemd

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
  • Display unit files
# 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
  • Get current locale
# localectl
  • Change current locale
# localectl set-locale LANG=en_US.utf8
  • Change the console keymap
# localectl set-keymap en_US
  • Change the X11 keymap
# localectl set-x11-keymap en_US
  • Get current date and time
# timedatectl
  • Change date
# timedatectl set-time YYYY-MM-DD
  • Change time
# timedatectl set-time HH:MM:SS
  • Get the list of zones
# timedatectl list-timezones
  • Change the time zone
# timedatectl set-timezone America/Sao_Paulo
  • Get user list
# loginctl list-users
  • Get current sessions
# loginctl list-sessions
  • Display properties from a user
# loginctl show-user kdiegorsantos
  • Set runlevel 3 as default
# systemctl set-default -f multi-user.target
  • Move to rescue mode
# systemctl rescue
  • Move to runlevel 3
# systemctl isolate runlevel3.target
  • Move to graphical mode
# systemctl isolate graphical.target
  • Poweroff, restart, suspend or hibernate.
# systemctl 'poweroff|restart|suspend|hibernate'

 

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s