LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 10-04-2021, 02:51 AM   #1
jasric
LQ Newbie
 
Registered: Oct 2021
Posts: 6

Rep: Reputation: Disabled
Unhappy Managed to Lock out my account from root


Hi

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.

Thanks

jasric
 
Old 10-04-2021, 03:03 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
Quote:
Originally Posted by jasric View Post
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/

Quote:
Originally Posted by jasric View Post
I really don't want to re-install my system.
No, you do not need to do that.
 
Old 10-04-2021, 03:04 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,295
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
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:

https://wiki.archlinux.org/title/Res..._root_password

Physical access along with a little time is considered root access for the most part. Even the OpenBSD project concedes this point
 
Old 10-04-2021, 05:23 AM   #4
jasric
LQ Newbie
 
Registered: Oct 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Unhappy Tried steps outlined

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.
 
Old 10-04-2021, 05:31 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
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.
 
Old 10-04-2021, 06:34 AM   #6
jasric
LQ Newbie
 
Registered: Oct 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Unhappy Tried steps outlined

Here is the output of the /etc/group

root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:syslog
tty:x:5:syslog
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
man:x:12:
proxy:x:13:
kmem:x:15:
dialout:x:20:
fax:x:21:
voice:x:22:
cdrom:x:24:
floppy:x:25:
tape:x:26:
sudo:x:27:
audio:x:29ulse
dip:x:30:
www-data:x:33:
backup:x:34:
operator:x:37:
list:x:38:
irc:x:39:
src:x:40:
gnats:x:41:
shadow:x:42:
utmp:x:43:
video:x:44:
sasl:x:45:
plugdev:x:46:
staff:x:50:
games:x:60:
users:x:100:
nogroup:x:65534:
systemd-journal:x:101:
systemd-network:x:102:
systemd-resolve:x:103:
systemd-timesync:x:104:
crontab:x:105:
messagebus:x:106:
input:x:107:
kvm:x:108:
render:x:109:
syslog:x:110:
tss:x:111:
rtkit:x:112:
systemd-coredump:x:113:
lpadmin:x:114:
bluetooth:x:115:
ssl-cert:x:116:xrdp
netdev:x:117:
uuidd:x:118:
mlocate:x:119:
tcpdump:x:120:
ssh:x:121:
geoclue:x:122:
avahi-autoipd:x:123:
scanner:x:124:saned
_flatpak:x:125:
avahi:x:126:
saned:x:127:
lightdm:x:128:
nopasswdlogin:x:129:
colord:x:130:
pulse:x:131:
pulse-access:x:132:
nm-openvpn:x:133:
jason:x:1000
sambashare:x:134:
xrdp:x:135:
rdma:x:136:
linuxfs:x:1001:
smbusers:x:1002:linuxfs,jason
admin:x:110:jason

and I still get the error when running sudo df: Sorry, user jason is not allowed to execute '/usr/bin/df' as root on jason-linuxmint.
 
Old 10-04-2021, 06:38 AM   #7
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,295
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
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
 
Old 10-04-2021, 06:40 AM   #8
jasric
LQ Newbie
 
Registered: Oct 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks,

I really didnt understand the method with systemd.unit=rescue.target any external info would be great
 
Old 10-04-2021, 06:48 AM   #9
jasric
LQ Newbie
 
Registered: Oct 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Unhappy

I still have the issue: Sorry, user jason is not allowed to execute '/usr/bin/df' as root on jason-linuxmint.

after making the change to the group.
 
Old 10-04-2021, 07:00 AM   #10
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,295
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
If you check the group membership for that account, does it list 'sudo' among the groups after you reboot?

Code:
groups jason
If not, then try using gpasswd instead of editing the group file directly.

Code:
gpasswd -a jason sudo
 
Old 10-04-2021, 07:03 AM   #11
jasric
LQ Newbie
 
Registered: Oct 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Talking FIXED IT

Hi I have fixed it:

I 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 (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

sudo df
 
1 members found this post helpful.
Old 10-04-2021, 07:55 AM   #12
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
in that case you may mark the thread solved. thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Vmnet adapters are shown as "device not managed". There are two adapters vmnet1 and vmnet8 which are all not managed. kats99 Linux - Networking 4 11-01-2019 01:42 AM
deian yum lock [ ERR] Reading state information E: Could not get lock /var/lock/aptit jayakumar01 Linux - Server 1 12-05-2011 11:26 AM
is it legitimate and allowed and can be done to make another user account set uid and gid to null 0 to make another root account with different name and possibly not damage the debian system creating and using that new account BenJoBoy Linux - Newbie 12 01-29-2006 10:02 AM
I've managed to lock myself out of X. I need help!! trentk Linux - Newbie 8 02-19-2002 03:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration