Set password for RStudio Server with AWS EC2 instance

Hello all,

I managed to follow all the steps to create EC2 instance and install R Server on it.

When I go to RStudio Server page to connect (which looks something like "ec2-[Public IP]"), I am asked a username and a password.

I figured out to set a username ("user1") this way:

$ sudo useradd user1
But then when I try this command to write the password:

echo user1:password | chpasswd
I receive this message: chpasswd: cannot lock /etc/passwd; try again later.

I looked at different solutions suggested here:

but I do not see a resolution to my problem.

I did not find either any passwd.lock, shadow.lock, group.lock, gshadow.lock files to remove.