Revert chmod 777 / -R

chmoddirectoryrecursive

while executing a command i made a mistake and executed (ubuntu 10)

sudo chmod 777 / -R # okay you may laugh

now all my filesystem has 777 permitions , obviously i dont know which where the permitions for every folder and file in my 1TB drive šŸ˜€

is there anyway i can revert this ?

Thanks in advance !!!

Best Answer

Wow... that's pretty bad... The best thing you can do now is back up your personal data and reinstall your system.

Since that's probably not what you wanted to hear, the second best (and probably substantially more painful) thing to do is something like:

for package in `dpkg -l | awk '{print $2}'`; do
    apt-get install --reinstall $package
done

Note that this fix is purely theoretical (I've never tried it), but it will reinstall every package on your system (because as far as I can tell apt and dpkg don't have a "fix permissions" function like RPM). Reinstalling should fix the permissions on all the files that are in packages.

This "fix" may break other things, and you will probably still have some 777'd files floating around that aren't part of any packages, so you should follow up by finding all the stuff that's mode 777 and making sure the list looks sane.

Related Topic