🌻Infrastructure And OperationsSystemd Openrc Cheatsheet

I'm creating a this page because of how frustrated I am with the OpenRC init system.

We use Alpine for a lot of stuff so it's important to know how to use OpenRC init.


systemd command

openrc command

list all services

systemctl or systemctl | cat (no pager)

rc-status --servicelist

list enabled services

systemctl list-unit-files | grep enabled


enable a service

systemctl enable <servicename>

rc-update add <servicename>

disable a service

systemctl disable <servicename>

rc-update del <servicename>

start a service

systemctl start <servicename>

service <servicename> start

stop a service

systemctl stop <servicename>

service <servicename> stop

stop a service in such a way that it won't start itself up again without asking

systemctl disable --now <servicename>

service <servicename> stop

get service status

systemctl status <servicename>

service <servicename> status (do not always trust this. search the process list as well)

reset crashed service

??? systemd is perfect, it never crashes 😇

service <servicename> zap

where is a service's configuration file at?

usually /etc/systemd/system/<servicename>.service. it's listed after Loaded: in the output of systemctl status <servicename>


how to make service configuration file changes take effect

systemctl daemon-reload

no action required

how to view the logs for a service

journalctl -u <servicename> -n 100 --no-pager (gets last 100 lines)

check inside the service configuration file (see above). it should have output_log=<filepath> and error_log=<filepath>

how to configure environment variables for a service?

you can use the Environment="var=value" in the service configuration file

/etc/default/<servicename> is the file. Add one var=value per line