Super User is a question and answer site for computer enthusiasts and power users. 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

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 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
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! – Hao Aug 21 '13 at 14:44
See this answer. – Kevin Aug 23 '13 at 15:45
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
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? – Hao Aug 21 '13 at 14:39
Sorry, no, there isn't. – Oliver Matthews Aug 21 '13 at 14:43
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
@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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .