0

I tried everything but nothing works.

sudo is not working because it says:

/etc/sudoers is world writable

Can't login as the root user even if I typed the command sudo -i

chmod: changing permissions of 'etc/sudoers': Operation not permitted

su: Authentication failure

Before this error happened, I tried to change the permission of the /etc folder to allow me to create a new folder inside the /etc folder, then after I open the ssh the next day, this error came up.

The following commands are the only ones that I remembered to allow me to create a folder:

sudo chmod -R 777 /etc chmod a+w test mkdir /etc/backup

I'm new to Linux commands so I just search them and tried it on my ssh then this error happens.

errors in terminal

Can anyone help me? Thanks in advance.

Zanna
  • 72,312
Jeff
  • 11
  • 2
  • 4

3 Answers3

4

Before this error happens, I tried to change the permission of the /etc folder to allow me to create a new folder inside the /etc folder

There is NO valid reason to alter /etc/. This is a system directory maintained by packages/he package manager. If you need a personal directory put it either in /home/$USER or if multi-user server in /opt/etc (but even those are icky IMO ;)).

You fix this by rebooting into grub rescue or from a live session and then do

chmod 440 /etc/sudoers

so it matches

r--r----- 1 root root 1800 feb 20 18:38 /etc/sudoers

Mind that this might be a futile attempt: if you did something to the whole of /etc/ you might have changed more then just sudoers file. Then a reinstall without formatting would be the answer.

Rinzwind
  • 309,379
0

You should reboot your system and start as single user mode, drop into root shell, change ownership of /etc/sudoers:

After reboot press shfit until GRUB menu appears, then press e to edit, afther that go to the line that starts with linux /boot/vmlinuz and replace the end of the line ro \ console=ttyS0 console=tty0 with rw init=/bin/bash.

Instructions from itgala with images.

Now chmod 440 /etc/sudoers at then end the sudoers file should look like this

-r--r-----

I recommend you to edit sudoers file with visudo and for adding more config to /etc/sudoers.d/my-sudoers.

mehdiMj
  • 183
0

If your system Not accepting a command then power of you system then power on at power on time press 'esc'

you will see one window

1.Select advanced ubuntu

2.Then select Recovery mode

3.Then select root

Command prompt will open Insert this below command and restart your syste.

Reset Your Etc Sudoers permissions Using:

chmod 755 /etc

chmod 644 /etc/sudoers

chown root:root /etc/sudoers

If you still see errors Like:

sudo: /etc/sudo.conf is world writable

sudo: /etc/sudo.conf is world writable

sudo: /etc/sudoers.d/README is world writable

Select one by one[Each file that show errors] and reset permisiions for all of them.

**Defualt permissions: **

sudo chmod 644 /etc/sudo.conf

sudo chmod 644 /etc/sudoers.d/README

Hi10
  • 1