In this post you will learn about runlevels and how to configure runlevels in linux .
RUNLEVELS are the mode of operation in the computer operating system that defines the state of system after boot .
To view the runlevels of your linux system open the /etc/inittab through vim .
[root@dhcppc6 ~]# vim /etc/inittab
- You will see here seven different types of runlevels . Default runlevel is set to 5 (graphical mode ) .
# inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, <firstname.lastname@example.org> # Modified for RHS Linux by Marc Ewing and Donnie Barnes # # Default runlevel. The runlevels used by RHS are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:5:initdefault: # System initialization. si::sysinit:/etc/rc.d/rc.sysinit l0:0:wait:/etc/rc.d/rc 0 l1:1:wait:/etc/rc.d/rc 1 l2:2:wait:/etc/rc.d/rc 2 l3:3:wait:/etc/rc.d/rc 3 l4:4:wait:/etc/rc.d/rc 4 l5:5:wait:/etc/rc.d/rc 5 l6:6:wait:/etc/rc.d/rc 6 # Trap CTRL-ALT-DELETE ca::ctrlaltdel:/sbin/shutdown -t3 -r now # When our UPS tells us power has failed, assume we have a few minutes # of power left. Schedule a shutdown for 2 minutes from now. # This does, of course, assume you have powerd installed and your # UPS connected and working correctly.
Before we make any changes i suggest you to backup the runlevel file . Means if you make anything wrong in this file your system might not work properly .
[root@dhcppc6 ~]# cp /etc/inittab /etc/inittab.bak
- To recover copy that backup file into main file .
[root@dhcppc6 ~]# cp /etc/inittab.bak /etc/inittab
THESE ARE THE SEVEN RUNLEVELS IN LINUX
|0||Halt||System won’t be able to start . Pc will shutdown after boot .|
|1||Single-user mode||This is basically administration mode|
|2||Multi-user mode||Its a command line mode where multi user can login .But does not configure network interfaces|
|3||Multi-user mode with networking||Command line with network interface .|
|4||Not used/user-definable||This ones is empty for special purpose .|
|5||Start the system normally with appropriate display manager (with GUI)||In this user can work in both graphical and command line mode .|
|6||Reboot||This reboots system again and again|
HOW TO CHANGE RUNLEVELS IN GRUB
- First restart your system .
- When this screen appears ( BOOTING LINUX )press up and down arrow key .
- Now you are in Grub settings . Press e to edit before booting .
- Now go to Kernel and press ” e ” to edit this kernel .
- Now you will see this type of screen . Hit spacebar and enter numeric 1 .
- Then Boot the kernel by pressing “ b ” . We have entered ” 1 ” because we want to enter single user mode in linux .
- Now we are in single user mode .
- Now open runlevel file ( /etc/fstab ) through vim
- Some users have problem in their system that reboots again and again because their id is 6 ( runlevel 6 ) . Just press ” I ” ( to enter the Insert mode ) . And in place of 6 , make id 5 ( runlevel 5 ) .Then press ESC and type : wq ( to save and quit )
- IF you are using command line mode and want graphical mode in your system Change id to 5 . In place of 3 write 5 .
- And if you want only command line mode , just write 3 in place of 5 . ID will be 3 .
- Press Esc and type :wq ( to save and quit ) .
- Then simply type reboot ( to reboot the machine .)