Linux Add user adduser appears Useradd:cannot lock/etc/passwd; Try again

Source: Internet
Author: User

Look for a file called/etc/passwd.lock, find, to it with root delete it, it may be the last use of this file did not close properly.
Specific operation:
Switch to root user, use CD etc to the ETC directory, RM. Pwd.lock, (note. Pwd.lock This name may not be the same, you can go to the ETC directory to see)


Next look at how to create a new login account with the root account

How to create a new user under Linux under normal circumstances, in the security considerations, generally give themselves to create a normal user, instead of directly using the root user, because the permissions are large, wrong operation will easily lead to irreparable loss. In a Linux system, only the root user has permission to create other users.
The creation process is as follows:
useradd-d/home/newuser NewUser

This method sets the user's home directory and user name
But the light is not enough, but also for the user to explicitly set the password (even the second method is no exception, because this time using love as a password to log on to the system, still unable to log in), the command for passwd username;
[Email protected] ~]# passwd hudamin
Changing password for user hudamin.
New UNIX Password:
Bad password:it are too short
Retype new UNIX Password:
Passwd:all authentication tokens updated successfully.

When the system is logged in, it will prompt the user home directory is not created, so there is a lack of a step, that is, for the corresponding user to create a belong to the user's home directory, create a time to note that because the new user's home directory is created by root, but the Linux system requires the owner of the home directory must be the user itself , therefore, after you create the home directory with root, you need to replace the owner with the new user itself. The command is as follows:

Mkdir-p/home/newuser
Chown Newuser:newuser/home/newuser

Get! This can be used NewUser login ...

Linux Add user adduser appears useradd:cannot lock/etc/passwd; try again

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.