How to fix it(Or can be fixed?)

A forum for general discussion about Linux. If it is about Linux, but does not seem to fit in any other forum, then this is probably the best place to post it.
Post Reply
User avatar
Dimitris
Posts: 5
Joined: Tue Jan 21, 2020 7:49 pm
Location: Greece

How to fix it(Or can be fixed?)

Post by Dimitris » Tue Jan 21, 2020 8:02 pm

In my attempt to make my machine no need password for sudo command I probably changed something wrong and now every time I use sudo command this message appears("dimitris is not in the sudoers file. This incident will be reported."). The problem is I use ubuntu which they have locked the password for the user root by default and i cant become root and change the sudoers file again. Can i fix this problem or i have to make a clear installation from the start? :D

User avatar
DistroTube
Site Admin
Posts: 49
Joined: Thu Jan 02, 2020 1:12 am

Re: How to fix it(Or can be fixed?)

Post by DistroTube » Tue Jan 21, 2020 10:53 pm

You could always use a live USB. Mount the drive:

Code: Select all

sudo mount /dev/sdYY /mnt  # change sdYY to your root partition
sudo mount --bind /dev  /mnt/dev
sudo mount --bind /dev/pts  /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys  /mnt/sys
sudo chroot /mnt
All the mount/bind commands are probably necessary to get you a properly running bash in the chroot.

Chroot'ing almost always logs you in as the root user. So then you can simply:

Code: Select all

sudo adduser username sudo 
(Ubuntu uses the "sudo" group rather than the "wheel" group)

bigpod
Posts: 28
Joined: Thu Jan 02, 2020 7:51 pm

Re: How to fix it(Or can be fixed?)

Post by bigpod » Tue Jan 21, 2020 11:15 pm

no need to chroot realy just mount the drive with live usb or if you have another distro and nano into sudoers file and fix the thing

Code: Select all

username ALL=(ALL) NOPASSWD:ALL
this is correct syntax for no password sudo
Use whatever tool makes your job easier.

User avatar
Dimitris
Posts: 5
Joined: Tue Jan 21, 2020 7:49 pm
Location: Greece

Re: How to fix it(Or can be fixed?)

Post by Dimitris » Wed Jan 22, 2020 8:38 am

Thank a lot!

Post Reply