0

I'm currently trying to set up a system user on my Ubuntu 18.04.1 LTS server to run a specific service from its home directory and be used with sudo -u USER to execute a command sometimes.

I've created the user with this command:

sudo useradd -d /opt/USER -m -r -s /usr/sbin/nologin USER

And passwd -S USER shows this:

USER L 12/30/2018 -1 -1 -1 -1

First of all, I don't understand why the password is L (locked) instead of not set at all (NP). Not that it matters, I think, since I don't want to login as that user anyway.

Now, I want to be able to run a command as that user, but only me. I can use sudo -u USER echo Test without issues, but anyone can run that command. Restricting access to sudo to only my account is currently not possible. How can I restrict sudo to only myself with that user?

  • Try adding that user to the sudoers group so only both of you can sudo! – George Udosen Dec 30 '18 at 12:37
  • And I don't think everyone can do sudo -u! – George Udosen Dec 30 '18 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.