I have user accounts for user A and user B. Both users are member of the "sudo" group which is allowed to sudo (standard setting for Kubuntu 16.04.3 LTS). Sometimes user A is already logged in and want me to do some administrative stuff.

But I only know the password for user B. I don't want to set a root password, if possible to stick to the distribution standard. Modifing /etc/sudoers would be fine.

How can I use sudo to ask for the password for user B if I'm logged in as user A?

  • It doesn't work that way... User A needs to be in /etc/sudoers to use sudo, it's that simple. If you want to use sudo as User B, you need to login as User B. You could always use 'su' though from any user if you know the root password.
    – acejavelin
    Dec 10, 2017 at 14:49
  • @acejavelin Both users are member of the "sudo" group. Which is per default allowed to sudo (it's an Kubuntu 16.04.3 LTS). For sticking to the standard I don't want to set a root password
    – Yeti
    Dec 10, 2017 at 14:52
  • ‘sudo - UserB’ will require UserA to input the password for UserB
    – Ramhound
    Dec 10, 2017 at 15:14
  • @Ramhound Unfortunately it does not as telcoM has pointed out. :(
    – Yeti
    Dec 10, 2017 at 15:22
  • Strange I use it every single day on my Solaris systems at work
    – Ramhound
    Dec 10, 2017 at 15:33

1 Answer 1


To first switch into User B (using User B's password), you can use the plain old su command. This will always prompt for User B's password. Then use sudo to become root as usual.

userA$ su - userb
userb's Password: ********
userB$ sudo -i    #or whatever

It is possible to make sudo ask the password of the target user instead of the user that is initially running the command: I think SuSE even has/had this as a default setting, but in other Linux distributions and other unix-style systems that would be unusual. The setting for this in the /etc/sudoers file would be:

Defaults targetpw

You can also make this setting only affect a specific user. For example, to cause sudo to ask the password of the target user only when userA uses the sudo command, you would set it in /etc/sudoers like this:

Defaults:userA targetpw

Or if you want anyone using sudo -u userB to be asked userB's password instead of their own, you can do it with:

Defaults>userB targetpw
  • First using su and then sudo is sufficient to me. Thanks everyone!
    – Yeti
    Dec 10, 2017 at 16:46

You must log in to answer this question.

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