I have just made a huge mistake by changing the owner of my /usr/bin
from root
to an ordinary user
. Whenever i try to execute $sudo chown root /usr/bin
this gives me :
chown: changing ownership of ‘/usr/bin/’: Operation not permitted
I have read many topics talking about this issue, which most of them give a solution in case you have already a backup image of your OS. Unfortunately I don't have any backup. Is there any solution then other than reinstalling Ubuntu from scratch.
Solution:- Get in to Ubuntu Recovery Console Start your computer and press and hold SHIFT key while booting. It will take you to the grub loader page as shown in image – 1.
Image 1
Select and enter Advanced options for Ubuntu and from there select the kernel named as recovery mode as shown in image – 2.
Image 2
select root – drop to root shell prompt as shown in image – 3
Image 3
Now the file system is read only to Remount to Read Write run below command
# mount -o remount,rw /
then need to change the ownership for sudo
# chown root:root /usr/bin/sudo
give permisson for sudo
# chmod 4755 /usr/bin/sudo
it’s done … let’s see by restarting the machine
# shutdown -r now
You should have your Sudo back by now....
If you can't gain root with plain "su" because you don't know the password or none has been set, then you have to reboot into a root shell. When you see the GRUB boot menu, press "e" to edit the kernel command lines, and append "init=/bin/sh" - then it will dump you into a single-user root shell instead of the normal boot process. Here you may have to remount the root file system read/write:
# mount / -n -w -o remount
Then you need to undo the damage from earlier:
# chown -R root /usr/bin
Then finally remount the file system read-only, sync and reboot:
# mount / -n -r -o remount
# sync
# reboot -f
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With