Solution to Linux root Password loss

Source: Internet
Author: User

 

Event start:

Earlier in the year, some minor problems occurred while configuring Tomcat and java environment variables. Later, due to several misoperations, the machine was stuck there after a logout. Then, press the power key to force the shutdown. However, after you log on as an ordinary user after restarting, you will find that you cannot log on after you enter the correct password. Incorrect password prompt

 

My attempt:

Install the installation disc in the optical drive, restart it, and enter the shell in rescue mode. Since I use the Linux version of fedora 14, run the following command after entering the shell to obtain the root permission:

$ Chroot/mnt/sysimage

 

Run the following command in the vi Editor:

$ Vi/etc/profile

In the first line or the line of the word headed by your root, delete the string between the second colon and the third colon, and save and exit (Press Esc, press the colon, enter wq, press ENTER)

 

$ Passwd root # enter the password twice and prompt that the password is successfully modified.

 

After restarting, log on to the terminal with a common su command, but still cannot log on with the correct password.

 

The solution is as follows:

After you use the installation disc to enter the shell, use the method mentioned above to obtain the root permission, add a user, and modify the line starting with the new username in the/etc/profile file, the two parameters used to identify a user group are changed to the same parameter (0: 0) as the root user, and the account super user permission is granted.

 

View passw and shadow permissions under/etc.

$ Ls-l/etc/{passwd, shadow}

-Rw ------- 1 root 2434 03-05 19:52/etc/passwd

-Rw ------- 1 root 1700 03-06/etc/shadow

Common users are not allowed to read passwd files. Then modify the passwd permission:

$ Chmod 644/etc/passwd

 

Error cause:

Yes, the/bin/su file is canceled with the s bit, so the solution is chmod a + s/bin/su.

# Ls-l/bin/su

-Rwxr-xr-x 1 root 39948 03-05 14:38/bin/su

# Chmod a + s/bin/su

# Ls-l/bin/su

-Rwsr-sr-x 1 root 39948 03-05 14:38/bin/su

 

Log on to the root again to solve the problem.

This article is from the "Michael_Feng" blog

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.