Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I recently installed Linux Mint 20.2 on my system. All was going well and I setup a samba share and added my account into a group that I use to access the samba share. Later on I restarted my Linux Mint system and now I seem to be removed from the root/sudoers group.
I don't have any other accounts with root access on the system and when I try and run sudo usermod -aG sudo <my username> I get the following error: Sorry, user <USERNAME> is not allowed to execute '/usr/sbin/usermod -aG sudo <USERNAME>' as root on linuxmint.
Also when I try and see if their are any lock files to delete I get the same sort of error.
When I try to elevate as root I get the same error. even if I run sudo -i same error.
How do I get my access back, and myself added back to sudoers group please? I really don't want to re-install my system.
How do I get my access back, and myself added back to sudoers group please?
You need to boot into single user mode or boot another OS from a pendrive to be able to do that. [Obviously] you cannot add yourself to the sudoers on a running system, that would be a serious security hole.
see for example here: https://www.linuxtechi.com/boot-linu...mergency-mode/
If you have a Live edition on a USB stick, you can boot from that and fix the permissions.
Otherwise, you can try to gain root access during the boot process. This page from the Arch Linux Wiki describes two methods, Using bash as init and Using the debug shell. Either one should also work for Linux Mint:
Hi I have tried both steps outlined and followed the following steps:
Boot to the Live media. You can use an Ubuntu USB.
Open a terminal
Find out the device name for your primary disk (root partition '/') using
sudo fdisk -l
Mount this somewhere using read/write mode, so we can use it (* change the disk from sda1 to your drive's name):
sudo mount -o rw /dev/sda1 /mnt
CD into the mounted drive using cd /mnt
Edit the groups file using
sudo gedit /etc/group
Add your username to important groups like sudo, admin etc. You can add to all the other groups you were removed from later once you gain the sudo Make sure you follow the formatting of the groups file.
format example:
group-name:x:group-number:user1,user2
admin:x:110:username
Save the file and exit
Get out of /mnt using cd /
Unmount the drive using umount /mnt (it threw up an error for me so I ignored this step)
Shutdown the PC, remove the bootable live USB and boot into the native Ubuntu.
Now you should have the sudo privilege restored. Check by typing
sudo df
When I add myself manually to the file it saves but if I run, sudo -l -U jason it says unknown username even though I have home folder, and can log into the system.
I don't really understand. Your user id and groups were ok, why did you change them?
And actually you would need to post exactly what did you try and what's happened, we can't do anything with an example. By the way gedit does not really work [well] together with sudo.
That's because the group to add the account 'jason' to would be 'sudo' and not 'admin' on Linux Mint 20.x. It's hard to see when you are locked out though.
So try again but add the account to the group 'sudo' instead.
If that does not work, try the method in #2 above which used systemd.unit=rescue.target
Boot to the Live media. You can use an Ubuntu USB.
Open a terminal
Find out the device name for your primary disk (root partition '/') using
sudo fdisk -l
Mount this somewhere using read/write mode, so we can use it (* change the disk from sda1 to your drive's name):
sudo mount -o rw /dev/sda1 /mnt
CD into the mounted drive using cd /mnt
Edit the groups file using
sudo gedit /etc/group (in linux mint the path to this file once the drive has been mounted is: /mnt/etc/group you will have to install vim using sudo apt install vim -y)
Add your username to important groups like sudo, admin etc. You can add to all the other groups you were removed from later once you gain the sudo Make sure you follow the formatting of the groups file.
format example:
(BUT ON BELOW STEP FOR MINT 20.2 you don't do this see below)
group-name:x:group-number:user1,user2
admin:x:110:username
Save the file and exit
You look for sudo:x:27 in the file and add your username at the end of it.
Get out of /mnt using cd /
Unmount the drive using umount /mnt (it threw up an error for me so I ignored this step)
Shutdown the PC, remove the bootable live USB and boot into the native Ubuntu.
Now you should have the sudo privilege restored. Check by typing
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.