Trying to delete the following file: ~/Library/Cookies/HSTS.plist
, but MacOS won't let me do it even when using sudo.
I just switched to Mac (was using Ubuntu before) and I'm probably missing something obvious. I'm using MacOS Mojave 10.14.1.
What could be wrong?
sudo rm -f ~/Library/Cookies/HSTS.plist
rm: /Users/dima/Library/Cookies/HSTS.plist: Operation not permitted
I can't run ls on the folder files:
ls -la ~/Library/Cookies/
ls: : Operation not permitted
Output of ls -lde@ ~/Library/Cookies
:
drwx------@ 11 dima staff 352 Dec 11 23:03 /Users/dima/Library/Cookies
com.apple.quarantine -1
I found out I can delete the file using Finder, but not using command line. Why is that?
Best Answer
I've had this problem before, too. I believe this is because of System Integrity Protection. macOS protects some parts of the filesystem starting with El Capitan.
I think there are two ways to work around this.
For the first, restart your Mac, but hold down Command-R until you boot into Recovery Mode. Then on the menu, select Utilities then type
csrutil disable
and press Enter. Reboot your Mac and try yourrm
command again. When you're done, I suggest you go back into Recovery Mode and re-enable it (csrutil enable
).For the second, open Security & Privacy in System Preferences. Click the Privacy tab, select Full Disk Access and add Terminal to the list of applications. You'll likely have to unlock that screen first by clicking the padlock at the lower left corner.
When I had this problem, I didn't know about the Full Disk Access trick and used the first option. I know it works. I just learned about the second option earlier today and I'm betting it does the trick, too.
Good luck!