Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Possible Duplicate:
How do I add a user to the “sudo” group?

I've added myself back into the admin's group I think, by following this.

But I still can't do commands like:

sudo aptitude update

I get the message

oshirowanen is not in the sudoers file.  This incident will be reported.

How do I add myself into the sudoers group now that I am in the admin group?

share|improve this question

marked as duplicate by hhlp, gertvdijk, Tom Brossman, RolandiXor, Ringtail Dec 29 '12 at 3:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Appears to be a duplicate ,But cant find it –  Tachyons Apr 22 '12 at 14:35
    
@tachyons You might be thinking of this question about a similar but different error. There, a syntax error prevents running sudo. Here, entries may actually be missing. So I think an optimal answer here must also explain how to add the usual entries to allow administrators to use sudo. I've attempted such an answer. I do not recommend that this question be made a duplicate of that one, because unlike with a "little" syntax error, answers there don't clarify how to edit. –  Eliah Kagan Jul 12 '12 at 17:17

3 Answers 3

up vote 6 down vote accepted

Login as root or su to get root prompt

type visudo

an editor will open find a line says

root ALL=(ALL) ALL

add one with your username below that

user ALL=(ALL) ALL

Type ctrl+x Type Y to the prompt

share|improve this answer
5  
Wouldn't it make more sense to adduser <user> sudo instead? I.e. have him be member of both admin and sudo group? I find it a bit redundant otherwise. –  0xC0000022L Jul 12 '12 at 17:22
    
I agree. That would be the best solution in my opinion. –  Victor Dec 28 '12 at 17:15

If you're in the admin group (or the sudo group starting with Ubuntu 12.04) but that group isn't configured in /etc/sudoers to be able to run commands as root with sudo, you can fix that problem the same way you'd fix a broken sudoers file:

pkexec visudo

Then just edit the sudoers file to add whatever entries you need. In particular:

  • Ubuntu systems before 12.04, or those that were upgraded from a version before 12.04, should have this:

    # Members of the admin group may gain root privileges
    %admin ALL=(ALL) ALL
    
  • Ubuntu 12.04 and later should have this (even if they also have the above lines because they were upgraded from an earlier release):

    # Allow members of group sudo to execute any command
    %sudo   ALL=(ALL:ALL) ALL
    

This pkexec method works (on desktop systems) because Ubuntu systems with a GUI installed have two separate mechanisms for administrators to perform actions as root: sudo, and PolicyKit.

See this question about a different but similar problem, if you're curious and want more information:

share|improve this answer
    
The %sudo line existed already before 10.04. The only thing that's needed is to add the user to the sudo group (adduser <user> sudo). Still +1 for pkexec. –  0xC0000022L Jul 12 '12 at 17:24
    
@0xC0000022L The %admin line exists too. This question is about a system where those lines have somehow been removed, commented out, or modified so they no longer work. You're right in that it's arguably a good idea to have the sudo line in sudoers files in Ubuntu releases prior to 12.04, but practically speaking, it doesn't matter much. In contrast, you need the %admin line on any system where users are made administrators by inclusion in the admin group, and you need the %sudo line on a system where users are made administrators by inclusion in the sudo group. –  Eliah Kagan Jul 12 '12 at 17:30
  1. Enter recovery mode
  2. login with the sudo username and password
  3. add the user to the list of sudo users.
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.