I have been trying to run a simple command using sudo, but everytime i run the command i am getting a password prompt. I am root user of that system. Here is the command i am running to invoke sudo

sudo -E -u  nonrootusername /opt/xyz/bin/run_cmd -stop

and here is my entry in sudoers file

%ynonrootuasername ALL=(ALL) NOPASSWD: /opt/xyz/bin/run_cmd -stop

Is invoking sudo -u the root cause of my troubles?

  • %ynonrootuasername defines rights for groups, not for users.
    – nohillside
    Nov 14, 2020 at 14:17
  • But in Linux when u create a user, a group also gets created of the same name to which the user is added, isn't it?...pls correct me if I am wrong
    – achak01
    Nov 14, 2020 at 16:41
  • sudoers defines rights for the user calling sudo
    – nohillside
    Nov 14, 2020 at 17:07

1 Answer 1


I think you have a syntax error :

% Is used for groups, you have wrote %ynonrootusername so you should be part of ynonrootusername group.

Also if you want to allow only nonrootusername just put :

nonrootuasername ALL=(ALL) NOPASSWD: /opt/xyz/bin/run_cmd -stop

Maybe you have mispelled %y characters &ynonrootusername

  • Actually even when I tried
    – achak01
    Nov 15, 2020 at 1:50
  • Actually even after trying this
    – achak01
    Nov 15, 2020 at 1:51
  • put the content of /etc/sudoers line & execute "id ynonrootusername"
    – Reda Salih
    Nov 15, 2020 at 2:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .