The systemd system and service manager are responsible for controlling how services are started, stopped and otherwise managed on Red Hat Enterprise Linux 7 systems. By offering on-demand service start-up and better transactional dependency controls, systemd dramatically reduces startup times. As a systemd user, you can prioritize critical services over less important services.
Although the systemd process replaces the init process (quite literally, /sbin/init is now a symbolic link to /usr/lib/systemd/systemd) for starting services at boot time and changing runlevels, systemd provides much more control than the init process does while still supporting existing init scripts. Here are some of the most commanly used systemd command examples:
View systemd information
Command | Description |
---|---|
systemctl list-dependencies | show a unit’s dependecies |
systemctl list-sockets | list the sockets |
systemctl list-jobs | View active systemd jobs |
systemctl list-unit-files | See unit files and their states |
systemctl list-units | Show if units are loaded/active |
systemctl get-default | List default target (like run level) |
Working with services
Command | Description |
---|---|
systemctl stop service | Stop a running service |
systemctl start service | Start a service |
systemctl restart service | Restart a running service |
systemctl reload service | Reload all config files in service |
systemctl daemon-reload | Must run to reload changed unit files |
systemctl –failed | Shows services that failed to run |
systemctl reset-failed | Resets any units from failed state |
systemctl status service | See if service is running/enabled |
systemctl enable service | Enable a service to start on boot |
systemctl disable service | Disable service–won’t start at boot |
systemctl show service | Show properties of a service (or other units) |
systemctl edit service | Create snippit to drop in unit file |
systemctl edit –full service | Edit entire unit file for service |
systemctl -H host status network | Run any systemctl command remotely |
Changing system states
Command | Description |
---|---|
systemctl reboot | Reboot the system (reboot.target) |
systemctl poweroff | Power off the system (poweroff.target) |
systemctl emergency | Put in emergency mode (emergency.target) |
systemctl default | Back to default target (multi-user.target) |
Viewing log messages
Command | Description |
---|---|
journalctl | Show all collected log messages |
journalctl -u network.service | See network service messages |
journalctl -f | Follow messages as they appear |
journalctl -k | Show only kernel messages |