Mistakenly giving sudo privileges to sub-users without root password

   Today when modifying the hosts file reminded me that I only have read-only access. I was brainstormed on the spot, and then I used the chown command to give the etc permissions to my hadoop user, and then it was a tragedy, sudo could not be used, and the prompt sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set.
     I checked the information on the Internet and it seems that I can enter the super administrator root and change it back, but I decisively did not set the root password at that time. The Internet said that I can use the recovery mode to log in to the root user without a password.
    Restart and hold down shift to enter recovery, then select root, enter
   chown root /etc/sudoers
   chmod 644 /usr/lib/sudo/sudoers.so
   chmod 644 /usr/lib/sudo/sudo_noexec.so

   chown root in the command line :root /etc/sudoers
   chmod 440 /etc/sudoers
   Remember to test whether sudo works after each input, and then give the corresponding permissions according to the prompts it gives.
    Of course, you'd better set up a password for root first, so as to facilitate what you need in the future, passwd su, and then follow the prompts to enter the password. However, after entering recovery mode, you need to change the mounting method of the root directory, modify it to rw, and enter mount -o remount rw /;
    After I did this, I used sudo in root, but after restarting my other users could not use the sudo command, prompting sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set.
    According to the online practice, I reset the properties of sudo.
    chown root:root /usr/bin/sudo
   chmod 4755 /usr/bin/sudo, well, it's done...

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326604685&siteId=291194637