Skip to content

Instantly share code, notes, and snippets.

@chase2981
Forked from kennwhite/reset_osx_attributes.sh
Created November 19, 2021 07:27
Show Gist options
  • Save chase2981/39678d35c88017c1d9676603cd8a5c64 to your computer and use it in GitHub Desktop.
Save chase2981/39678d35c88017c1d9676603cd8a5c64 to your computer and use it in GitHub Desktop.
Remove all extended attributes recursively on an OSX directory & files and fix "chown: ... Operation not permitted" and "chmod: ... Operation not permitted"
# This is the nuclear option. Use with extreme care
# Works up to and including Mountain Lion (10.8.x)
# Show all extended attributes
ls -lOe ~/dir-to-fix
# Remove no-change attributes
sudo chflags nouchg ~/dir-to-fix
# Recursively clear all entended attributes
sudo xattr -rc ~/dir-to-fix
# The reset to rational owner & perms
sudo chown -R username:staff ~/dir-to-fix
sudo chmod -R 0700 ~/dir-to-fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment