CentOS sudo permission problem



Chmod - R 777 / usr was accidentally used
Change all permissions of all files in the usr directory of CentOS to executable, readable and writable
Then something bad came
A problem was found when executing the sudu Su command to obtain root privileges
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

If you are still logged in as root in other windows, congratulations on having a direct solution to the problem
Execute the following command

chown root:root /usr/bin/sudo
chmod 4755 /usr/bin/sudo

Then execute sudo again. Su finds the following error

sudo: error in /etc/sudo.conf, line 19 while loading plugin "sudoers_policy"
sudo: /usr/libexec/sudo/sudoers.so must be only be writable by owner
sudo: fatal error, unable to load plugins

I found that I still couldn’t solve the problem. When I found many methods that couldn’t be solved, I found that someone implemented itpkexec chmod go-w /usr/lib/sudo/sudoers.soThe problem can be solved. If you are still under the root user and modify the directory according to the error reported above, my problem ispkexec chmod go-w /usr/libexec/sudo/sudoers.so
But now the problem is that I’m not under the root user, and I can’t get root permission now, so I’m in an endless loop
Fortunately, there is a final solution

Solution to failure to log in root user

CentOS 7 enters safe mode

  • 1. Restart the system

CentOS sudo permission problem

  • 2. After entering, find the line beginning with Linux 16! Press the right arrow key, navigate to RO, then change RO to RW, and add the command line in the following red box!

CentOS sudo permission problem

  • 3. Use the following tipsCtrl+XEntering the system is actually just entering a memory system in safe mode, not the real Linux system we normally use, and then inputchroot /sysroot/Enter the files in our normal system

CentOS sudo permission problem

Then execute the command just said
The directory is modified according to its own error report

pkexec chmod go-w /usr/libexec/sudo/sudoers.so

Then pressCtrl+Alt+DeleteRestart the system
Enter after enteringsudo suIt is found that you can obtain root user privileges.

This work adoptsCC agreement, reprint must indicate the author and the link to this article