LinuxCommandLibrary

rc-update

Manage services at system startup (runlevels)

TLDR

List enabled services and the runlevels they are added to

$ rc-update
copy

List all services
$ rc-update [[-v|--verbose]]
copy

Add a service to a runlevel
$ sudo rc-update add [service_name] [runlevel]
copy

Delete a service from a runlevel
$ sudo rc-update [[del|delete]] [service_name] [runlevel]
copy

Delete a service from all runlevels
$ sudo rc-update [[-a|--all]] [[del|delete]] [service_name]
copy

SYNOPSIS

rc-update command [options] [arguments]
rc-update {add | del} service [runlevel ...]
rc-update show [-v | --verbose]

PARAMETERS

add service [runlevel ...]
    Adds the specified service to one or more runlevels. If no runlevel is specified, the service is typically added to the 'default' runlevel.

del service [runlevel ...]
    Removes the specified service from one or more runlevels. If no runlevel is specified, the service is removed from all runlevels it is currently in.

show
    Displays the current status of all services, indicating which runlevels they are enabled in. This is useful for auditing the system's startup configuration.

-v, --verbose
    Used exclusively with the 'show' command, this option provides a more detailed output, showing all services and their respective runlevel statuses in a more expanded format.

-h, --help
    Displays a brief help message with command usage information and then exits.

service
    The name of the service script (e.g., 'sshd', 'cron', 'netmount') located in the /etc/init.d/ directory.

runlevel
    The name of an OpenRC runlevel (e.g., 'default', 'boot', 'sysinit', 'shutdown', 'nonetwork'). Services are enabled or disabled within these specific system states.

DESCRIPTION

rc-update is a crucial command within the OpenRC init system, primarily used on Gentoo Linux and other distributions that utilize OpenRC instead of systemd or SysVinit. Its main purpose is to manage which services are started or stopped automatically when the system enters specific runlevels.

The command allows system administrators to add or remove service scripts from various runlevels by creating or deleting symbolic links in the /etc/runlevels/ directory structure. This ensures that services are properly initialized or terminated according to the system's operational state. For instance, services added to the 'default' runlevel will start automatically when the system boots into its normal operating mode, while 'boot' runlevel services are fundamental for the initial system setup.

Essentially, rc-update provides a streamlined interface for configuring system-wide service startup behavior without manually manipulating symbolic links, making system maintenance more efficient and less error-prone. It serves as OpenRC's equivalent to update-rc.d in SysVinit or systemctl enable/disable in systemd for managing service boot-time behavior.

CAVEATS

The rc-update command is specific to systems using the OpenRC init system. It will not be present or functional on systems running systemd (e.g., most modern Fedora, Ubuntu, Debian) or traditional SysVinit (e.g., older Debian, CentOS 6). Changes made by rc-update are persistent across reboots but may not take immediate effect. For changes to apply without a reboot, the affected service must be manually started or stopped using the rc-service command.

OPENRC RUNLEVELS

In OpenRC, runlevels define distinct system states, each associated with a specific set of services that should be running. Common runlevels include:

  • boot: Contains services essential for the initial system bring-up, such as mounting the root filesystem.
  • sysinit: Services required after 'boot' but before 'default', often including filesystem checks and basic network configuration.
  • default: The standard operating state, containing services for normal system operation (e.g., SSH, web server, database). This is the typical target for normal boots.
  • shutdown: Services designed to be stopped gracefully during system shutdown.
  • nonetwork: A variation of 'default' where network services are explicitly disabled, useful for troubleshooting.

rc-update manages the symbolic links within /etc/runlevels/ directories, where each subdirectory corresponds to a runlevel and contains links to the service scripts in /etc/init.d/ that should be active in that runlevel.

HISTORY

rc-update is an integral component of the OpenRC init system, which originated from Gentoo Linux in the early 2000s as a more flexible and dependency-aware alternative to the traditional SysVinit. Its development aimed to simplify the process of managing service startup and shutdown across different runlevels, moving away from the manual manipulation of symbolic links that was common with SysVinit. The command provides a higher-level abstraction for configuring service integration into runlevels, reflecting OpenRC's focus on modularity, robust dependency tracking, and faster boot times through parallel service startup.

SEE ALSO

rc-service(8), rc-status(8), openrc(8), runlevels(7), init(8), update-rc.d(8), systemctl(1)

Copied to clipboard