Solved: cannot lock /etc/passwd; try again later

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 Anto Online

Anto, a seasoned technologist with over two decades of experience, has traversed the tech landscape from Desktop Support Engineer to enterprise application consultant, specializing in AWS serverless technologies. He guides clients in leveraging serverless solutions while passionately exploring cutting-edge cloud concepts beyond his daily work. Anto's dedication to continuous learning, experimentation, and collaboration makes him a true inspiration, igniting others' interest in the transformative power of cloud computing.

View all posts by Anto Online

One Comment on “Solved: cannot lock /etc/passwd; try again later”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.