1

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:~$ 
  • If you don't manage to escalate privileges to root, boot into a root command line — see http://unix.stackexchange.com/questions/77852/how-to-recover-from-a-chmod-r-000-bin/77858#77858 for tips. Or reinstall the system — recovering from bad permissions on /etc requires quite a bit of experience. – Gilles 'SO- stop being evil' May 15 '14 at 23:18
  • @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 May 16 '14 at 01:59

3 Answers3

2

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.

michas
  • 21,510
  • 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 – Sulthan Allaudeen May 15 '14 at 06:09
  • 1
    The init process is always run with root permissions. With this kernel option your kernel will directly boot into a root shell. – michas May 15 '14 at 06:11
  • 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 – Sulthan Allaudeen May 15 '14 at 06:24
0

The problem was fixed by myself :

I typed pkexec chmod 0440 /etc/sudoers

And then i am able to be sudo su, and then the permission was changed and i gave the default permission /etc as chmod 744 /etc

-1

its because of Limiting Access to sudo

Follow these steps:

chmod 755 /etc/sudoers

vi /etc/sudoers

Allow root to run any commands anywhere

root ALL=(ALL) ALL username ALL=(ALL) ALL

username = your username

type Esc > type :wq Enter

change chmod to

chmod 440 /etc/sudoers

Your problem is solved :)