Manage Services in RHEL 7
systemd defines itself as a system and service manager. The project was initiated in 2010 by Lennart Poettering and Kay Sievers to create an integrated set of tools for managing a Linux system including an init daemon. It also includes device management (udev) and logging, among other things.
- systemd can monitor services and restart them if needed
- There are watchdogs for each service and for systemd itself
- Services are started in parallel, reducing boot time
- The systemd service doesn’t use runlevels as SysV or Upstart do. The alternatives for systemd are called targets.
Systemctl
The systemctl command is used to interact with systemd and can be used to list systemd unit information and manage services.
1. List manageable services
List all service units with the command:
# systemctl list-units --type service
# systemctl list-units --type service
2. Start service on boot
It's alternative to upstart command chkconfig <service> on .
# systemctl enable crond.service
It's alternative to upstart command chkconfig <service> on .
# systemctl enable crond.service
2. Don't Start service on boot
It's alternative to upstart command chkconfig <service> off .
# systemctl disable crond.service
It's alternative to upstart command chkconfig <service> off .
# systemctl disable crond.service
Managing Targets(Runlevels)
| Runlevel | Target Units |
| 0 | poweroff.target |
| 1 | rescue.target |
| 2 | multi-user.target |
| 3 | multi-user.target |
| 4 | multi-user.target |
| 5 | graphical.target |
| 6 | reboot.target |
1. List Runlevels/Targets
List all target units with the command:
# systemctl list-units --type target --all
# systemctl list-units --type target --all
2. Print the default Target
# systemctl get-default3. Change Runlevels/TargetsChange the default target to ‘runlevel 3’:# systemctl set-default multi-user.targetSwitch to ‘runlevel 3’:# systemctl isolate multi-user.targetList all loaded service units :# systemctl list-units --type service --allList only the active service units :# systemctl list-unit-files --type serviceTo check whether a service is running (active) or not running (inactive) :# systemctl is-active sshd active# systemctl is-enabled sshd enabled