If I run:
sudo chown -R user:user /
Can I revert it to what it was before I ran it?
In short: no.
You'll need to restore from a backup. (Some backup tools might have options to only restore only permission, others can list backed-up files with their permissions and you can use that to fix your system.)
If you don't have a backup, you'll need to fix all that manually.
Only if you know the user and group ownership of every file and directory under your
Even then, you've already clobbered the ownership of critical system files that need to be owned by root, including the
Make a copy of the entire hard drive if you can, then reinstall your operating system. Once you've done that, you can try copying files back to the newly wiped system and restoring their ownerships. You can probably assume (though not 100% reliably) that everything under
And then start cultivating a habit of double-checking any command you run under
You can store the current versions and then parse that out to revert by using the -v option.
The contents would be:
Using your favorite scripting language and regular expressions, you can execute the painful process of reverting them (if you must).
I'd strongly recommend not doing a recursive chown on / as you'll expose /etc/shadow or any other important file.