Laboratorium Komputerowe Progmar
Marcin Załęczny

We are using cookies in the page. If you use the page you agree for the cookies.      Close

Systemd

Displays unit files list of the systemd init process: sudo systemctl list-unit-files

Displays a list of services that could not be run while system startup: sudo systemctl --state=failed

Displays detailed information about specified service: sudo systemctl status mysql.service

Stops specified service: sudo systemctl stop mysql

Starts specified service: sudo systemctl start mysql

Kills all processes that belongs to specified service: sudo systemctl kill mysql

Sends SIGHUP signal to the test process of specified service: sudo systemctl kill -s HUP --kill-who=test mysql

Makes a specified service not to run during system startup: sudo systemctl disable mysql

Makes a specified service to run during system startup: sudo systemctl enable mysql

To run a custom script (here: /usr/local/bin/firewall.sh) during system startup, first we need to create a unit file for the script, for ex.: /lib/systemd/system/firewall.service with the following content:

# iptables firewall service file

[Unit]
Description=Iptables firewall and fwsnort rules
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=root
Group=root
ExecStart=/usr/local/bin/firewall.sh
Next we enables the service: sudo systemctl enable firewall

Displays load time stats for all services being run at the system startup (both kernel and user space): systemd-analyze

Displays load time stats for all services being run: systemd-analyze blame

Generates a load time stats plot for all services: systemd-analyze plot >plot.svg View created plot with eye of gnome application: eog plot.svg

Displays system journal messages since last system startup: sudo journalctl

Displays system journal error messages since last system startup: sudo journalctl -b -p err

Displays system journal messages since specified period: sudo journalctl --since=yesterday sudo journalctl --since=2016-05-28

Displays system journal messages within specified time period: sudo journalctl --since=2016-05-27 --until=2016-05-29

Displays system journal messages generated by given service (mysql) within specified time period: sudo journalctl -u mysql --since=yesterday --until=now

Displays all systemd services/units which system journal messages can be filtered for: sudo journalctl -F _SYSTEMD_UNIT

Displays all metadata that was registered ever: sudo journalctl -o verbose -n

Filters system journal messages for specified metadata (here: _UID and _EXEC) and its values: sudo journalctl _UID=0 _EXE=/usr/sbin/thermald