NOTE: This article applies to more recent Linux distrubutions:
- RHEL/CentOS 7+
- Fedora 21+
- Debian 8+
- Ubuntu 16+
The experienced System Administrator will know SysVinit and the perennial init
commands used to control system run levels, for example, init 6
to reboot.
As of 2014, however, most Linux distributions now rely on the newer Systemd system and service manager. While the init
commands can still be used there are some notable advantages that Systemd offers. Below are a few such advantages.
- Systemd daemons make it is easier to supervise and control processes and parallelized job execution.
- Systemd offers the
systemctl
command andcgroups
to make your life easier:systemctl
provides the administrator with more detailed error messages including runtime and start-up errors.cgroups
, or "control groups", allow for the grouping of processes into a hierarchy for easier management.
- Process attributes such as function and ownership are much easier to ascertain. For example, under Systemd, sub-processes, once spawned, become 'children' and are organized under the appropriate 'parent' group to show inheritance.
To see an example of the clear visual hierarchy and process management under Systemd, try the pstree
command.
On my CentOS 7 system it looks like this:
Useful Systemd Commands:
For controlling runlevels:
systemctl poweroff
--> shut down (enter runlevel 0)systemctl rescue.target
--> enter rescue mode (runlevel 1, single-user)systemctl multi-user.target
--> enter multi-user mode (runlevels 2 through 4)systemctl graphical.target
--> enter graphical mode (runlevel 5)systemctl reboot
--> reboot the system (runlevel 6)
For controlling services:
systemctl start dummy.service
--> start the "dummy" servicesystemctl stop dummy.service
--> stop the "dummy" servicesystemctl restart dummy.service
--> restart the "dummy" servicesystemctl status dummy.service
--> get status of "dummy" servicesystemctl kill dummy
--> kill all processes related to "dummy" service
Miscellaneous:
journalctl -f
--> follow the system logs (i.e.tail -f /var/log/messages
)journalctl --since=today
--> get logs of all events that have occurred todayhostnamectl
--> get system hostname and other host informationtimedatectl
--> get system date, time, and timezone information
SOURCE: Linoxide's write-up here: https://linoxide.com/linux-command/systemd-vs-sysvinit-cheatsheet (includes beautiful, downloadable PDF version)