SysVinit is a system initialization program that runs when a Linux system boots up. It is responsible for starting and stopping various services and processes on the system. SysVinit uses a series of scripts called init scripts to control the behavior of different runlevels, which are modes of operation that define what services are available. SysVinit is one of the oldest and most widely used initialization systems for Linux, but it has some limitations and drawbacks, such as lack of parallelism, dependency management, and event handling.
In the table below, we’ve listed out the various runlevels (predefined sets of system states) you can find in SysVinit.
Runlevel | Description |
0 | Halt |
1 | Single-user mode |
2 | Multi-user mode without NFS |
3 | Full multi-user mode |
4 | Unused |
5 | X11 |
6 | Reboot |
For example:
- If you use a command line login screen, then you are in runlevel 3.
- If you use a graphical login screen, you are operating in runlevel 5.
To Determine the init level you’re in, use the command runlevel.
The default runlevel can be viewed and persistently changed by editing the /etc/inittab file. If a change is made to the file, ensure to update the system using the command telinit q.
- The /etc/initab file contains a line near the top of the file similar to the following, “id:5:initdefault:”. You can change the number in this line to enter the desired runlevel.
- You will have to reboot the system for the changes to take effect.
Alternatively you can set the runlevel to a value as a one-time change using the telinit command followed by the run level #, such as telinit 6, which will reboot the device as shown in the example below.