I am using Ubuntu 19.10
.I want add a system user with a home directory, and the user won't have any login access or password. I want to accomplish this by running useradd
without sudo
command.
I gave following permission to the main user using sudo visudo
:
main_user ALL=(root) NOPASSWD: \
/usr/sbin/useradd, /usr/bin/chmod, /usr/sbin/userdel, /usr/bin/setfacl, /usr/sbin/usermod
I have followed answer Creating a user without a password but seems like there is no --disabled-password
parameter in useradd
. Even there was, would it prevent useradd: cannot lock /etc/passwd; try again later.
error, since I believe it won't access into the passwd
file.
useradd -d /var/users/general -m general --shell /bin/bash
error:
useradd: Permission denied.
useradd: cannot lock /etc/passwd; try again later.
NOPASSWD
does not mean "no sudo" - you'd still need to prefix theuseradd
command withsudo
– steeldriver Jul 07 '20 at 19:19userdel
since I am getting the same error for it as well – alper Jul 07 '20 at 19:22sudo
is needed because only an admin can create/delete user accounts. It is unrelated to the permissions of the user that is being created/deleted/modified. That's a different setting. – user535733 Jul 07 '20 at 21:05jail
with dummy users I created (https://askubuntu.com/q/1034993/660555). There is only a single user able to login in to system, and running jobs under dummy users forcing, those jobs not to overwrite other users's folders with additional permission (https://superuser.com/a/1342600/723632). Ex: only a user A have access to/home/A/
and the main user able to run a slurm-script as user-A
, which only allows that code to run under/home/A
. – alper Jul 08 '20 at 11:58