Skip to content

This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!


init systems

An init system is the first program, other than the kernel, to be run after a Linux distribution is booted. It is a daemon process that continues running until the system is shut down. Init is the direct or indirect ancestor of all other processes, and automatically adopts all orphaned processes. It is started by the kernel using a hard-coded filename; if the kernel is unable to start it, panic will result. Init is typically assigned PID 1.

Reference(s)

Table of contents


rc

rc is an ancient abbreviation that stands for "run commands". It refers to a script (or a set of scripts) containing "startup instructions for an application program (or an entire operating system)". It would seem rc was the basis for modern init systems.


A lot of init systems are available. Here are maybe the four most popular:


Quick equivalents

  • Start the service_name service:
# rc-service service_name start

# sv start service_name
or
# sv up service_name

# service service_name start
# systemctl start service_name
  • Stop the service_name service:
# rc-service service_name stop

# sv stop service_name
or
# sv down service_name

# service service_name stop
# systemctl stop service_name
  • Restart the service_name service:
# rc-service service_name restart
# sv restart service_name
# service service_name restart
# systemctl restart service_name
  • Reload the service_name service:
# rc-service service_name reload
# sv reload service_name
# service service_name reload
# systemctl reload service_name
  • Check the service_name service status:
# rc-service service_name status
# sv status service_name
# service service_name status
# systemctl status service_name
  • Enable the service_name service on system boot:
# rc-update add service_name

Depending on your runit implementation, either run:

# ln -s /etc/runit/sv/service_name /service
or
# ln -s /etc/runit/sv/service_name /var/service
or
# ln -s /etc/runit/sv/service_name /run/runit/service

# chkconfig service_name on
# systemctl enable service_name
  • Disable the service_name service on system boot:
# rc-update del service_name

Depending on your runit implementation, either run:

# unlink /service/service_name
or
# unlink /var/service/service_name
or
# unlink /run/runit/service/service_name

# chkconfig service_name off
# systemctl disable service_name
  • Check if the service_name service is enable or disable on system boot:
# rc-update -v | grep service_name
# service="service_name" && if [ -d /run/runit/service/"$service" ] && [ ! -f /run/runit/service/"$service"/down ]; then echo "$service is enable on boot"; else echo "$service is disable on boot"; fi
# chkconfig service_name
# systemctl is-enabled service_name

System commands

TODO/TO CHECK

  • Halt the system:
# halt
# halt
# halt
# systemctl halt
  • Power off the system:
# poweroff
# poweroff
# poweroff
# systemctl poweroff
  • Reboot the system:
# reboot
# reboot
# reboot
# systemctl reboot
  • Suspend the system: TODO

  • Hibernate the system: TODO

  • Print system logs: TODO


If this cheat sheet has been useful to you, then please consider leaving a star here.