Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
System V init, commonly referred to as SysVinit, is a traditional initialization system for Unix-like operating systems. It manages the system’s boot process and service control using a series of scripts executed in a specific order. Although largely replaced by systemd in modern Linux distributions, understanding SysVinit remains valuable for managing older systems or troubleshooting legacy environments.
SysVinit is a straightforward and reliable system initialization tool, ideal for legacy systems or environments with minimal requirements. Understanding its structure, runlevel concept, and service management is crucial for maintaining older Unix/Linux systems. As systemd becomes the standard, familiarity with both systems helps bridge the gap between legacy and modern environments.
For the history of System V and its evolution along with the history and evolution of other init systems, see the following article: An Introduction to Linux Init Systems and their evolution through time.
SysVinit uses runlevels to define system states and relies on scripts located in /etc/init.d and symbolic links in runlevel directories such as /etc/rc.d* for service management.
Runlevels represent different system states, each defining a specific set of services or tasks:
Check the current runlevel:
who -r
Change the runlevel:
init <runlevel>
Example:
init 3 # Switch to multi-user mode without GUI
Init scripts in /etc/init.d control services and follow a basic structure:
#!/bin/sh
### BEGIN INIT INFO
# Provides: my-service
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: My Custom Service
# Description: A longer description of my custom service.
### END INIT INFO
Symbolic links in the /etc/rc.d* directories control which services run at each runlevel:
Enable a service:
ln -s /etc/init.d/my-service /etc/rc3.d/S99my-service
Disable a service:
rm /etc/rc3.d/S99my-service
The service command simplifies interaction with init scripts.
Start, stop, and restart services:
sudo service <service> start # Start a service
sudo service <service> stop # Stop a service
sudo service <service> restart # Restart a service
Check service status:
sudo service <service> status
Example:
sudo service apache2 start
View boot logs:
dmesg
Check service logs:
cat /var/log/syslog
Manually start troubleshooting mode (single-user):
At the bootloader, add single
to the kernel parameters.
chmod +x /etc/init.d/my-service
Add symbolic links:
ln -s /etc/init.d/my-service /etc/rc3.d/S99my-service
ln -s /etc/init.d/my-service /etc/rc0.d/K01my-service
Test the script:
sudo service my-service start
For distributions supporting both systems, you can switch between them:
To use SysVinit:
sudo apt install sysvinit-core
Reboot the system.
To revert to systemd:
sudo apt install systemd
Reboot the system.
System V certainly left its mark in the history of Linux. You can read about that rich history following this link: The history and evolution of Linux distros, or more specifically, the history of Linux commands following this link: The history and evolution of Unix, GNU and Linux commands.