Wednesday, 24 October 2018

How to fix sudo after “chmod -R 777 /usr/bin”?

Today, by mistakenly, I set the 'sudo chmod -R 777' to my /usr/bin folder as a root user. After doing that, I found that , my sudo command was not working at all. After spending a couple (of) hours over google, finally I got the solution and here I am going to share with you.

In an attempt to set permissions for my local scripts(because as I told you ,I broke the sudo permission and changed ownership, by mistake ), and back the ownership of sudo to root , I followed the following steps:
Step 1: Switch to ubuntu recovery mode. If you are unaware of the process, you can refer an answer here: https://brajeshnotes.blogspot.com/2018/10/how-can-i-start-ubuntu-in-safe-mode.html
Step 2: Once in recovery mode, select root - Drop to root shell prompt

Step 3: Do the following commands.
mount -o remount,rw /
chown root:root /usr/bin/sudo
chmod 4755 /usr/bin/sudo
reboot
Note*: If after reboot , sudo comes up with the same three errors mention below :  

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

Try this :
$ mount -o remount,rw /
$ chmod 644 /usr/lib/sudo/sudoers.so
reboot
Wait for your system to boot normally and you will see the ownership of sudo back to root.After doing these all steps, still you guys facing any problem, please leave your valuable comments here, I will try to answer my best.

Related Posts:

5 comments:

  1. You Are Good man, Thank You Alot <3

    ReplyDelete
  2. After follow your instruction i have not able to start my system. It's show always booting process,Can you please suggest me, It's very urgent.

    ReplyDelete
    Replies
    1. Apologies for the delay response. What problem are you facing?

      Delete
  3. This comment has been removed by the author.

    ReplyDelete