Password-protected single-user mode on RHEL/CentOS/5.x/6.x

Source: Internet
Author: User

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
  1. Cp/etc/inittab. backup

To protect the password in single-user mode, run the following command with root :-

  1. [Root @ tejas-barot-linux ~] # Sed-I '1i su: S: wait:/sbin/sulogin '/etc/inittab

In this way, you will see

  1. Su: S: wait:/sbin/sulogin
  2. # Default runlevel. The runlevels used by RHS are:
  3. #0-halt (Do NOT set initdefault to this)
  4. #1-Single user mode
  5. #2-Multiuser, without NFS (The same as 3, if you do not have networking)
  6. #3-Full multiuser mode
  7. #4-unused
  8. #5-X11
  9. #6-reboot (Do NOT set initdefault to this)
  10. #
  11. 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
  1. Cp/etc/sysconfig/init. backup
2.2 To protect the single-user mode with a password, run the following command with root :-
  1. [Root @ tejas-barot-linux ~] # Sed-I's/SINGLE =\/ sbin \/sushell/SINGLE =\/ sbin \/sulogin/'/etc/sysconfig/init

In this way, you will see

  1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.