[SOLVED] Cannot use sudo after changing my user password. Cannot access root in any other manner either.
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.
Cannot use sudo after changing my user password. Cannot access root in any other manner either.
I am running Mint 18.1 on a Toshiba Satellite P75-A and access grub bootloader via ESC at boot. My username is no longer a member of sudo group though it is a member of adm. I am the only user of this computer, and my network is a home network with ethernet and wifi and, typically, only one other user.
the problem is not with the password
it is the fact the the membership of sudo group is lost
I assume
Code:
usermod -G adm gebees
the problem is, -G on its own flushes all other group memberships
man usermod
Quote:
-G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
A list of supplementary groups which the user is also a member of. Each group is separated from the next by a comma, with no
intervening whitespace. The groups are subject to the same restrictions as the group given with the -g option.
If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be
changed via the -a option, which appends the user to the current supplementary group list.
to fix, you need to boot a liveCD, mount the root partition, chroot to it and then fix the users group
there was a similar thread not so long ago, I'll see if I can find it
the reason I wanted to link it was I think they managed to get to root account by booting recovery mode from grub
Which is easier than my suggestion of chroot with a liveCD
I've just gotten ready to try the boot-from-ISO solution. This method gets me directly to my current user name and allows me to work on it without any other password. Thanks for that.
In using the Mint 18.2, Cinnamon 64 bit ISO to boot from USB stick, I found that, sadly, I could not read my hard drive such that my booted OS could work in any way with any user management commands such as adduser, passwd, users etc. Nor was sudo useable with my login credentials. Anyway, researching more, trying again.
Help I've received has clarified and expanded my work to fix this issue. Thanks. Any further ideas are welcome.
if the below does not work, I can probably walk you through chroot via a liveCD
Quote:
Originally Posted by michaelk
To elaborate as far as I know the only way to accomplish the above is boot into recovery mode and select drop to a root shell prompt. The root partition is mounted but as read only. To mount it read/write use the mount command.
mount -o remount,rw /
To restore sudo group
adduser g41m-combo sudo
To quit recovery mode type exit and then reboot.
I have not booted into recovery mode in a long time so I can't not confirm exact wording of recovery mode. I also assume that Mint works the same as Ubuntu.
if the above fails
I'm guessing Mint is lvm2 and not "traditional" partitions
to confirm I will need to output of
Code:
lsblk
you won't need root to run that, ( and it should be installed by default )
Boot to recovery did not work, password required...
I booted from an ISO of my Mint as well. No happiness there because I could not chroot, if that makes sense, and when I ran fdisk -l, the booted OS was denied access,'...permission denied.' I'm thinking of attempting the ISO boot with an Ubuntu ISO. It seems that the Ubuntu OS may have more luck with the fdisk -l and the chroot. Regarding the boot to recovery 'failure', I believe that I had set a root password some time ago, but the password that I remember does not work when- and wherever I attempt to use it.
chroot just do not do the install-grub part and try dealing with your issue how ever it needs to get done, remember to change the parts that reflect your system.
ok, so it isn't lvm ( I assumed that was the default ( like CentOS ) these days, I guess it is still optional )
boot your live CD and open a terminal
Code:
mkdir /tmp/mnt
sudo mount /dev/sda2 /tmp/mnt
# no password, see link above just hit enter
sudo chroot /tmp/mnt
# you should now be root on your install!
adduser yourusername sudo
exit # to get out of the chroot
sudo umount /tmp/mnt
then reboot
you should now have access to sudo once more
consider adding your username
Code:
sudo visudo
Code:
<snip>
# User privilege specification
root ALL=(ALL:ALL) ALL
copy that root line, subsituting your username
this way should you lose sudo group membership you can still use sudo
you might also like to think about adding a password for root
Code:
sudo passwd root
but since you have explicitly added your username to sudoers you should not need that
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.