If I try using sudo as a non-privileged user, I get a message that the user is not in the sudoers file. I know the Administrator password, but I do not know, how to use it from a non-privileged (Standard) user.
2 Answers
Use pkexec
instead. If the current user doesn't have privileges, or if there are multiple users who can authorize an action, it will prompt you to select the user:
$ pkexec true
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/bin/true' as the super user
Multiple identities can be used for authentication:
1. muru
2. sysad, (sysad)
Choose identity to authenticate as (1-2): 1
Password:
pkexec
, of course, does not follow the sudo
configuration, but its own. However, if you added admin users by adding them to the sudo
group, they will also be granted Polkit admin rights by Ubuntu's default configuration.

- 197,895
- 55
- 485
- 740
To go from a nonprivileged user to a sudo
user, you do not use sudo
.
Instead, you first have to switch users.
Login as the other user with the following command from nosudo
user (assuming nosudo
is the nonprivileged user, yessudo
is the sudoer):
su - yessudo
It will then prompt for the login password for yessudo
. After you login as yessudo
you can run sudo
commands from that user. If at any time you exit out of that and return to the nosudo
user, you have to do the command above again.

- 74,764
-
Note that this does not solve the problem of you not being in sudoers. Also consider that it's probably that way for a reason, so you should reconsider the ramifications of going about this method. – Thomas Ward Jun 26 '15 at 02:09
-
1@ Thomas W.: Yes, I care for security and I will always switch back to the 'nosudo' user. I understand that the system cannot switch it back straight automatically . – Tomáš Pečený Jun 26 '15 at 02:51
-
@ Thomas W.: Is it not possible to enable using sudo from the standard user by adding somehow the standard user into a sudoers file? Thanks! – Tomáš Pečený Jun 26 '15 at 03:16
-
@TomasPeceny yes, but at that point the user becomes a privileged user, and not a standard user. Add the unprivileged user to the
sudo
group, and they'll havesudo
access (usermod -a -G sudo nosudo
is the command, wherenosudo
is the non-sudoers user from above). Then,nosudo
user should log out and log back in, thereby refreshing their groups membership. (HOWEVER, while this would do what you achieve and givesudo
access to thenosudo
user,pkexec
would be a better option if you want to keepnosudo
as an unprivileged user) – Thomas Ward Jun 26 '15 at 03:23 -
@ Thomas W.: I see I have misunderstood the term 'sudoer'. I seek for a method how to shorten the time when I am connected to the network as the privileged user. As far as possible without complicated configuring. Your answer appears to be really the proper solution for me. Thanks! – Tomáš Pečený Jun 26 '15 at 03:43
-
@ Thomas W.: But the 'sudo pm-hibernate' does not work this way (the CPU is working further, after a notice 'cannot find...'). Do you have an idea how to hibernate from a non-privileged user? Suspending works OK. – Tomáš Pečený Jun 26 '15 at 04:05
-
@TomasPeceny Hibernate doesn't work in all systems. And I believe that's why they disable it. You have to add your own user to the sudo group then execute with sudo. Or use pkexec. – Thomas Ward Jun 26 '15 at 11:27
-
pkexec
I don't see command output in the terminal. – gmk57 Dec 20 '21 at 17:34