Categories
Mac

Delete undeletable files on OS X

Today I found myself stuck: I couldn’t delete a directory from my Mac, no matter what I tried, sudo or not.

Undeletable file
Turns out, for some reason the schg flag was set on that folder. schg, or “system immutable” flag, prevents even root from doing anything with that file. Fortunately, root is allowed to remove that flag, and then delete the file.

sudo chflags noschg undeletable_file_or_folder
sudo rm -rf  undeletable_file_or_folder

Problem solved.

(Always be careful copying and pasting sudo rm -rf commands from the internet.)

One reply on “Delete undeletable files on OS X”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.