On my Linux Red Hat machines, I do the following from root# su - starus$                <--   now I am in starus user$ su - moon      <-- now I want to access moon user from starus userPassword:But I get prompted for a password!Please advise why I get password if already added in visudo the followingmoon ALL=(starus) NOPASSWD: ALLWhat is wrong?I also try to run the following script as user moon but password is needed  starus@host sudo -u moon  /home/USER261/test.bash[sudo] password for starus:
visudo + how to get access to user from other user
permissions;users;not root user
First of all, root can become any user without needing a password. That's one of the privileges of being the super user. So, with su - starus, you can switch to starus without being prompted. However, at that point, you are starus and no longer root, so you do need a password to switch to moon.The simple solution is to switch back to root first (just run exit) and then switch to moon. Now, visudo is irrelevant here. You're not using sudo so any changes you make there (in /etc/sudoers, the file that visudo edits) won't affect the behavior of su, only that of sudo which is not the same program.In any case, the line you show (moon ALL=(starus) NOPASSWD: ALL) simply means that the user moon can run any command as the user starus with sudo without needing to enter a password. It doesn't mean that anyone can become moon without knowing moon's password. It just means that commands like this don't need a password:moon@host $ sudo -u starus commandIf you are logged in as moon, you can use sudo to run a command as starus without a password. 