Skip to content

Instantly share code, notes, and snippets.

@JucaRei
Forked from unrooted/initSystemsCheatSheet.md
Created May 14, 2022 22:31
Show Gist options
  • Save JucaRei/b25cc3e22a8a8f23b6704297cf8052b2 to your computer and use it in GitHub Desktop.
Save JucaRei/b25cc3e22a8a8f23b6704297cf8052b2 to your computer and use it in GitHub Desktop.

Revisions

  1. @unrooted unrooted created this gist Dec 31, 2020.
    40 changes: 40 additions & 0 deletions initSystemsCheatSheet.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    # 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 :heart:

    > 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]`