Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I accidentally did this:

chmod -R 777 /

I suppose to do this:

chmod -R 777 ./

I feel really bad now. How can I reverse this??

share|improve this question

migrated from stackoverflow.com Aug 23 '13 at 15:29

This question came from our site for professional and enthusiast programmers.

    
Don't feel bad. It'd have been worse if you did sudo chmod -R -x /. –  devnull Aug 21 '13 at 14:39
1  
There are two kinds of people in the world. Those who have destroyed a file system running as root -- and those who haven't done it yet. Don't run as root ;) –  Jeremy J Starcher Aug 21 '13 at 14:40
    
At least now I feel no sleepy no more. Again, GOD! –  Jusfeel Aug 21 '13 at 14:44
2  
See this answer. –  Kevin Aug 23 '13 at 15:45
1  
chmod -R 777 ./ would have been wrong too. It is extremely rare to need to set files to mode 777. I can't think of ever needing to set a whole directory hierarchy to mode 777. chmod -R a+rx . or chmod -R u+w . are common. chmod -R 777 . was a mistake from the start. –  Gilles Aug 23 '13 at 16:22
show 4 more comments

1 Answer

up vote 3 down vote accepted

short version: You can't. Unless you have a backup or similar which lists the permissions of all your files, you don't know what the files need to be.

share|improve this answer
    
God. Won't CentOS provide some tools to do permissions...RESET or some sort? –  Jusfeel Aug 21 '13 at 14:39
    
Sorry, no, there isn't. –  Oliver Matthews Aug 21 '13 at 14:43
3  
for allpkg in $(rpm -qa); do rpm --setperms $allpkg; done resets file permissions for all installed packages. This does not help with user files... –  Roland Jansen Aug 21 '13 at 14:46
1  
@Jusfeel There is a tool to reset permissions. It's called restoring from a backup. If you want to avoid some data copying, it's possible to restore the permissions while leaving the data in place. How to do that depends on what backup tool you used. –  Gilles Aug 23 '13 at 16:19
add comment

Your Answer

 
discard

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.