How to reset to default permissions on El Capitan

During development and debugging I have changed permissions of various files and folders using chown and chmod on my local system (I didnt maintain the list of changes). Now that I have fixed the issue, i fear of security consequences. Any way I could restore the default permissions and/or find vulnerabilities in terms of network security or other potential loop holes that might create due to my changes.


Solution 1:

For system installed packages you can run the following command in Terminal.app to find permissions that differ from the default:

sudo /usr/libexec/repair_packages --verify --standard-pkgs /

If you want to just apply those permissions to your system as a whole, run the following command:

sudo /usr/libexec/repair_packages --repair --verify --standard-pkgs /

Or you could individually fix the permissions that you have changed yourself using chmod/chown.

For everything else, you need to have used either a package manager that can verify permissions, or have a backup you can use for comparing permissions before and after the event.

For others: Please note that the repair_packages command no longer exists in Sierra and newer macOS versions, as they now automatically handle repairing permissions. If you have manually messed up permissions so much that they cannot be fixed automatically, I would recommend restoring permissions from a Time Machine backup or similar.

Solution 2:

It depends on your OS.

Yosemite

  • Use Disk Utility to reset System permissions.
  • Reset Home folder permissions & ACLs using OnyX - Maintenance tab/permissions, tick the box at the top then Execute.
  • For belt & braces, apply [or-reapply if already up to date] 10.10.5 using the 10.10.5 combo update, not the delta from App Store

El Capitan

  • Reset Home folder permissions & ACLs
    This has become more complex since El Capitan because of System Integrity Protection, but is still possible by booting to Recovery Mode...

    1. At boot, hold Cmd ⌘ R at the chimes
    2. At the recovery screen, open Terminal from the Utilities menu.
    3. Type in resetpassword and hit Return\Enter. A Reset Password window opens.
    4. Select your username from the drop-down menu labeled Select the user account (NOT System Administrator/root).
    5. Click the Reset button at the bottom of the window in the Reset home folder permissions and ACLs section.
    6. Quit the Password Utility and go back to the main recovery screen.
    7. On your keyboard, press Cmd ⌘ Q and restart your computer (or Select  > Restart from the menu bar). It's very important that you don't hold down the power button to exit the recovery session, or the ACL reset won't be performed.
  • For belt & braces, apply [or-reapply if already up to date] 10.11.5 using the 10.11.5 combo update, not the delta from App Store