Home > Article > Operation and Maintenance > 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:
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)
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.
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
, 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!