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.

This question already has an answer here:

I booted up Ubuntu 12.10 today, and when trying to sudo, I entered my password as usual but it had said I'm not a sudoer. So I go and check my account under User Accounts, and for some reason Im now a standard user?

I tried re-adding myself to admin through recovery mode already, but it didn't work.

EDIT: UserMod command will not work. Get the error: usermod: cannot lock /etc/passwd; try again later.

EDIT 2: Thank you to all that helped! Your support is greatly appreciated!

share|improve this question

marked as duplicate by Eliah Kagan, Eric Carvalho, Thomas W., Nathan Osman, Basharat Sialvi Apr 9 '13 at 1:15

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.

    
@Aditya There, the problem relates to entering recovery mode. Here, the problem is that changes made in recovery mode weren't effective. So this is not a duplicate of that. fr057w1nd: Administrator and sudoer effectively mean the same thing in Ubuntu, since the other mechanism whereby administrators may perform actions as root--PolicyKit--is based on the same details of group membership as being able to sudo-to-root. –  Eliah Kagan Mar 29 '13 at 21:12
    
Sorry for misunderstanding. Sortof new to Ubuntu. –  fr057w1nd Mar 29 '13 at 21:13
    
@Aditya I don't think the'll help here, as this problem appears to be that the OP attempted to add to admin, when the proper group (in this version of Ubuntu) is sudo. Backward compat. makes admin work, but only if it exists (except on upgraded systems it doesn't). fr057w1nd: Not a problem. Hopefully my answer will enable you to fix this problem. BTW, if you're interested in the details of what makes a user an administrator in Ubuntu, you may want to read this answer (but that's not necessary, for this issue). –  Eliah Kagan Mar 29 '13 at 21:22
    
Related: Regain Sudo rights after removing from admin group –  Aditya Mar 29 '13 at 21:29
1  
@Aditya IMO highly detailed instructions for re-making oneself an administrator is an unnecessary duplication of effort, since it's very similar to, and can be explained in relation to, resetting a password. (But I do recommend keeping that link; in light of new information, it may be more relevant than I thought, though this is only a duplicate of it if the part about sudo vs. admin groups is disregarded.) –  Eliah Kagan Mar 29 '13 at 21:33
show 1 more comment

2 Answers 2

up vote 14 down vote accepted

Starting in Ubuntu 12.04, the sudo group confers administrative power to users. The admin group will too, but only if it exists, and unless you upgraded from a previous version or manually created it, it does not.

  • For more information, see What is the difference between the 'sudo' and 'admin' group?
  • Even if you did upgrade starting from a version earlier than 12.04, if the event that caused this problem was the inadvertent deletion of the admin group, then an attempt to fix this by adding yourself to admin would also fail.

Therefore, you must add yourself to the sudo group rather than the admin group. To do this, boot in recovery mode and enter a root shell (as you did before), then run:

usermod -a -G sudo username

Make sure to replace username with your actual username.

Then, you'll be an administrator again.

(If that does not work or produces an error, please comment here to briefly explain what happened, and also edit your question to add as much information about what happened as possible.)

Source: How can I give admin permissions to my account?

When That Doesn't Work

You got the error usermod: cannot lock /etc/passwd; try again later.

usermod is apparently not able to gain proper access to /etc/passwd (the file it must modify), even in recovery mode.

Hopefully, booting directly to a root shell without going through the recovery mode menu will work better. So try "The Other Way Lucid" (but run usermod -a -G sudo username instead of passwd username, as before).

If that doesn't work, you can try the solution by Oli that Aditya had suggested, with two major caveats:

  1. You can only use those instructions if you know enough about your system to "change sdYY to your root partition" as it demands (i.e., if you know the device name for your root partition).

  2. Don't run sudo adduser your-username admin as it says; instead, run adduser your-username sudo. (Or usermod -a -G your-username.)

    The important thing is that you add yourself to sudo rather than admin.

    (Feel free to skip this paragraph--it's about style and "best practices.")
    But it's also unnecessary, and in my opinion somewhat poor form, to use sudo to run commands as root, when you're already in a root shell where all your commands run as root. I think this rapidly causes confusion about when one is and isn't in a root shell.

Or you can use the instructions I wrote here, which explain how to obtain all the necessary information. They're long, but that is because they cover a variety of situations that probably don't apply for you, including not being able to log on to the machine at all, and wanting to reset the password as well as make a user an administrator. They also explain how to do everything without assuming much prior knowledge or experience (for example, they explain in detail how to boot from and access a useful desktop on a live CD).

You have another option: Those instructions of mine are really a general presentation the same technique that Oli wrote about more succinctly and more situation-specifically. So, from what I wrote there, here's how to find out what command to use in place of sudo mount /dev/sdYY /mnt/boot # change sdYY to your root partition:

In your Ubuntu system (not the live CD/DVD/USB system), run this command in the Terminal:

mount | grep ' on / '

You should include the spaces before on and after /.

That command produces something like /dev/sda1 on / type ext4 (rw,errors=remount-ro,commit=0) as the output. The text before on (not including the space) is the device name of the partition that contains your Ubuntu system's root filesystem. Remember it (or write it down).

Then, once you've opened the Terminal on the live CD/DVD/USB:

Run this command:

sudo mount /dev/sda1 /mnt

Replace /dev/sda1 with the device name of the partition containing your Ubuntu system's root filesystem, if different.

Besides using the device name you found with the technique above, you should also use /mnt and not /mnt/boot as in Oli's answer. But then you can continue on with the instructions there.

share|improve this answer
    
Thanks, will try now. Will come back and say if it has worked or not. –  fr057w1nd Mar 29 '13 at 21:19
    
Got an error. usermod: cannot lock /etc/passwd; try again later. –  fr057w1nd Mar 29 '13 at 21:25
    
@fr057w1nd I've updated my answer with information that should help. I've given a couple of other ways to add yourself to the sudo group. The first and easiest way might work. If not, the other ways will almost certainly work. –  Eliah Kagan Mar 29 '13 at 22:08
    
Sorry for the huge delay, went out somewhere. But I found that none of them worked. I did, however, find a different method. Will put an answer up. –  fr057w1nd Mar 30 '13 at 2:08
add comment

Recover your Sudo Privileges.

  1. At boot menu, go under Advanced options.
  2. Select one with Recovery mode.
  3. Go to "root"
  4. Type and enter: mount -rw -o remount /
  5. Type and enter: usermod -a -G sudo USERNAMEHERE
  6. Type and enter: reboot You should have your Sudo Privileges back.
share|improve this answer
    
No, you had to mount first. –  fr057w1nd Mar 30 '13 at 2:14
    
Gotcha. Cool, I'm glad you solved it! –  Eliah Kagan Mar 30 '13 at 2:15
    
Thanks! You helped alot too. Never thought of the usermod command! –  fr057w1nd Mar 30 '13 at 2:15
    
Also, in case anything does happen again, I've created a backup admin account so I don't have to go through them troubles. Lol. –  fr057w1nd Mar 30 '13 at 2:16
add comment

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