0

I've recently had an increased interest in how multiple users are handled in Ubuntu, and have hit an interesting problem: running commands as sudo from a standard account. If I run a GUI application that needs root privileges such as GParted, it gives me the option to authenticate as any administrator. However, running sudo in the terminal only asks for the current user's password and fails if it's running in a standard account. I realize I could easily work around this by switching the terminal session to an admin account, but that requires several extra lines of commands for just one root command. I also came across the idea to use pkexec instead of sudo, but it seems to have some problems with vim and gedit. Is there a simpler way to run commands with root privileges from a standard account? Preferably, a way to tell it to attempt super-user authorization with a different account. If it makes any difference, I'm using zsh instead of bash in Ubuntu 14.04.

2 Answers 2

1

you must add the standard user to the /etc/sudoers files to give them priviledges to run elevated commands.

For example with a user called 'demo':

demo  ALL=(ALL:ALL) ALL

The first field indicates the username that the rule will apply to (demo).

The first "ALL" indicates that this rule applies to all hosts.

The second "ALL" indicates that the demo user can run commands as all users.

The third "ALL" indicates that the demo user can run commands as all groups.

The last "ALL" indicates these rules apply to all commands.

0

For commands which do not need to be connected to a tty or X server (i.e. a few command-line based admin utilities) you can use

su root -c <command>

The command may need to be enclosed in quote marks, and you will be prompted for the root user's password. Note that this requires the root account to be enabled, which it is not by default on Ubuntu. I also tried

su <administrator username> -c "sudo <command"

but that failed due to the lack of a connected tty.

You must log in to answer this question.

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