See Also:
Why is “chmod -R 777 /” destructive?
I changed file permissions recursively on the root directory / by executing sudo chmod -R / 777, and after that my system won't boot (I'm getting a lot of "permission denied" errors).
Please help.
I changed file permissions recursively on the root directory Please help. |
|||||
|
|
You're looking at a lost cause. Save the data you need, and reinstall the operating system. |
|||||||||||||
|
|
I know dpkg stores the permissions in the databases and I found the following script google which may help. Edit: I actually had a quick look at the script and it looks as if it is missing a bit of magic that goes from PERMS to MODE eg dpkg -c gives for example "-rw-r--r--" but you want 0644, I am at work right now so I am not sure I have the time to do the conversion at this instant but I may come back later if no one else has jumped in to add that bit. There is a script here which is looks interesting
|
|||||
|
|
It is possible to come back from such a messy situation, without reinstalling the system. Well, more exactly running a fresh new system either from an USB key or in a Virutal Box (or so) if you have a dual boot system. I ran again the same kind on issue (some bug in a script I was writing) and solved it, but you need to ask some expert's help. Be very cautuous! First, my situation was easier to solve because I had a dual boot system (ubuntu and my old fedora install), but running the system for a USB key (or maybe a CD/DVD) should do the same thing. MPOINT=/mount/ubuntu First I mounted my file systems like this (don't forget to create the mount points): mount /dev/ubuntu/root $MPOINT mount /dev/ubuntu/home $MPOINT/home Then I ran the following command (my issue was only in a few - critical - directories) to copy the permissions on from the running system to the messy one (in fact, in my case, I installed an ubuntu system in Virtual Box under fedora and got the permissions there): find /etc /usr /bin -exec stat --format "chmod %a ${MPOINT}%n" {} \; > /tmp/restoreperms.sh And then I ran the restoreperms.sh script. I was able again to boot on ubuntu. The content of restoreperms.sh will be something like:
I didn't test it but it must work for owners and owner groups too. Something like: find /etc /usr /bin -exec stat --format 'chown %U:%G ${MPOINT}%n' {} \; > /tmp/restoreperms.sh^
Of course, you have to take care here, that the UID and GID are the same on both systems, but for the system related users and groups, this shouldn't be an issue. Rk: An important thing for this is to keep an install disk synchronized with the version you are using, or at least work with the current ubuntu version. Now, I have this commands in a cronjob, running every day (could be weeks) in order to keep that information. It will make the solution easier next time but, of course, as I have this now, it will never happen again. ;-) Something like this:
EDIT: to support links, the combined command is:
|
||||
|
|
|
I modified the script from above and it's looks like this:
|
|||
|
|
|
Agree with blueben, just reinstalling might be faster than analyzing which file/directory needs which permission. But if reinstalling is not an option, here's an idea:
|
|||
|
|
|
ERRATUM to my post posted as user user100740: to support links, the combined command is:
|
|||
|
|
|
If you can still launch Sort the packages by status (installed packages at the top), select all the installed packages, right click and select reinstall. Then apply, that will prompt It may not get everything fixed though. |
||||
|
|
|
boot from live CD. then start shell, then sudo -s. Then chmod 777 /*, then chmod 600 /etc/passwd. kernel will panic if init fails which will happen if /lib/init scripts are not executable. boot to single user mode, for Lilo Linux 1, and run user102453's script above. This gets sytem boot to prompt. Still need to get X running. |
|||||
|
|
Setting the permission of / to 755 worked for me. So check first with
Permissions should be "drwxr-xr-x" (755). |
|||||||||
|
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?