I stupidly ran sudo chown -R carlos:carlos /
and carlos is my user. This changed all files to be Carlos and I could not boot up again (because the root files were now owned by #1000) and I cant get sudo acess in live cd (because the owner of /usr was changed to my user). Can anyone help me? FYI I have mounted my hard drive.
3 Answers
You could spend a bunch of time trying to repair this, your best bet is to just reinstall over your existing installation and doublechecking that you don't format the partition.
You'll lose the packages you have installed and have to reinstall them, but it's much less work than reconstructing the permissions on your system.
-
1Will this erase
~
? If it does, it's probably a good idea to backup~
first. After the reinstall, you can replace the new~
with the old~
afterwards and keep your old settings. This will save you lots of time. Commented Jun 25, 2012 at 21:18 -
1No, by default a reinstall will preserve ~, but you're right, keeping backups is always a good idea. Commented Jun 25, 2012 at 21:21
-
3Actually, depends if the /home drive is on a separate mount point in my experience, because from what I've done when trying to reinstall, Ubuntu NEEDS to erase the mount point of / to reinstall it's OS... Commented Jul 2, 2016 at 18:53
It worked from me, hope it helps someone. If this doesn't work reinstall is always an other option.
On booting time:
Select Advanced Options for Ubuntu.
Switch to ubuntu recovery mode.
Select root option from the list of Options.
Enter the commands below:
mount -o remount,rw /
mount --all
chown root:root /usr/bin/sudo
chmod 4755 /usr/bin/sudo
restart
-
I just used this to solve my own issue. How did the change in the ownership of
sudo
occur. I have Webmin installed, did that change it ? Commented Dec 20, 2016 at 16:06 -
Worked for me after changed the chown of /use/bin /use/share by mistake, big thx :)– zatamineCommented Nov 4, 2017 at 11:52
-
I hope this gets more upvotes. I'm very much against the "reformat" or "reinstall" option.– LoraxCommented Aug 7, 2018 at 9:54
-
1worked for me to regain sudo and for re-constructing permissions i downloaded virtual machine of the same distro in other PC created
facl
(ACL file) uploaded to Public S3wget
in infected one and restored permissions and reboot. :) Commented Jan 4, 2019 at 4:55
Boot into recovery mode (follow 1 to 8 from this link). Item 8 is very important.
By typing in the root terminal there, change the ownership of the sudoers.so file:
chown 0 /usr/lib/sudo/sudoers.so
.Then
chmod 644 /usr/lib/sudo/sudoers.so
.Restart your computer.