0

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.
alper
  • 222
  • 3
    NOPASSWD does not mean "no sudo" - you'd still need to prefix the useradd command with sudo – steeldriver Jul 07 '20 at 19:19
  • I believe this also stands for userdel since I am getting the same error for it as well – alper Jul 07 '20 at 19:22
  • 1
    sudo 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:05
  • Like a guest User? https://askubuntu.com/questions/1120448/disable-persistence-on-hdd-install-public-pc/1120537#1120537 – C.S.Cameron Jul 08 '20 at 03:28
  • @C.S.Cameron yes and no. I am actually trying to accomplish kind of a jail 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

0 Answers0