Ubuntu – 12.04 LTS won’t boot after modifying root directory permissions

12.04boot failurechownpermissionsroot

I accidentally changed permissions to root directory on my system and now my system won't boot, I tried to fix packages from grub recovery and check file system but nothing.
Here's the code I accidentally typed:

     sudo chown -hR jmayerz:jmayerz /

After it executed, X11 shut down and system got stuck, so I rebooted and it won't boot again.
I tried changing back permissions to system superuser from liveCD but how can I change it to the user on the machine itself not the liveCD?
like this:

     sudo mkdir /media/mount
     sudo mount /dev/sda1 /media/mount
     sudo chown -hR <user which originally owns root on the machine itself not liveCD, I think root user> / 

How would that last line be executed?? which user is it?? and how is this executed from livCD?

When I try to use that method in recovery, it tells me that files are read-only, when I try to perform tasks that mount root in read-write it still doesn't do it.

     mount -ro remount,rw

says that /etc/fstab reports that directories are already mounted.

     chown -hR root /

says that files are in read only mode, after mounting read-write through doing something like fixing packages, it doesn't output anything.

     chmod -hR jmayerz:jmayerz /home/jmayerz/

same thing.

And now the liveCD won't boot, says general filesystem mount error.

Best Answer

There's always a user called root in Ubuntu, and its User ID is always 0. When using chown you can specify either user name or user ID, so I suppose both of the following commands should work when booted from a LiveCD:

chown -hR root:root /media/mount
chown -hR 0:0 /media/mount

after which I think you'll need to change the ownership of home directories - you'll have to use user IDs in this case because users from your machine do not exist when booted from LiveCD. You can see what was the user IDs of the users in your system by looking into /etc/passwd on the hard disk (so, in your case it'll be something like /media/mount/etc/passwd)

Related Question