How to set password for Single-User mode on Linux (CentOS/RHEL)
What is Single-User mode on Linux? That is a mode help you restore some config or operation on OS Linux like reset password root when you forgot it,… However, if you don’t try to protect this mode, your system will have a exploited vulnerability so you need to set password for Single-user mode.
(single-user grub mode, before prompt pass single-mode appear phase)
Note:
– When you set password for single-user mode on Linux, you have to remember or note your password of root for future login in single-user mode. If you forgot it, you will have to use DVD Linux recuse to reset root password.
Step-by-step to set password for Single-user mode on
First of all, you need to config file ‘/etc/inittab’:
# vi /etc/inittab ~~:S:wait:/sbin/sulogin
You have to insert config line “~~:S:wait:/sbin/sulogin” before config line ‘initdefault‘. So now the content of config file ‘/etc/inittab‘ will be like below:
# Password requires for single user mode. ~~:S:wait:/sbin/sulogin # 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:3:initdefault:
The last step, that you have to change config in file ‘/etc/sysconfig/init‘ :
# vi /etc/sysconfig/init SINGLE=/sbin/sushell
change to
SINGLE=/sbin/sulogin
Finally, you can reboot OS and try to boot to single-user mode and check that a prompt password appears or not. So now you have completed the way to set password for Single-user mode on Linux. Good luck !