Home  >  Article  >  Operation and Maintenance  >  Unable to log in after using the useradd command to add a user in Linux

Unable to log in after using the useradd command to add a user in Linux

王林
王林Original
2019-12-07 15:37:525976browse

Unable to log in after using the useradd command to add a user in Linux

When using useradd to add a user, the -p parameter sets the password, and then the password cannot be used to log in. Problem:

Unable to log in after using the useradd command to add a user in Linux

As you can see from the above picture, I created a new user luo, with the password set to 123456. First, the root user is switched to an ordinary user, and then switched to luo (because the root user has the highest authority and does not need a password to switch to other users)

Unable to log in after using the useradd command to add a user in Linux

You can see that the password is wrong and you cannot switch to it.

Free video tutorial sharing: linux video tutorial

Solution:

Use the [passwd username] command to change the user password. This will allow you to log in directly.

Unable to log in after using the useradd command to add a user in Linux

In this way, you can log in with the password you set.

Cause analysis:

After you use the useradd command to create a new user and set a password for him, enter the command: cat /etc/shadow View When all user information is

Unable to log in after using the useradd command to add a user in Linux

, you will find that the passwords of my luomeng user and mike user are encrypted. The password of the newly added user is not encrypted, and the original password is displayed directly.

There will definitely be problems in parsing the password when logging in.

It turns out that when you use useradd to add a new user, the [-p] parameter cannot directly use the password you want. Instead, you should add the original password encrypted in single quotes. Password, so that you can log in directly with your original password when logging in. Of course this method is not very practical.

Recommended related articles and tutorials: linux tutorial

The above is the detailed content of Unable to log in after using the useradd command to add a user in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn