You'll need to start by getting root write access to /usr/bin/
. You'll need recovery mode or even a Live CD/USB. Both those approaches are covered here — just ignore the password setting bit.
By this point you should be logged in as root.
Anyway fixing this isn't too hard because most of the files are straight 755 and there are only a handful of exceptions. So we'll start by setting everything in there to 755 and correct the exceptions. This is based off my filesystem so I've probably got a few things you don't but running chmod
on a non-existent file shouldn't hurt.
chmod 755 /usr/bin/*
chmod 4755 /usr/bin/{{lp,g,}passwd,chfn,mtr,beep,traceroute6.iputils,pkexec,sudo,newgrp,ksu,chsh}
chmod 6755 /usr/bin/{X,at}
chmod 2755 /usr/bin/{mail-{un,touch,}lock,ssh-agent,mutt_dotlock,chage,bsd-write,wall,screen,crontab,mlocate,expiry,dotlockfile}
chmod 0755 /usr/bin/
This syntax is exact. You need to make sure it's entered correctly or it could break even more.
You could argue that this is too much to manually copy and paste. You might be right. We can handle the most important things and then reboot back into a graphical desktop to do the rest with sudo
:
chmod 755 /usr/bin/*
chmod 4755 /usr/bin/{sudo,pkexec}
chmod 2755 /usr/bin/crontab
chmod 6755 /usr/bin/X
chmod 0755 /usr/bin/
For anybody curious on how to generate a list like that, here are the commands:
find /usr/bin -type f ! -perm 755 -printf '%m %P\n'
That does only look at files but all the links I could find linked back through to /usr/bin/
files so they were already being dealt with.