I accidentally typed out this command, not knowing exactly what it did:
sudo chown -R user:user /
Now when I type
ls -la /, it shows that user has permission to all directories (before it showed root only).
How do I revert it back to root?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
This is messed up very badly.
cd / chown root:root -R bin boot cdrom etc initrd.img* lib lib64 lost+found mnt opt root run sbin srv tmp usr var vmlinuz* # essentially everything except home and media chown root:root home media # we don't want to recursively chown here.
I assume you have a root shell open somewhere. If not, try
pkexec chown, since
sudo won't work when
/etc/sudoers has incorrect permissions/owners.
Then there are various folders in
/var whose correct owners you'll have to set, but that depends on which programs you have installed and which services you need to run.
If you're not able to run a command, or some other errors happen, try this from a bootable live USB (after mounting the root partition somewhere and replacing
cd / with the path of the mount point).
Note that I have skipped a few directories, such as
proc, as these are directories populated by the kernel.