Skip to content

Instantly share code, notes, and snippets.

@unrooted
Created December 31, 2020 11:58
Show Gist options
  • Save unrooted/d70583fd4eceb3c818d65a83bf2c6acf to your computer and use it in GitHub Desktop.
Save unrooted/d70583fd4eceb3c818d65a83bf2c6acf to your computer and use it in GitHub Desktop.
init systems cheat sheet

Manage services in systemd, openRC and runit

systemd

  • list all services: systemctl list-unit-files
  • list running services status: systemctl list-units
  • list failed services: systemctl --failed
  • list available services: systemctl --all
  • start a service: systemctl start [SERVICE_NAME]
  • stop a service: systemctl stop [SERVICE_NAME]
  • restart a service: systemctl restart [SERVICE_NAME]
  • get the status of a service: systemctl status [SERVICE_NAME]
  • enable a service: systemctl enable [SERVICE_NAME]
  • disable a service: systemctl disable [SERVICE_NAME]

openRC

  • list services: rc-status
  • list failed services: rc-status --crashed
  • list available services: rc-update -v show or ls /etc/init.d/
  • start a service: rc-service [SERVICE_NAME] start or service [SERVICE_NAME] start or /etc/init.d/[SERVICE_NAME] start
  • stop a service: rc-service [SERVICE_NAME] stop or service [SERVICE_NAME] stop or /etc/init.d/[SERVICE_NAME] stop
  • restart a service: rc-service [SERVICE_NAME] restart or service [SERVICE_NAME] restart or /etc/init.d/[SERVICE_NAME] restart
  • get the status of a service: rc-service [SERVICE_NAME] status or service [SERVICE_NAME] status or /etc/init.d/[SERVICE_NAME] status
  • enable a service: rc-update add [SERVICE_NAME]
  • disable a service: rc-update del [SERVICE_NAME]

runit ❤️

note, if you're an Artix user, available services are in /etc/runit/sv directory and the enabled services are in /run/runit/service directory

  • list all available services: ls /etc/sv
  • list all enabled services: ls /var/service/
  • start a service: sv up [SERVICE_NAME] or sv u [SERVICE_NAME]
  • stop a service: sv down [SERVICE_NAME] or sv d [SERVICE_NAME]
  • restart a service: sv restart [SERVICE_NAME] or sv t [SERVICE_NAME]
  • get the status of a service: sv status [SERVICE_NAME] or sv s [SERVICE_NAME]
  • get the current status of all enabled services: sv status /var/service/*
  • enable a service: ln -s /etc/sv/[SERVICE_NAME] /var/service
  • disable a service: rm /var/service/[SERVICE_NAME]
@notKtquad
Copy link

Very nice, thank you

@artixnous
Copy link

Please, use standard UNIX man page syntax conventions. All mandatory parameters should be enclosed in angle brackets (<>) and optional ones in square brackets ([]). Example for OpenRC, where service is mandatory and runlevel optional (which defaults to, well, runlevel default):

  • enable service: rc-update add <service> [runlevel]

@Pound-Hash
Copy link

Pound-Hash commented Sep 6, 2023

I can't run any of the openRC commands beginning with service , e..g, service [SERVICE_NAME] start .

I'm on Gentoo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment