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!
About the Authors
Each member of Anto's editorial team is a Cloud expert in their own right. Anto Online takes great pride in helping fellow Cloud enthusiasts. Let us know if you have an excellent idea for the next topic!
Support the Cause
Support Anto Online and buy us a coffee. Anything is possible with coffee and code.