1

I changed the permissions of /usr in Ubuntu to 700.

Graphics are not working. In a tty I have no access to sudo to change permissions back again.

I tried to access root from 'advanced boot option' and run the command chmod 755 /usr but it said something like 'read only file' and the permissions didn't change.

One of my friends also tried by mounting the drive and changing owner, but nothing seems to be working.

  • When in recovery mode ('advanced boot options') the root filesystem is initially mounted read-only: you will need to remount it in read-write mode first mount -o remount,rw / then chmod 755 /usr. (NOTE: both mount and chmod are in /bin so shouldn't be affected by bad permissions on /usr). – steeldriver Aug 20 '16 at 13:34
1

Unfortunately, you removed group permissions and all other permissions. And you did it to just about every program that your system uses to boot and draw the GUI. You also nuked the terminal emulator. Unless you have an image that you can restore from, I think you're going to have to re-install the OS.

  • It looks like they didn't do recursive chmod, in which case it's not so bad – Zanna Aug 20 '16 at 6:50
  • Well, the OP still has stuff under /bin and TTY is always available. – Sergiy Kolodyazhnyy Aug 20 '16 at 6:55
1

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:

  1. 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.

  2. 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
    
  3. Check the current permissions

    ls -ld /usr
    
  4. 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 chowned : chown libuuid /usr/sbin/uuidd

  1. change the permissions (NOT USING -R)

    sudo chmod 755 /usr
    

Again, please please do not use the -R flag

  1. 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
    
  2. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.