Password-protected single-user mode on RHEL/CentOS/5.x/6.x
Hello everyone, if you have not used a password to protect the single-user mode, this poses a great risk to your Linux server. Therefore, when it comes to security, it is very important to use a password to protect the single-user mode.
This article will show you how to use a password to protect your single-user mode on RHEL/CentOS 5.x and RHEL/CentOS 6. x.
Please execute the given command carefully, otherwise your system will not be able to start normally. First, I will ask you to finish reading and then try. Please bear the relevant consequences by yourself :-)
Password Protect
1. Before starting RHEL/CentOS 5. x1.1, back up your/etc/inittab
- Cp/etc/inittab. backup
To protect the password in single-user mode, run the following command with root :-
- [Root @ tejas-barot-linux ~] # Sed-I '1i su: S: wait:/sbin/sulogin '/etc/inittab
In this way, you will see
- Su: 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:
NOTE: If you do not want to use the sed command, you can add "su: S: wait:/sbin/sulogin" to the top of the/etc/inittab"
2. Before starting RHEL/CentOS 6. x2.1, back up your/etc/inittab
- Cp/etc/sysconfig/init. backup
2.2 To protect the single-user mode with a password, run the following command with root :-
- [Root @ tejas-barot-linux ~] # Sed-I's/SINGLE =\/ sbin \/sushell/SINGLE =\/ sbin \/sulogin/'/etc/sysconfig/init
In this way, you will see
- SINGLE =/sbin/sulogin
Note:-If you do not want to use sed, you can directly change it to "SINGLE =/sbin/sysconfig/init" in/etc/sysconfig/init"
Enjoy Linux :) Enjoy open source