sudo chmod -R 777 /

9

2

 sudo chmod -R 777 /

I did this. It was a mistake. Is there any way to undo it?

Basically it's messed up more things than I can list. I don't have time-machine enabled on my mac.

Casey Flynn

Posted 2011-06-22T18:04:54.960

Reputation: 223

Serious question man, is there any way to undo it. – Casey Flynn – 2011-06-22T18:07:19.190

3777 permissions are almost never the answer to any permissions problem. It might get you past a hiccup, but it is seldom a good idea, even when restricted to a directory deep in your disk system. It is a catastrophe when applied to all files and directories under root, not least because it attempts to remove SUID bits from programs such as 'sudo' that need them. Don't do it again! (Many Unix users can regale you with a story of an analogous mistake; I won't bother you with mine, but the backups of the system saved the day, and it wasn't me who typed the command that achieved the rm -fr /.) – Jonathan Leffler – 2011-06-22T18:20:02.207

2Let this be a lesson to everyone about why sudo goes on about "think before you type" the first time you use it. ;-) – Scott – 2011-06-22T21:05:55.960

Do a ls -lR / >list on a healthy system (or ask someone else for a list). You could automate this process to re-set the permissions (if this Dirk Utility Repair won't work). – ott-- – 2011-10-21T17:38:20.977

Tab Auto-complete saves lives ;3 – hwshadow – 2013-05-18T08:27:05.187

Answers

9

Take a look at Apple's Disk Utility's Repair Disk Permissions feature:

http://support.apple.com/kb/HT1452?viewlocale=en_US

kylex

Posted 2011-06-22T18:04:54.960

Reputation: 575

1This won't undo your changes, but it should fix most of the issues due to improper permission settings. – kylex – 2011-06-22T18:08:58.660

Will this repair my 'sudo' program? – Casey Flynn – 2011-06-22T18:39:47.887

@Casey - What is the issue with sudo? sudo just allows you to run a command as root. ie. bypasses many security restrictions. – kylex – 2011-06-22T19:15:21.567

1@kylex: it probably refuses to work since /etc/suoers is worldwritable :) Good thinking – sehe – 2011-06-22T19:39:58.810

4Sudo probably refuses to work because it needs the suit bit set and by recursively changing everything to mode 777 the OP has stripped the suid bit on sudo (and all other privileged programs). Without the suid bit set, sudo cannot gain elevated privileges and hence cannot grant you access other than that which you already have. Unless Disk Utility has an alternative mechanism for gaining elevated privileges, Casey will probably have to arrange to log in as root. – larsks – 2011-06-22T19:44:50.617

4

From http://support.apple.com/kb/HT2963:

Using the Repair Privileges Utility

Most users of Mac OS X have not intentionally modified privileges and simply need a utility to reset system privileges to their correct default values. If you have Mac OS X 10.2 and later, this utility is included in the operating system. If you have Mac OS X 10.1 you can download it. For versions 10.0 to 10.1.4, you must update to version 10.1.5 first.

For Mac OS X 10.2 or later, open Disk Utility (/Applications/Utilities/). Select your Mac OS X startup volume in the column on the left of the Disk Utility window, then click the First Aid tab. Click the Repair Disk Permissions button. You may see an erroneous message.

sdolgy

Posted 2011-06-22T18:04:54.960

Reputation: 251

3

You're in luck:

It won't fix everything, but it will fix everything that's listed in the bill of materials file for an installed package.

Tom Anderson

Posted 2011-06-22T18:04:54.960

Reputation: 1 341

0

Repair permissions includes files that were created by an OS X installer (like /etc/sudoers), but it doesn't include files that were not preinstalled or not created by packages.

It's probably easier to back up everything, do a clean reinstall, and restore files selectively from the backup (or backups). You can restore 644 / 744 permissions with find:

find /Volumes/Second\ Backup -type f -exec chmod 644 {} \+
find /Volumes/Second\ Backup -type d -exec chmod 744 {} \+

If you can't back up files, try starting up from a recovery partition (or installation media in 10.6 and earlier) and cloning the main OS X drive from Disk Utility.

Lri

Posted 2011-06-22T18:04:54.960

Reputation: 34 501

-1

If there are some tools to revert the permissions, and people are suggesting it, you better first go with it, sudo chmod -R 777 / otherwise you may do is revert all the permissions to some safer level like

chmod -R 644

and then change the permissions to required level, when there is a conflict.

-

But its not a good way though. Just some safer approach to prevent screwing up with your files, before anything worse can happen. :(

Dhruba Adhikari

Posted 2011-06-22T18:04:54.960

Reputation: 101

2chmod -R 644 will make all directories non-searchable. It would be difficult to recover from that. – Keith Thompson – 2011-10-21T18:26:15.280