I using Redhat linux. I am trying to run the following command and would like to know why it is not prompting for password?

Here is what I am doing. I open the terminal window and enter my username and password. After that I run the following command

sudo su - anotherusername

The command runs successfully without prompting for password of anotherusername. I want to know why I don't get password prompt?

Are there any circumstances where I will get password prompt for anotherusername?

Or Is there a different command that will prompt me for anotherusername password?

I mistakenly posted this question in StackOverflow https://stackoverflow.com/questions/46632690/sudo-su-username-not-prompting-for-password and I was told that if my username is part of sudoers group then I will not get password prompt.

Just want to confirm if that is the only reason or there are other reasons as well for not receiving password prompt.


2 Answers 2


sudo su runs su as root; thus there is no need for su to ask a password.

The question might be why sudo does not ask for a password (the invoking user's or root's). The output of sudo -l may explain that. Or sudo has been invoked before and considers the formerly entered password still valid.


Try searching for the username of the user running the sudo command in /etc/sudoers:

$ sudo grep yourusername /etc/sudoers
yourusername    ALL=(ALL)       NOPASSWD: ALL

If the output of that grep command contains NOPASSWD:, then use the visudo command to edit and remove the NOPASSWD: from that line.

Also, you'll be prompted for the password of the user running the sudo command, not the password of the account that you're trying to login to.

  • sudo -iu anotherusername would be somewhat easier, though Oct 8, 2017 at 20:56

You must log in to answer this question.

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