Understanding SysV

The systemd is backward compatible with SysV init. If the system has /etc/inittab file, it uses SysV init.

The SystemV init (SysV init) is using runlevels to define the state of servers should be booting in. These runlevels identify which services are loaded at which runlevel. For example, at runlevel 1 (rescue mode) only essential services are loaded for administration, at runlevel 3, essential services with networking services are loaded, at runlevel 5, graphical environment is loaded. However, some distributions use different runlevels for different services.

Red-Hat-based SysV init runlevels

RunlevelRed Hat-based distribution runlevelsDebian-based distribution runlevels
0Shut down the systemShut down the system
1, s, or SSingle-user mode (maintenance)Single-user mode (maintenance)
2Multi-user mode without networking services enabledMulti-user mode with GUI
3Multi-user mode with networking services enabledN/A
4CustomN/A
5Multi-user mode with GUIN/A
6Reboot the systemReboot the system

To see current runlevel on the system:

# runlevel
N 5

Instead using default target (default.target) like systemd, SysV init uses configuration file – /etc/inittab. Let’s see what it holds:

# grep :initdefault: /etc/inittab
id:5:initdefault:

The “initdefault” keyword specifies the runlevel to enter after the system boots.

  • Each script must have initialization script located in /etc/init.d/ directory.
  • Each of these scripts contains shell code responsible for starting, stopping, restarting, reloading a service.
  • Now, program that starts these scripts is called rc script and it lives in /etc/init.d/ or in /etc/rc.d/ directory.
  • The rc script, runs all scripts within one of these directories. T
  • he directory used depends on the runlevel.
  • Each runlevel has its own subdirectory in /etc/rc.d/ like rc0.d, rc1.d, rc2.d…
  • Inside each of these are service scripts that start with K or S in their name. K stands for kill, S stands for start.
  • The number indicates order in which script will be run.
  • All scripts in /etc/rc.d/rcX.d/ are symbolic links to scripts in /etc/init.d/ directory.

Managing SysV services

To view a SysV init service’s status and control its behaviour use service utility.

service SCRIPT COMMAND [OPTIONS]

the SCRIPT here refers to a particular script in /etc/init.d/ directory. The service scripts typically have names same as the service. The COMMAND are explained in table below.

restartStop and restart specified service
startStart specified service
statusShow service status
–status-allShow all services’ status
stopStop the specified service
reloadLoad the service configuration file. It makes service changes without stopping it.

Leave a Reply