Linux – Lost permission to use sudo commands


I changed /etc folder permission to 711.

After doing that, I lost the permission to use sudo commands. Any way to change the folder permissions back?

What I have tried so far:

1) use su -, authentication failure

2) sudo …, not working obviously.

sudo: unable to open /etc/sudoers: Permission denied

sudo: no valid sudoers sources found, quitting

sudo: unable to initialize policy plugin

Best Answer

  • There is a very good, detailed answer on using chroot here.

    As user1461135 said, you need to add the iso to your Virtual Machine, boot using it and then mount your / partition. So, first of all check the name of your / partition. Log into your Linux System and run:

    $ mount | grep "/ "

    This should return a line like:

    /dev/disk/by-uuid/d5cf13h31-f344-41237-92c5-e29c6006442h60 on / type ext4 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)

    or like this:

    /dev/sda7 on / type ext4 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)

    In the first case, your partition is mounted by its UUID. To find out which device this UUID corresponds to run:

    $ ls -l /dev/disk/by-uuid/

    You will see that the UUID returned by mount corresponds to a specific /dev/sdX device. ON my system, it is /dev/sda7. If you have a line like the second example above, you already know the device.

    Now, boot into the live session from the CD as suggested in the comments, create an empty directory, and mount your system there:

    $ mkdir mountpoint
    $ sudo mount /dev/sda7 mountpoint

    Remember to replace sda7 with whatever your partition is. Once the system is mounted, I am not even sure you will need chroot. You can probably just run the chmod command directly:

    $ sudo chmod 755 mountpoint/etc

    Now, reboot your Linux system and things should be back to normal.

  • Related Question