Why am I suddenly not a sudoer anymore? [duplicate]
Solution 1:
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 toadmin
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:
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).-
Don't run
sudo adduser your-username admin
as it says; instead, runadduser your-username sudo
. (Orusermod -a -G your-username
.)The important thing is that you add yourself to
sudo
rather thanadmin
.(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 usesudo
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 beforeon
(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.
Solution 2:
Recover your Sudo Privileges.
- At boot menu, go under Advanced options.
- Select one with Recovery mode.
- Go to "root"
- Type and enter: mount -rw -o remount /
- Type and enter: usermod -a -G sudo USERNAMEHERE
- Type and enter: reboot You should have your Sudo Privileges back.