
Can’t add a user in Linux because of this: ‘useradd: cannot lock /etc/passwd; try again later.’ ? Here’s what to check!
$ sudo useradd -m -g users -s /bin/bash jsmith useradd: cannot lock /etc/passwd; try again later.
If you receive this message even when running with sudo, there are small lock files that are causing this.
Remove any files called
/etc/passwd.lock /etc/group.lock /etc/gshadow.lock /etc/shadow.lock
Careful to not remove the actual passwd or shadow files(!).
This error can also occur if the filesystem was mounted read-only. Check to be sure the file system is mounted read write.