I encountered a “cannot lock /etc/passwd; try again later” issue whilst trying to create a new user on my Ubuntu 18.x server.
The root cause eludes me, but I did find that the following helped to resolve the issue.
Step 1 – Remount the file system
Remount the file system in read-write (rw) mode:
- sudo mount -o rw,remount /
Step 2 – Remove lock files
Under the /etc folder remove any of the following files: passwd, shadow, group and gshadow -.lock.
- sudo rm -rvf /etc/passwd.lock /etc/shadow.lock /etc/group.lock /etc/gshadow.lock
Now, lets go add that user!
tnx, you saved me