Wrong Permission to /etc folder

7,606

Seems like your root account does not have an associated password, hence you cannot log into your root account directly. The other way to get root is sudo which is currently broken due to the wrong permissions of the sudoers file.

Since you need root access to fix those permissions you need to find another way.

Maybe the easiest way is to add a custom init option to your kernel at bootup.

Your boot manager should allow you to add custom options to your kernel command line. Reboot your computer and add something like init=/bin/bash at the end of the kernel line.

Then your kernel should start bash instead of the normal init deamon. This way you can fix your permissions and after another reboot your usual sudo should work again.

Share:
7,606

Related videos on Youtube

Sulthan Allaudeen
Author by

Sulthan Allaudeen

Updated on September 18, 2022

Comments

  • Sulthan Allaudeen
    Sulthan Allaudeen over 1 year

    I have given the wrong permission to the /etc folder

    chmod -R 777 /etc
    

    When I want to login as root it gives me an error and the following output.

    How can I correct the permissions?

    system13@motpl:~$ sudo su
    sudo: /etc/sudoers is mode 0777, should be 0440
    sudo: no valid sudoers sources found, quitting
    sudo: unable to initialize policy plugin
    system13@motpl:~$ su root
    Password: 
    su: Authentication failure
    system13@motpl:~$ 
    
    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' about 10 years
      If you don't manage to escalate privileges to root, boot into a root command line — see unix.stackexchange.com/questions/77852/… for tips. Or reinstall the system — recovering from bad permissions on /etc requires quite a bit of experience.
    • Sulthan Allaudeen
      Sulthan Allaudeen about 10 years
      @Gilles Yes thank you. And the answer given by me looks very simple. It worked. But i don't know whether it is good practise or not.
  • Sulthan Allaudeen
    Sulthan Allaudeen about 10 years
    I have a password. And another thing. I can do the init=/bin/bash only if i am root user right. Now i can't be a root user
  • michas
    michas about 10 years
    The init process is always run with root permissions. With this kernel option your kernel will directly boot into a root shell.
  • Sulthan Allaudeen
    Sulthan Allaudeen about 10 years
    After entering init=/bin/bash and pressing Ctrl+x it is rebooting but it is not entering with root mode. it is just like normal boot and can't use the sudo su too