Ubuntu – Change default user for authentication

authentication

When I attempt to perform certain actions within ubuntu I am asked to authenticate with a root user, but ubuntu doesn't give me options for which root user, it just specifies it as the user that set up my machine. I was wondering how to go about changing which user it selects to run the authentication?

For instance, if I want to install software from the Ubuntu Software Center I am asked to authenticate with user X and I would like to change that to be user Y globally.

I am also aware that I can just run things with sudo from the command line, but I don't want to have to do that.

I'm using ubuntu 14.04. And user Y is in the sudoers file and as of now user X is not.

Best Answer

For sometime now, sudoers has not been the only way to control user privileges on Ubuntu and other Linux distros. Polkit allows more fine-grained control of privileges. When you use GParted or Synaptic on a recent version of Ubuntu, authentication is usually done using polkit.

To set an user (say Y) as an administrator for polkit, create a file in /etc/polkit-1/localauthority.conf.d/ (say 99-custom.conf), containing:

[Configuration]
AdminIdentities=unix-user:Y

You can test whether this was applied correctly by using pkexec as Y:

$ pkexec bash -l
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/bin/bash' as the super user
Authenticating as: muru,,, (muru)
Password: 
==== AUTHENTICATION COMPLETE ===

Since you already have an admin user, you will be offered a choice by pkexec:

$ pkexec bash
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/bin/bash' as the super user
Multiple identities can be used for authentication:
 1.  X,,, (Y)
 2.  Y,,, (X)
Choose identity to authenticate as (1-2): 

The GUI should offer a drop-down list.

Related Question