Solved: Troubles with Visudo

Hello!

I am having some troubles with visudo. The following I want to do:

My main user is called usera. A second user is called userb.

I am logged in with usera and want to run an app as userb. The app is located in /opt.

The command to do this usually looks like this:

sudo -H -u userb /opt/app.appimage

However, with this command, I am asked for the password. I want it to work without entering the password, therefore I tried to set a rule with visudo.

My visudo line looks like this:

usera ALL=(userb) NOPASSWD: /opt/app.appimage

However, this gets ignored, I am still asked for the password. This line works with Ubuntu so I wonder if I it has to be different in Fedora or is there a known issue with visudo?

Any ideas how to resolve the issue?

Thanks

UPDATE: I works now. It seems the line

usera ALL=(userb) NOPASSWD: /opt/app.appimage

needs to be at the right place in the sudoers file. Putting right below

Allows people in group wheel to run all commands

%wheel ALL=(ALL) ALL

works.

Not a good idea, because sudoers file nowadays is more a template and you will be encouraged to use the file path /etc/sudoers.d/userb-rights as an example. The file name you can choose as you like. but if you include the username, you always get an idea what kind of changes you made without changing sudoers and use visudo.

@ilikelinux , thank you for this advice. And apologies for replying with a different user name - I just lost my access code.

So, I have one more followup question:

How would this line usera ALL=(userb) NOPASSWD: /opt/app.appimage translate into /etc/sudoers.d/userb-rights ?

sudo tee /etc/sudoers.d/userb-rights << "EOF"
usera ALL=(userb) NOPASSWD: /opt/app.appimage
EOF
1 Like

Ah, I see. Just a simple line within this file.

Thank you very much. I will follow this approach.