January 19, 2023, 9:54am
While installing Ruby/Jekyll and following ‘advice on internet’ I messed up the permissions on /usr/bin/, so now can not use
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
StackExchange topics suggest a system reinstall to fix the permission issues.
Would a reinstall, with keeping (not formatting) the root ‘/’ and ‘home’ partitions solve the issue, or do I need to format the partitions?
I really do not want to lose the system settings and all, as I reinstalled the system just a couple of weeks ago (and switched to KDE).
Thanks in advance!
January 19, 2023, 9:59am
You should be able to fix this without reinstalling the system.
Please share the output of “
ls -l /usr/bin/*”
Can you login with root user and root password, like with “
su -” ? If not, you would need to boot with a live iso and mount your “/” filesystem there to fix it.
January 19, 2023, 10:10am
Here’s an extract of the log:
-rwxr-xr-x 1 reinis root 51K aug 4 14:32 /usr/bin/su*
-rwxr-xr-x 1 reinis root 5,0K nov 15 18:45 /usr/bin/substrings.pl*
-rwxr-xr-x 1 reinis root 2,0K dec 24 23:04 /usr/bin/su-c_wrapper*
-rwsr-xr-x 1 reinis root 243K nov 5 12:08 /usr/bin/sudo*
lrwxrwxrwx 1 reinis root 4 nov 5 12:08 /usr/bin/sudoedit -> sudo*
-rwxr-xr-x 1 reinis root 237K nov 5 12:08 /usr/bin/sudo_logsrvd*
-rwxr-xr-x 1 reinis root 84K nov 5 12:08 /usr/bin/sudoreplay*
-rwxr-xr-x 1 reinis root 119K nov 5 12:08 /usr/bin/sudo_sendlog*
-rwxr-xr-x 1 reinis root 39K aug 4 14:32 /usr/bin/sulogin*
I don’t have a ‘root’ user, thus the
su root command gives an
su: Authentication failure error.
January 19, 2023, 12:12pm
If all you did was change the ownership, switch to a TTY, login as root and run:
chown -R root /usr/bin
That isn’t a particularly good idea in general but given the state of your system it shouldn’t make things worse. In my system, everything inside
/bin is owned by root.
In general, if you have a tutorial/guide/person telling you to change permissions in
/bin, find a different one. You should never need to do that.
January 19, 2023, 12:22pm
OK, will try that. How do I switch to TTY? I’m running KDE and systemd-boot (no grub), if that is relevant.
Yeah, will definitely remember this lesson on changing permissions, based on some online tutorial, without deeper research.
January 19, 2023, 12:24pm
ctrl+ alt+ f3 after the system has booted.
January 19, 2023, 12:44pm
Thanks for your help! Now the
sudo command works. Though not sure if something else has not been messed up still.
I also had to do
chmod u+s /usr/bin/sudo to apply the
setuid bit to the file.
Don’t change permissions and owners on files installed by the package manager, not even on aur packages. It could make your system vulnerable, not a big deal on personal computers, but on servers it can be really bad. Most of the times you need to add your user to a group that owns the files in the package to use it.
January 19, 2023, 3:36pm
That is probably what I should have done to begin with. Will now better the next time.
January 21, 2023, 3:37pm
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.