Tuesday, April 22, 2025

Fix the "ls: Operation Not Permitted" Error on Mac

Recently, I encountered an issue when trying to execute the ls command in Terminal. This is a commonly used command to display the contents—files and directories—within a specific path. I need to know what's there before I do anything.

ls Error

  1. MyMac-MBP13:~ auser$ ls
  2. Applications Untitled.html
  3. Desktop downloadtemp
  4. Documents iCloud Drive (Archive)
  5. Downloads iCloud Drive (Archive) - 1
  6. Library iCloud Drive (Archive) - 2
  7. Movies test
  8. Music test.aiff
  9. Pictures test.html
  10. Programming tmp
  11. Public vc.swift
  12. Sites
  13. MyMac-MBP13:~ auser$ cd ~/Library/Application\ Support/MobileSync/
  14. MyMac-MBP13:MobileSync auser$ ls
  15. ls: .: Operation not permitted
  16. MyMac-MBP13:MobileSync auser$

After searching online, I discovered that this issue is due to a security enhancement introduced by Apple in the latest macOS: System Integrity Protection (SIP). By default, the Terminal app does not have the privilege of Full Disk Access. My current macOS version is Sequoia 15.3.2.

Change System Settings

According to a solution on the CleanMyMac blog titled “How to fix the ‘ls: .: operation not permitted’ error in Terminal,” I needed to adjust a setting in System Settings.

Initially, when I navigated to Privacy & Security, I couldn’t find the Full Disk Access option.

I wasn’t sure where the setting was—until I tried searching for “Full Disk.”

I turned it on.

The hidden setting was revealed. As expected, Terminal did not have Full Disk Access by default. I enabled it by entering my admin password. Now, the ls command works anywhere in the console, after re-opended.

  1. MyMac-MBP13:Application Support auser$ ls Mob*
  2. Backup
  3. MyMac-MBP13:Application Support auser$

Revert the Setting (Optional)

I believe Apple’s SIP is a great safety feature. After finishing my work in Terminal, I turned off Full Disk Access for the Terminal app to restore the default setting. I’m writing this blog post for future reference, in case I need to do similar work in Terminal again.

References

Other Blogs

No comments: