Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  17] [ 0]  / answers: 1 / hits: 17044  / 2 Years ago, tue, august 9, 2022, 7:23:50

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!


More From » sudo

 Answers
4

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.


[#31974] Thursday, August 11, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
arkcker

Total Points: 296
Total Questions: 111
Total Answers: 104

Location: Nepal
Member since Tue, Sep 8, 2020
4 Years ago
;