systemd Commands cheat sheet cover image

systemd Commands Cheat Sheet

Bob Reselman

Tags:

English

About

The systemd service runs on Linux to consolidate service configuration and application behavior: starting, stopping, and so forth. systemd is found in Red Hat Enterprise Linux as well as other Linux distributions.

Users and administrators query and control systemd behavior through the systemctl command. This systemd Cheat Sheet presents the most common uses of systemctl, along with journalctl for displaying information about systemd 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

The systemctl command in this example stops the httpd 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. The systemctl status httpd command that follows reports the status.

$ systemctl stop httpd

$ systemctl status httpd

httpd.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 80

Jan 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 the httpd service is inactive:

Active: inactive (dead) since Mon 2022-01-24 09:56:53 PST; 3s ago

Related Cheat sheets