Cheatography
https://cheatography.com
Systemd : system state, services management, troubleshooting and runlevels.
System state
Old command |
Systemd command |
Description |
halt |
systemctl halt |
Halts the system. |
poweroff |
systemctl poweroff |
Powers off the system. |
reboot |
systemctl reboot |
Restarts the system. |
pm-suspend |
systemctl suspend |
Suspends the system. |
pm-hibernate |
systemctl hibernate |
Hibernates the system. |
pm-suspend-hybrid |
systemctl hybrid-sleep |
Hibernates and suspend the system. |
Services management
SysVinit command |
Systemd command |
Notes |
service httpd start |
systemctl start httpd.service |
Start a service (not reboot persistent). |
service httpd stop |
systemctl stop httpd.service |
Stop a service (not reboot persistent). |
service httpd restart |
systemctl restart httpd.service |
Restart a service. |
service httpd reload |
systemctl reload httpd.service |
Reloads the configuration files without interrupting pending operations. |
service httpd condrestart |
systemctl condrestart httpd.service |
Restarts if the service is already running. |
service httpd status |
systemctl status httpd.service |
Shows the status of a service. |
service --status-all |
systemctl list-units --type=service |
Displays the status of all services. |
ls /etc/rc.d/init.d/ |
systemctl list-unit-files --type=service |
List the services that can be started or stopped. |
chkconfig httpd on |
systemctl enable httpd.service |
Start service at next boot. |
chkconfig httpd off |
systemctl disable httpd.service |
Service won't be started on next boot. |
chkconfig httpd |
systemctl is-enabled httpd.service |
Check if a service is configured to start in the current environment. |
chkconfig --list |
systemctl list-unit-files --type=service or ls /etc/systemd/system/*.wants/ |
Print a list of services showing which runlevels they are configured for. |
chkconfig httpd --list |
ls /etc/systemd/system/*.wants/httpd.service |
Show which runlevels a service is configured for. |
chkconfig httpd --add |
systemctl daemon-reload |
Run this command after a change in any configuration file (old or new). |
Investigate
Command |
Notes |
systemctl get-default |
Determine which target unit is used by default. |
systemctl set-default multi-user.target |
Change default boot target to multi-user.target. |
journalctl -b |
Show all messages from last boot. |
journalctl -b -p err |
Show all messages of priority level ERROR and more from last boot. |
journalctl -p warning --since="2015-07-31 12:34:56" --until="2015-09-19 23:59:59" |
View the messages of priority level WARNING or more from a certain date and time. |
journalctl -f |
Follow new messages a la tail -f. |
journalctl -u SERVICE |
Show logs for SERVICE. |
journalctl /usr/sbin/httpd |
Show all messages related to a specific executable. |
journalctl --full |
Display all messages without truncating any. |
systemctl --state=failed |
Display the services that failed to start. |
systemctl list-units --type=target |
Show current runlevel. |
systemctl isolate graphical.target |
Change the current runlevel (target). |
systemctl rescue/emergency |
Switch to Rescue (single user)/Emergency mode. |
systemctl kill SERVICE.service |
Gently kill SERVICE (SIGTERM, 15). |
systemd-cgls |
Show the full systemd control group (cgroup) hierarchy as a tree. |
systemctl show -p "Wants" multi-user.target |
Find out what other units does a unit depend on. |
systemctl list-jobs |
Show jobs. |
Runlevels
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 runlevels (identical to 3). |
3 |
runlevel3.target, multi-user.target |
Multi-user, non-graphical. |
5 |
runlevel5.target, graphical.target |
Multi-user, graphical. |
6 |
runlevel6.target, reboot.target |
Rebbot. |
emergency |
emergency.target |
Emergency shell. |
|
Created By
https://tme520.com
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by TME520