Friday, December 1, 2017

Changing Default Runlevel in Centos/RHEL 6 & 7

Changing Default Runlevel in Centos/RHEL 6 & 7

Hello Linux-Fanatics, in this post we will be process for changing default runlevel in Centos\RHEL 6 & 7 . But before we do that, we must discuss following…

What is a runlevel ?

Runlevel is the preset state in which a Linux system operates. Below mentioned are the different runlevels of a Linux system in which a linux system can be operated
  • 0-  halt or shutdown
  • 1- single user mode
  • 2- multi user mode without NFS
  • 3- full multi-user mode
  • 4- not used
  • 5- graphical mode
  • 6- reboot
Now, lets learn how to change the default runlevel.

Centos/RHEL 6

Changing default runlevel in Centos/RHEL 6 is very easy task & requires a change in single file.
Firstly, open file /etc/inittab
vim /etc/inittab
and you will get something like id:5:initdefault: in the file, where 5 is the default runlevel.
You must change 5 to desired runlevel, which in this case is 3 (multi-user mode). After making changes to file, save it to change the default runlevel on boot.
id:3:initdefault:
Note:- You must never use 0 (halt) as default runlevel.

Centos/RHEL 7

Changing runlevel in Centos/RHEL 7 is bit tricky as /etc/inittab is no more used by systemd to change the run levels. Also, runlevels are also defined differently in Centos/RHEL 7.
Firstly let’s check all the available runlevels, to do so run the following command
systemctl list-units –type=target
and output should be like ,
Default runlevel
so, these are all the runlvels available in Centos/RHEL 7.
Now if you want to change default runlevel to 3 which is ‘multi-user.target’, run following command,
systemctl set-default multi-user.target
and that’s it, your runlevel is changed. You can verify if the runlevel is changed by running following comamnd
systemctl get-default
So, that concludes our tutorial on changing default runlevel, i hope it was easy & descriptive enough to be followed. 

No comments: