2
user@main-desktop:~$ sudo apt-get python-cheetah
[sudo] password for user: 
user is not in the sudoers file.  This incident will be reported.

So that is what I get when trying to install something while logged into my user account. It's prompting me for the user password.

How do I get it to prompt me for my admin account's password so that it will allow me to install something? I want to try and keep the user account seperate. I'm new to linux but it seems like adding a user account to the sudoers file defeats the purpose of having a user account.

dcvl
  • 123
  • 1
  • 3
  • So just to be clear - you have actually two users, one was created during install and has admin priviledges and the other is this one which does not have admin priviledges? If so, this works as designed, you cannot install software for the whole system witohut admin priviledges. Actually, just go with the use created during install, sudo is meant to only run processes that need root priviledges (so that you do not run firefox as root) with root priviledges and this is exactly its point - to have one user account and being able to admin the system without loggin as root. – sup May 06 '15 at 12:06
  • There is a second case. Maybe you removed yourself from sudo group like this guy: http://www.maketecheasier.com/fixing-sudo-error-in-ubuntu/ – Cikson May 06 '15 at 12:13
  • Yes, this is the case. But I figured there would be a way to use admin credentials while on another user account (like you can with windows). That way you only provide the credentials during task needed, otherwise you stay in user mode. – dcvl May 06 '15 at 15:43
  • Separation of duties (regular user and system administration) while is exactly, what sudo is made for. You may want to read https://help.ubuntu.com/community/RootSudo. – David Foerster May 07 '15 at 20:21

3 Answers3

1
  • For individual commands to run as super-user, use:

    sudo -u your-admin-account sudo COMMAND [ARGS...]
    

    (replace your-admin-account with the name of your admin account)

  • To start a shell as your-admin-account use:

    su - your-admin-account
    

    In this shell you can use sudo with your admin account's password. When you don't need the admin shell any more close it using exit or Ctrl+D.

David Foerster
  • 36,264
  • 56
  • 94
  • 147
  • This was the fix! Thank you. I was under the impression sudo was all I needed to make the superuser perform the action. The su allowed me to move into the admin account and then sudo apt-get the install I needed. Thanks! – dcvl May 06 '15 at 15:45
  • Similarly, for individual commands use sudo -u your-admin-account sudo COMMAND [ARGS...]. This would be more in the spirit of the normal use of sudo as a user in /etc/sudoers. – David Foerster May 07 '15 at 20:29
0

Use pkexec instead. pkexec prompts with a list of users who can authorize the action, if the current one can't:

user1@ica:~$ DISPLAY= pkexec bash
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/bin/bash' as the super user
Authenticating as: Muru (muru)
Password: 

I unset DISPLAY to show you the CLI prompt, but pkexec typically uses a graphical prompt if the GUI is available.

muru
  • 197,895
  • 55
  • 485
  • 740
-1

The user that you are trying to install from named user has no sudo power which means he is not an admin on your system.

In order to install a package you should be a sudoer which means admin user.

So you can fix your problem by either use a sudoer user to install or change your account from normal user to admin user.

To change this account to sudo user you have to run this command using either root user or another sudo user

sudo usermod -a -G sudo user

sudo usermod -a -G sudo adm

But according to @muru advice not to use usermod -a -G this is another way to perform the same task

sudo adduser user sudo

sudo adduser user adm

Now the user named user is a sudoer

Maythux
  • 84,289
  • 1
    The adm group typically grants access to some logs. The wheel group in older installation grants access to sudo. In either case, use adduser instead of useradd. – muru May 06 '15 at 12:12
  • I do know what adm group is for. http://askubuntu.com/questions/612751/what-is-the-difference-between-the-groups-adm-and-admin – Maythux May 06 '15 at 13:14
  • Hooray! Then why haven't you explained the difference in the post, instead simply adding users to various groups? – muru May 06 '15 at 13:16
  • for useradd or adduser it still a mysterious for me lol http://askubuntu.com/questions/611954/when-to-use-adduser-or-useradd – Maythux May 06 '15 at 13:16
  • @muru the use still needs to perform system monitoring tasks for that i added him to adm... And why i didn't add the explanation because i don't want the OP confused with definitions. I want to solve his problem first. – Maythux May 06 '15 at 13:17
  • The principle difference is that a user forgetting the -a in usermod -a -G can cause problems. – muru May 06 '15 at 13:18
  • 1
    The user actually doesn't need to perform anything. "I want to try and keep the user account seperate." – muru May 06 '15 at 13:18
  • what problem in the -a in usermod -a -G ? – Maythux May 06 '15 at 13:20
  • The problem is when a user forgets it. – muru May 06 '15 at 13:21
  • Ok But i think most commands in linux would be a problem if we consider this is a problem!!! – Maythux May 06 '15 at 13:22
  • Most commands don't have safer alternatives. – muru May 06 '15 at 13:22
  • Yes you are right from this point of view – Maythux May 06 '15 at 13:24