Deleting protected folders in your Mac home directory

One day I was setting up my new Catalina (and later in Big Sur) OS on a fresh work Mac laptop and I discovered something fishy. I couldn’t delete my Documents, Pictures, Videos, and Music directories. Normally what I do on my Linux systems is create symlinks for those folders whose target is in a common directory that I can then sync onto my NFS server, or like in the case of my work laptop, into a corporate system. Be it Office365 OneDrive, or Box, or Amazon WorkDocs.

Ok, anyway I fought and fought with the Mac OS. Attempts to delete the folder were denied even though I have sudo access on the system:

% sudo rm -rf Documents
rm: Documents: Permission denied

So my hunt began. Turns out the culprit is SIP. Otherwise known as System Integrity Protection. It’s designed to help keep things setup the way they need to be for various aspects of the OS to work as expected. In some ways it kinda really annoys me because is the result of the whole Mac eco-system dependencies. So as Apple continues to force you to keep apps on your OS like News, Stocks, iTunes, etc, the OS has to work a little harder to make sure dependencies stay correct.

Cool, how do you shoot that shit in the head?

This is the link to the official documentation from Apple. But I will duplicate it here:

Restart your computer in Recovery mode.
Launch Terminal from the Utilities menu.
Run the command csrutil disable
Restart your computer.
Make your changes, then do all the previous in reverse using csrutil disable

I think it’s work noting that I was able to do everything I needed in just the one reboot to Recovery mode. Once in Recovery Mode and in a terminal, I could disable SIP, make my directory changes, then reenable SIP, and then reboot back in.

Hope that helps!