2014-02-25 10:06:23 +08:00
|
|
|
# systemctl
|
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
> Control the systemd system and service manager.
|
2020-09-01 22:31:47 +08:00
|
|
|
> More information: <https://www.freedesktop.org/software/systemd/man/systemctl.html>.
|
2014-02-25 10:06:23 +08:00
|
|
|
|
2021-10-08 22:00:29 -04:00
|
|
|
- Show all running services:
|
|
|
|
|
|
|
|
`systemctl status`
|
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
- List failed units:
|
2014-02-25 10:06:23 +08:00
|
|
|
|
|
|
|
`systemctl --failed`
|
|
|
|
|
2024-05-10 15:04:49 +07:00
|
|
|
- Start/Stop/Restart/Reload/Show the status a service:
|
2014-02-25 10:06:23 +08:00
|
|
|
|
2024-05-10 15:04:49 +07:00
|
|
|
`systemctl {{start|stop|restart|reload|status}} {{unit}}`
|
2014-02-25 10:06:23 +08:00
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
- Enable/Disable a unit to be started on bootup:
|
2014-02-25 10:06:23 +08:00
|
|
|
|
2021-02-19 07:13:45 -03:00
|
|
|
`systemctl {{enable|disable}} {{unit}}`
|
2014-02-25 10:06:23 +08:00
|
|
|
|
2024-05-10 15:04:49 +07:00
|
|
|
- Reload systemd, scan for new or changed units:
|
|
|
|
|
|
|
|
`systemctl daemon-reload`
|
2016-04-10 06:36:11 +08:00
|
|
|
|
2024-05-10 15:04:49 +07:00
|
|
|
- Check if a unit is active/enabled/failed:
|
2016-04-10 06:36:11 +08:00
|
|
|
|
2024-05-10 15:04:49 +07:00
|
|
|
`systemctl {{is-active|is-enabled|is-failed}} {{unit}}`
|
2014-02-25 10:06:23 +08:00
|
|
|
|
2024-05-10 15:04:49 +07:00
|
|
|
- List all service/socket/automount units filtering by running/failed state:
|
|
|
|
|
2025-03-13 04:41:47 +02:00
|
|
|
`systemctl list-units {{[-t|--type]}} {{service|socket|automount}} --state {{failed|running}}`
|
2020-09-01 22:31:47 +08:00
|
|
|
|
2024-05-10 15:04:49 +07:00
|
|
|
- Show the contents & absolute path of a unit file:
|
2020-09-01 22:31:47 +08:00
|
|
|
|
2024-05-10 15:04:49 +07:00
|
|
|
`systemctl cat {{unit}}`
|