Systemd Cheat Sheet PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

LinuxTrainingAcademy.

com

Viewing Systemd Information


systemctl list-dependencies Show a unit's dependencies
systemctl list-sockets List sockets and what activates
systemctl list-jobs View active systemd jobs
systemctl list-unit-files See unit files and their states
systemctl list-units Show if units are loaded/active
systemctl get - default List default target (like run level)

Working with Services


systemctl stop service Stop a running service
systemctl start service Start a service
systemctl restart service Restart a running service
systemctl reload service Reload all config files in service
systemctl status service See if service is running/enabled
systemctl enable service Enable a service to start on boot
systemctl disable service Disable service--won't start at boot
systemctl show service Show properties of a service (or other unit)
systemctl -H host status network Run any systemctl command remotely

Changing System States


systemctl reboot Reboot the system (reboot.target)
systemctl poweroff Power off the system (poweroff.target)
systemctl emergency Put in emergency mode (emergency.target)
systemctl default Back to default target (multi-user.target)

Viewing Log Messages


journalctl Show all collected log messages
journalctl -u network.service See network service messages
journalctl -f Follow messages as they appear
journalctl -k Show only kernel messages

SysVinit to Systemd Cheat Sheet


Sysvinit Command Systemd Command Notes
service SERVICE_NAME start systemctl start SERVICE_NAME (Example: systemctl start cron.service) Used to start a service (not reboot persistent)
service SERVICE_NAME stop systemctl stop SERVICE_NAME Used to stop a service (not reboot persistent)
service SERVICE_NAME restart systemctl restart SERVICE_NAME Used to stop and then start a service
service SERVICE_NAME reload systemctl reload SERVICE_NAME When supported, reloads the config file without interrupting pending operations.
service SERVICE_NAME condrestart systemctl condrestart SERVICE_NAME Restarts if the service is already running.
service SERVICE_NAME status systemctl status SERVICE_NAME Tells whether a service is currently running.
ls /etc/rc.d/init.d/ systemctl (or) systemctl list-unit-files --type=service (or) Used to list the services that can be started or stopped
ls /lib/systemd/system/*.service /etc/systemd/system/*.service Used to list all the services and other units
chkconfig SERVICE_NAME on systemctl enable SERVICE_NAME Turn the service on, for start at next boot, or other trigger.
chkconfig SERVICE_NAME off systemctl disable SERVICE_NAME Turn the service off for the next reboot, or any other trigger.
chkconfig SERVICE_NAME systemctl is-enabled SERVICE_NAME Used to check whether a service is configured to start or not in the current environment.
chkconfig --list systemctl list-unit-files --type=service (or) ls /etc/systemd/system/*.wants/ Print a table of services that lists which runlevels each is configured on or off
chkconfig --list | grep 5:on systemctl list-dependencies graphical.target Print a table of services that will be started when booting into graphical mode
chkconfig SERVICE_NAME --list ls /etc/systemd/system/*.wants/SERVICE_NAME.service Used to list what levels this service is configured on or off
chkconfig SERVICE_NAME --add systemctl daemon-reload Used when you create a new service file or modify any configuration

Runlevels to Targets Cheat Sheet


Sysvinit Runlevel Systemd Target Notes
0 runlevel0.target, poweroff.target Halt the system.
1, s, single runlevel1.target, rescue.target Single user mode.
2, 4 runlevel2.target, runlevel4.target, multi-user.target User-defined/Site-specific runlevels. By default, identical to 3.
3 runlevel3.target, multi-user.target Multi-user, non-graphical. Users can usually login via multiple consoles or via the network.
5 runlevel5.target, graphical.target Multi-user, graphical. Usually has all the services of runlevel 3 plus a graphical login.
6 runlevel6.target, reboot.target Reboot
emergency emergency.target Emergency shell

Changing runlevels:
Sysvinit Command Systemd Command Notes
telinit 3 systemctl isolate multi-user.target Change to multi-user run level.
(OR systemctl isolate runlevel3.target OR telinit 3)
sed s/^id:.*:initdefault:/id:3:initdefault:/ ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target Set to use multi-user runlevel on next reboot.

LinuxTrainingAcademy.com

You might also like