What should I do if ubutu14.04 cannot use sudo and cannot switch to root user to solve the problem?

I accidentally modified the /etc/sudoers file.

Crap.

Can't use sudo anymore, can't do anything.

The most important thing is that you can't log in with root.

I was thinking of reinstalling the system.

Later discovered the magical ubuntu safe mode.

1. Restart ubuntu, then long press shift to enter the grub menu.

2. Select recovery mode, and press "e" to enter the editing page.

3. Replace ro recovery with rw single init=/bin/bash.

After the modification is complete, press Ctrl+x to enter the system.

In this way, log in as root user, and you can modify the /etc/sudoers file.

chmod 444 /etc/sudoers

Change to read-only file.

Note:
a. After modifying the grub configuration, the next time you enter the recovery mode, the displayed content is still the same as before. If you want to enter single-user mode again, you need to modify it again.
b. If you want to restart after modification, it is not feasible to use reboot, shutdown -r, etc., you need to use ctrl + alt + delete to achieve it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325382289&siteId=291194637