4

How can I make something like that:

There are two users: user with normal privileges, and administrator with admin privileges.

I want to make it like that:

user@localhost:~$ sudo vim 
[sudo] password for administrator: <admin's password here>

And I am on the administrator account now.

Seth
  • 59,332
LiquidPL
  • 218

3 Answers3

6

Simply add the user to the sudo group:

sudo adduser <username> sudo

More detailed explanation: https://help.ubuntu.com/community/RootSudo#Allowing_other_users_to_run_sudo

If you really need to run vim as a user named "administrator" (not root!) you should use

sudo -u adminstrator vim

But even in that case the normal user has to be member of the sudo group.

5

sudo vim would mean to execute the vim command as super-user. If you are looking for the command to start a shell, use

sudo -i

or

sudo su

These will have you type the password of your user, and the user needs to be in the sudoers file.

If you don't want the user to be added to that file, you could just use the command

su

which will have you type in the root (administrator) account.

And finally, if there is an account called administrator, you could do

su administrator

to gain access to that.

Nanne
  • 8,685
1

If you meant that when logged in as user you want to execute a command as administrator then you need to do:

user@localhost:~$ sudo -u administrator vim

However, the user's password will be asked not the one from adminitrator. To do so you need to run as administrator (hmm) the following command to configure sudo:

visudo

Then scroll down in the opened file and look for other Defaults definition. In this section, preferrably at the end of it, add a new line with:

Defaults targetpw

And save the file and exit. Note that this will change the default behaviour for all sudo users, so if your user administrator needs to use sudo to have root privilege, you would better know the root password!

Huygens
  • 4,783