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 ,
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. There are many other tips & tricks tutorial HERE, please look through.
Also, if you have any queries or questions, mention them in the comment box below & I will surely get back to you.
If you think we have helped you or just want to support us, please consider these :-
Connect to us: Facebook | Twitter | Google Plus
Donate us some of you hard earned money: [paypal-donation]
Linux TechLab is thankful for your continued support.
So could you describe to me what would happen if I changed my default runlevel to 6? Would my system continuously reboot?
Thanks in advance!
Thanks exactly what will happen.
“systemctl set-default multi-user.target” command makes error message like ‘Failed to set default target: Cannot send after transport endpoint shutdown’. How can I fix it?
Is there a runlevel in RHEL7 that corresponds the the user-definable runlevel 4 in RHEL6?
Yes it same as RHEL 6, commands are bit different,
# systemctl get-default
to get the default runlevel.
Is there a user-definable runlevel in RHEL7, as there is in RHEL6 (runlevel 4)?
Yes it same as RHEL 6, commands are bit different,
# systemctl get-default
to get the default runlevel.