About
Thesystemd service runs onLinux to consolidate service configuration and application behavior: starting, stopping, and so forth.systemd is found inRed Hat Enterprise Linux as well as other Linux distributions.
Users and administrators query and controlsystemd behavior through thesystemctl command. This systemd Cheat Sheet presents the most common uses ofsystemctl, along withjournalctl for displaying information aboutsystemd activities from its logs.
Topics in this Cheat Sheet include:
Application management
- systemctl enable
- systemctl restart
- systemctl start
- systemctl status
- systemctl stop
Control over computers and virtual machines
- systemctl poweroff
- systemctl reboot
System information
- journalctl
- systemctl list-sockets
- systemctl list-units
- systemctl list-unit-files
Excerpt
Thesystemctl command in this example stops thehttpd service. This command can be useful if you have to stop a service in order to back up its data, because you think it is being attacked by a malicious intruder, or for any other reason. Thesystemctl statushttpd command that follows reports the status.
$ systemctl stop httpd$ systemctl status httpdhttpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: inactive (dead) since Mon 2022-01-24 09:56:53 PST; 3s ago Docs: man:httpd.service(8) Process: 1262 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=0/SUCCESS) Main PID: 1262 (code=exited, status=0/SUCCESS) Status: "Running, listening on: port 80"Jan 24 09:32:27 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...Jan 24 09:32:34 localhost.localdomain httpd[1262]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, usi>Jan 24 09:41:29 localhost.localdomain systemd[1]: Started The Apache HTTP Server.Jan 24 09:41:29 localhost.localdomain httpd[1262]: Server configured, listening on: port 80Jan 24 09:56:52 localhost.localdomain systemd[1]: Stopping The Apache HTTP Server...Jan 24 09:56:53 localhost.localdomain systemd[1]: httpd.service: Succeeded.Jan 24 09:56:53 localhost.localdomain systemd[1]: Stopped The Apache HTTP Server.
Note the following line in the status output, which shows that thehttpd service is inactive:
Active: inactive (dead) since Mon 2022-01-24 09:56:53 PST; 3s ago