openrc
Manage system services during boot and runtime
TLDR
Change to a specific runlevel
Change to a specific runlevel, but don't stop any existing services
SYNOPSIS
For the purpose of illustrating interaction with the OpenRC system, the rc-service
command is often used to manage individual services.rc-service <service> [<command> [<arguments>]]
rc-service --ifneeded <service> [<command> [<arguments>]]
rc-service --exists <service>
rc-service --resolve <service>
rc-service --dependencies <service>
rc-service --status-all
PARAMETERS
--ifneeded
Conditionally runs the command only if the service is not already running.--exists
Checks if the specified service script exists.--resolve
Resolves the full path to the service script.--dependencies
Lists all services that the specified service depends on.--status-all
Shows the status of all services.
<service>
The name of the service to manage (e.g., nginx
, sshd
).
<command>
The action to perform on the service. Common commands include:
start: Starts the service.
stop: Stops the service.
restart: Restarts the service.
reload: Reloads the service's configuration.
status: Displays the current status of the service.
zap: Clears the PID file and ensures the service is not running.
crashed: Checks if the service has crashed.
configcheck: Checks the service's configuration.
<arguments>
Additional arguments passed to the service script's command.
DESCRIPTION
OpenRC is a dependency-based init system for Unix-like operating systems. It is designed to be highly configurable, modular, and lightweight, providing a fast and efficient way to manage system services during boot-up and runtime. Unlike monolithic init systems, OpenRC uses a structured approach where service scripts are simple shell scripts that define dependencies, allowing services to start and stop in the correct order.
While "openrc" refers to the entire init system, direct user interaction often involves specific commands prefixed with rc-
, such as rc-service
for managing individual services, rc-status
for viewing system runlevels and service states, and rc-update
for adding or removing services from runlevels. It is a popular choice for distributions that prioritize simplicity and control, like Gentoo and Alpine Linux.
CAVEATS
The name "openrc" refers to the entire init system, not a standalone executable command in the traditional sense like ls
or grep
. Interaction with the OpenRC system primarily occurs through a suite of rc-
prefixed commands, such as rc-service
, rc-status
, rc-update
, and rc-config
. Therefore, direct openrc
command usage as depicted in some command-line tools is atypical; instead, specific rc-*
utilities are used to manage services and system state.
RUNLEVELS
OpenRC organizes services into runlevels, which define sets of services to be started or stopped for specific system states (e.g., default
, boot
, sysinit
, shutdown
). Users can switch between runlevels to change the system's operational mode.
SERVICE SCRIPTS
OpenRC service scripts are typically found in /etc/init.d/
and are simple shell scripts that define start, stop, and status functions, along with metadata for dependencies and runlevels. This design promotes transparency and ease of customization.
DYNAMIC DEPENDENCIES
OpenRC supports dynamic dependency resolution, meaning services can be started based on the presence of required resources (like network interfaces) rather than fixed ordering. This contributes to faster and more robust boot processes.
HISTORY
OpenRC was created by Roy Marples, initially for the NetBSD operating system, and later adopted by Gentoo Linux as its default init system in 2007, replacing its traditional System V init scripts. Its design principles emphasize simplicity, POSIX compliance, and avoiding bloat, making it a popular alternative to systemd, especially in distributions like Alpine Linux, which values a small footprint and fast boot times. Development has continued with a focus on stability, performance, and flexibility in managing system services and dependencies.