Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :D

is there anyway i can revert this ?

Thanks in advance !!!

share|improve this question
Which particular OS? – Ignacio Vazquez-Abrams Feb 10 '11 at 10:00
Finaly i recover my data booting in recovery mode... – user70247 Feb 22 '11 at 10:44

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

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.

share|improve this answer
See also the question Cakemox pointed to in their comment above ( looks like the same advice can be found there. – voretaq7 Feb 10 '11 at 16:24

Try the following command

rpm --setperms $(rpm -qa)

This will reset all permissions to the defaults stored in the rpm database.

Or, if you want to go package by package and get some more output, try:

for p in $(rpm -qa) ; do echo "$p" ; rpm --setperms $p ; done

This will only revert files installed with rpm, not other files you created manually, or in your /home or installed in another way other than as an rpm package.

If you have a full backup, then you can get the permissions from there.

share|improve this answer
rpm on Ubuntu? – Ignacio Vazquez-Abrams Feb 10 '11 at 10:19
ups, sorry, was too fast. Doesn't apt have a similar option? Forgot that Ubuntu was debian based, sorry. – rems Feb 10 '11 at 10:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.