(This post applies to CentOS 7, RHEL 7, Fedora 21+, and recent Debian and Ubuntu-based distributions.)
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 and cgroups 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:
Here are some useful Systemd commands for your reference...
1. systemctl poweroff --> shut down (runlevel 0)
2. systemctl rescue.target --> enter rescue mode (runlevel 1, single-user)
3. systemctl multi-user.target --> enter multi-user mode (runlevels 2 through 4)
4. systemctl graphical.target --> enter graphical mode (runlevel 5)
5. systemctl reboot --> reboot the system (runlevel 6)
1. systemctl start dummy.service --> start the "dummy" service
2. systemctl stop dummy.service --> stop the "dummy" service
3. systemctl restart dummy.service --> restart the "dummy" service
4. systemctl status dummy.service --> get status of "dummy" service
5. systemctl kill dummy --> kill all processes related to "dummy" service
Other Useful Commands:
1. journalctl -f --> follow the system logs (i.e. 'tail -f /var/log/messages')
2. journalctl --since=today --> get logs of all events that have occurred today
3. hostnamectl --> get system hostname and other host information
4. timedatectl --> get system date, time, and timezone information
There are many more examples of commands available, as well as a beautiful PDF you can download, on Linoxide's write-up here: linoxide.com/linux-command/systemd-vs-sysvinit-cheatsheet