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
cgroupsto make your life easier:
systemctlprovides 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
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" service
systemctl stop dummy.service--> stop the "dummy" service
systemctl restart dummy.service--> restart the "dummy" service
systemctl status dummy.service--> get status of "dummy" service
systemctl kill dummy--> kill all processes related to "dummy" service
journalctl -f--> follow the system logs (i.e.
tail -f /var/log/messages)
journalctl --since=today--> get logs of all events that have occurred today
hostnamectl--> get system hostname and other host information
timedatectl--> 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)