sudo useradd: cannot lock /etc/passwd; try again later (no lock files)
When doing this on Ubuntu server 14.04:
camilstaps@localhost:~$ sudo useradd --home-dir /var/www/xxx.camilstaps.nl/ --no-create-home --root /var/www/xxx.camilstaps.nl/ --shell /bin/sh xxx
I'm getting the error:
useradd: cannot lock /etc/passwd; try again later.
I checked and tried the following (found the suggestions all over the internet):
- Obviously, I'm using sudo
- There exists a file /etc/.pwd.lock, but it is empty and removing it doesn't help
- There are no other *.lock files in the /etc directory
- The filesystem is not full (14G available on /)
- Rebooting the server doesn't remove the lock.
I'm stumped. How can I unlock /etc/passwd?
df -ih
output
camilstaps@localhost:~$ df -ih
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/vda1 1,3M 228K 1,1M 18% /
none 125K 4 125K 1% /sys/fs/cgroup
udev 124K 404 123K 1% /dev
tmpfs 125K 386 124K 1% /run
none 125K 5 125K 1% /run/lock
none 125K 1 125K 1% /run/shm
none 125K 2 125K 1% /run/user
You can use adduser
instead of useradd
.
adduser
also provides an interactive session to configure your Linux user and also creates the necessary /home/username/
directory automatically.
sudo adduser <username>
By the way, there is no difference between adduser
and useradd
. They both serve the same purpose.