How a Non-Root User Can sudo to Another Non-Root User Without Password

linuxrhelsudousers

As root, created a new non-root user on RHEL 7.5

appuser:x:1903:1903:appuser:/home/appuser:/bin/bash

A non-root user to be able to sudo to appuser,

sudo -u appuser

without a password,

What are the changes required on RHEL 7.5?

Best Answer

You can edit the "User privilege specification" section of /etc/sudoers, adding:

non-root-user ALL = (appuser) NOPASSWD: ALL

This will allow non-root-user to run all commands as appuser. non-root-user will not be allowed to run commands as root.

Note that errors in /etc/sudoers can make a system unusable. The file should only be edited with:

$ sudo visudo

This special editor checks the sudoers file for errors before saving and refuses to save it if errors are found.