I accidently ran
sudo chmod 755 -R /
instead of
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?
|
I accidently ran
instead of
I stopped it after few seconds, but now there is some problems such as
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, some tips 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. Third: |
|||||||||||||||||||||
|
|
You can try restoring permissions with If you can not run these commands with sudo you may need to boot to recovery mode and run them as root. For booting to recovery mode see https://wiki.ubuntu.com/RecoveryMode. From http://hyperlogos.org/page/Restoring-Permissions-Debian-System Note: This was originally posted on the Ubuntu Forums but I can not find the original post. Try, in order,
If that fails:
And finally, as a last resort,
Using apt-get Here's the relevant snip, EDITED FOR CORRECTNESS and reformatted:
|
||||
|
|
|
(I know I shouldn't comment in an answer, but not enough reputation to comment.) blade19899's answer worked for me except for symlinks. E.g. it applied 755 to /bin/bash, but then applied 777 to the symlink /bin/rbash, effectively 777-ing /bin/bash. As I already had the fileper.log file, I just modified the destination-end command:
|
|||||
|
|
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 |
|||||||||||||||||
|
|
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
|
|
|
|||
|
|
|||
|
kinda an overkill... find does that quite nicely:
find SOME_DIR -depth -printf 'chmod %m %p\n' > saved_permission
– reflog
Jul 16 '15 at 7:17
|
|
I would try to reinstall all packages with |
|||||||||||||
|
|
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. |
|||
|
|
sudomeans, that you have think twice what you will do! – antivirtel May 18 '11 at 13:37Upgrade from Ubuntu 11.04 to Ubuntu 11.04. Accept this option, and it will effectively re-install Ubuntu for you, in the most painless way. – user4124 May 18 '11 at 17:18/in the end of directory name to specify the directory as a target. It's a bad habit, don't do it, never! The.is by itself valid directory name, there is no need to append/to it. If everyone followed this rule, then very much mistypedsudooperations would have no effect on the root directory, so no harm would've been done to their systems. Don't do it! – ulidtko May 18 '11 at 19:10cd ., for example, does nothing.ls .is the same asls. Also, the..is a directory name which means "the parent of.", and you probably knew it already. – ulidtko May 18 '11 at 19:24/at the end. If you want to do pathname expansion for directories only. Example of listing directories inside the current directory:echo */– pabouk Nov 15 '13 at 9:16