What is a Run-Level?
“Runlevel” defines the state of the machine after boot. Different runlevels are typically assigned to:
- single-user mode
- multi-user mode without network services started
- multi-user mode with network services started
- system shutdown
- system reboot
The exact setup of these configurations will vary from OS to OS, and from one Linux distribution to another. As a result, the information listed below is for Redhat Linux. Below are the different Redhat levels:
- 0 is Halt
- Immediately shuts down system and powers it off, if it can.
- 1 is Single user
- Brings system to a bare essentials mode for maintenance
- 2 & 4 is User-defined or custom
- 5 is Multi-user with display and console
- All services are running including X11 (or GUI)
- 6 is Reboot
You might be able to tell what runlevels are used with you Linux distribution by entering the following command:
cat /etc/inittab
Then look for the section that has a description similar to “Default runlevel. The runlevels used by…”
How do you tell what runlevel you’re currently running? Good question, here’s the command:
who -r
The result lets us know that we are currently at level 3 and previously running level 5. How do we change the current level? Wow, I’m overwhelmed by the excellent questions for this post ;). Here’s the command:
init 3
This command will change the run level to 3. However, on reboot it will go back to the default level which is usually runlevel 5 for Redhat. To make it permanent run the following commands:
su -c ‘vi /etc/inittab’
Now scroll down to the line that has “id:5:initdefault:” (image below) and enter “o” This will open a new line and enter edit mode. Change the 5 to the runlevel your configuring. In this case it would be 3. Hit the “ESC” key on your keyboard to exit edit mode. Then enter the following CMD “:x”. This command saves and exits vi.
Note: Run-Level 1 stops all services. As a result, you may need network connectivity. Below is the command to start the network services:
service network start; service nfs start
References: