I accidently ran
sudo chmod 755 -R /
sudo chmod 755 -R ./
I stopped it after few seconds, but now there is some problems such as
sudo: must be setuid root
How can I revert permissions back?
In short: you can't, reinstall your system.
I mean, Posix permissions are used and relied on heavily; there's a multitude of places in the filesystem where wrong permissions would break the OS (SUID flags) or even worse, make it exposed security-wise (
Hence, such a recovery is hard to do properly. Miss one thing — and you screw it up. You already screwed up your
So trust me, just reinstall. It's a safe bet and guaranteed to keep you out of trouble.
Finally, two tips might be relevant here.
First: reinstalls will be less painful if you setup your
Second: consider doing crazy Linux science in a virtual machine like the VirtualBox, and do your snapshots.
I wrote and have been using for several years a couple of Ruby scripts to
You can run
You will need to have root so fix your
I can generate and give you the
In long: you can. You'll need to mount the the file system from the a Live CD and begin reverting the permissions in the appropriate places. At a minimum to get sudo back you'll want to run
However, it would likely be easier to simply reinstall the system.
I would try to reinstall all packages with
Alright, I haven't tested this (so use at your own risk), but it still might work. I Will test this in a virtual machine when I get the chance to:
First, in a still working system, I did the following to get all file permissions in a list, skipping the
This will print the permissions and file name for each file or directory on the system, followed by a
Then, on a system where the file permissions have been compromised:
This will read each line of
A few things to note here:
What I would suggest is boot up a LiveCD with the Linux version you have on your disk, run the command, modify the path to where you have the local disk mounted, and run the second command!
I have tested that when booted from an Ubuntu CD/USB, I can choose not to format disk, meaning it will replace everything in the