Zoek:

Systemd Cheatsheet

Naslag voor systemd commando's.

Viewing Systemd Information

systemctl list-dependenciesShow a unit's dependencies
systemctl list-socketsList sockets and what activates
systemctl list-jobsView active systemd jobs
systemctl list-unit-filesSee unit files and their states
systemctl list-unitsShow if units are loaded/active
systemctl get - defaultList default target (like run level)

Working with Services

systemctl stop serviceStop a running service
systemctl start serviceStart a service
systemctl restart serviceRestart a running service
systemctl reload serviceReload all config files in service
systemctl status serviceSee if service is running/enabled
systemctl enable serviceEnable a service to start on boot
systemctl disable serviceDisable service (won't start at boot)
systemctl show serviceShow properties of a service (or other unit)
systemctl -H host status networkRun any systemctl command remotely

Changing System States

systemctl rebootReboot the system (reboot.target)
systemctl poweroffPower off the system (poweroff.target)
systemctl emergencyPut in emergency mode (emergency.target)
systemctl defaultBack to default target (multi-user.target)

Viewing Log Messages

journalctlShow all collected log messages
journalctl -u network.serviceSee network service messages
journalctl -fFollow messages as they appear
journalctl -kShow only kernel messages

SysVinit to Systemd Cheat Sheet

Sysvinit CommandSystemd CommandNotes
service SERVICE_NAME startsystemctl start SERVICE_NAME
(Example: systemctl start cron.service)
Used to start a service (not reboot persistent)
service SERVICE_NAME stopsystemctl stop SERVICE_NAMEUsed to stop a service (not reboot persistent)
service SERVICE_NAME restartsystemctl restart SERVICE_NAMEUsed to stop and then start a service
service SERVICE_NAME reloadsystemctl reload SERVICE_NAMEWhen supported, reloads the config file without interrupting pending operations
service SERVICE_NAME condrestartsystemctl condrestart SERVICE_NAMERestarts if the service is already running
service SERVICE_NAME statussystemctl status SERVICE_NAMETells whether a service is currently running
ls /etc/rc.d/init.d/systemctl or systemctl list-unit-files --type=service or
ls /lib/systemd/system/*.service /etc/systemd/system/*.service
Used to list the services that can be started or stopped
Used to list all the services and other units
chkconfig SERVICE_NAME onsystemctl enable SERVICE_NAMETurn the service on, for start at next boot, or other trigger
chkconfig SERVICE_NAME offsystemctl disable SERVICE_NAMETurn the service off for the next reboot, or any other trigger
chkconfig SERVICE_NAMEsystemctl is-enabled SERVICE_NAMEUsed to check whether a service is configured to start or not in the current environment
chkconfig --listsystemctl 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:onsystemctl list-dependencies graphical.targetPrint a table of services that will be started when booting into graphical mode
chkconfig SERVICE_NAME --listls /etc/systemd/system/*.wants/SERVICE_NAME.serviceUsed to list what levels this service is configured on or off
chkconfig SERVICE_NAME --add systemctl daemon-reloadUsed when you create a new service file or modify any configuration

Runlevels to Targets Cheat Sheet

Sysvinit RunlevelSystemd TargetNotes
0runlevel0.target, poweroff.targetHalt the system
1, s, singlerunlevel1.target, rescue.targetSingle user mode
2, 4runlevel2.target, runlevel4.target, multi-user.targetUser-defined/Site-specific runlevels. By default, identical to 3
3runlevel3.target, multi-user.targetMulti-user, non-graphical. Users can usually login via multiple consoles or via the network
5runlevel5.target, graphical.targetMulti-user, graphical. Usually has all the services of runlevel 3 plus a graphical login
6runlevel6.target, reboot.targetReboot
emergencyemergency.targetEmergency shell

Changing runlevels

Sysvinit CommandSystemd CommandNotes
telinit 3systemctl isolate multi-user.target or
systemctl isolate runlevel3.target or
telinit 3
Change to multi-user run level
sed s/^id:.*:initdefault:/id:3:initdefault:/ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.targetSet to use multi-user runlevel on next reboot
Pagina laatst gewijzigd op 18 mei 2018 om 14:42