I ran sudo chmod 777 -R /usr/bin
as I had a few programs there I wanted to be able to run with more ease, without continuously entering my root password but now /usr/bin/sudo
keeps giving me an error whenever I run sudo
. Namely this error:
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
and I am stuck for how to fix this.
Best Answer
The following procedure can also be performed from booting to Recovery Mode choosing Root. Then after booting into root, type in the following to mount the drive in Read / Write so changes can be made:
I would recommend following the first answer on this site to boot to a Live CD so that you can mount your hard drive and repair your file(s). Stop after hitting step #5 so that your hard drive is mounted as a root user.
How can I repair grub? (How to get Ubuntu back after installing Windows?)
after the drive is mounted as a root user, you should be able to type in from the terminal window:
to set the "suid" back for the sudo file.
The following list is all the files in
/usr
that should have the "suid" set: (I will leave them as a list that you can copy and paste as need be)EDIT 2:
The following files have permissions of
rwxr-sr-x
and can be reset by copy and pasting the following into a terminal after getting the host back up: (some might be different then your system)Since all you ran was
chmod 777 -R /usr/bin
and there are no sub directories in that directory, all the files except for the links and the obvious ones above in the list with the "suid" permission set on them, the rest of the files in that directory have permission settings of-rwxr-xr-x
(or 755). You could reset those permissions to those files without touching the "suid" files or the links by typing in:that will set the
group
andother
permissions tor-x
and leave the links alone aslrwxrwxrwx
. DO NOT RUN AS chmod 755 as that will mess up the permissions we have fixed!EDIT: changed to the "suid" as was pointed out to me.