If you boot in recovery and get given a menu where you can enable networking (this option mounts the file system with read write permission), then enable networking and then choose the option to enter a root shell and skip to step 3 - you can omit sudo
on the commands in this case. If you boot in recovery and don't get this option, then it won't work because you have to use sudo
to remount as read-write and you cannot use sudo
, so in that case:
If you don't have the networking & root shell recovery option, then boot into a live session (get that friend to make you a live USB if you don't have one) and mount your installation:
Find the root partition with sudo fdisk -l
. It will be the biggest one if you don't dual boot and most likely have an ext4 filesystem.
Mount the partition, using the actual name of your root patition instead of /dev/sdxY
and cd
to the mountpoint:
sudo mount /dev/sdxY /mnt
cd /mnt
Check the current permissions
ls -ld /usr
Change the owner back to root if it is not root:
sudo chown root:root /usr
Check whether your friend used -R
by doing ls -ld /usr/bin
and if it says root is the owner, then do nothing more and go to the next step. If your friend used -R
then you must use sudo chown -R root:root /usr
to correct it here. root should be the owner of everything in /usr
except /usr/bin/at
which should belong to daemon
so if you used chown -R root:root /usr
then afterwards do chown daemon:daemon /usr/bin/at
(I checked this using the clever find command from this answer... if you have /usr/sbin/uuidd
that should also be chown
ed : chown libuuid /usr/sbin/uuidd
change the permissions (NOT USING -R)
sudo chmod 755 /usr
Again, please please do not use the -R
flag
a. Assuming you did not use the -R
flag in the first place, you've fixed it now. If you did use the -R
flag, then it might be easier to back up your /home
stuff safely and reinstall, but for now fix sudo
which needs the setuid bit (octal 4):
sudo chmod 4755 /usr/bin/sudo
If running a live session, cd
out and unmount the partition:
cd /
sudo umount /dev/sdxY
and reboot back into your system. Now you have sudo
, and chmod
is in /bin
so you can use sudo chmod
to fix broken permissions on anything else you need in /usr for whatever you want to do next, but make sure you know exactly what you are doing (read some stuff, for example this and this) when using chmod
(read and avoid using the -R
flag - if you clear the setuid bit from sudo
you will break it again.
mount -o remount,rw /
thenchmod 755 /usr
. (NOTE: bothmount
andchmod
are in/bin
so shouldn't be affected by bad permissions on/usr
). – steeldriver Aug 20 '16 at 13:34