Messed up /usr/bin permissions

While installing Ruby/Jekyll and following ‘advice on internet’ I messed up the permissions on /usr/bin/, so now can not use sudo command.

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!

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.

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.

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.

1 Like

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.

Press ctrl+alt+f3 after the system has booted.

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.

2 Likes

That is probably what I should have done to begin with. Will now better the next time.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.