ls: .: Operation not permitted - Mac Big Sur Terminal Zsh Error

Recently when I tried to run ls command in the Mac Terminal Zsh shell on macOS Big Sur, I got the below error,

code2care@mac % ls
ls: .: Operation not permitted

This was really weird, I was able to fix this issue by following the below steps,

  1. Click on the Apple logo on Menu Bar,
  2. Select System Preferences...
  3. Click on Security & Privacy,
  4. Select Files & Folders,
  5. Under - Allow the Apps below to access files & folders, look for terminal and check - Desktop Folder, you will get the below alert,
    "Terminalโ€ will not have access to files on your desktop until it is quit. 

    You can choose to quit โ€œTerminalโ€ now or do it on your own later.
  6. Click on Quit & Reopen
  7. You will not be able to access ls and other commands in desktop.
Security and Privacy Option
Security and Privacy Option
Select Desktop folder from Files and Folders
Select Desktop folder from Files and Folders

โœ๏ธ You can get such an error while trying to access Network volumes, Download, or Documents folder if the option in Files and Folders is unchecked for Terminal.

Try Out Code2care Dev Tools:


Android Java Linux Microsoft Google Python macOS Notepad++ Microsoft Teams CSS PHP SharePoint Html Linux C Programs Bootstrap jQuery Sublime Android Studio Facebook Eclipse WhatsApp News MySQL Json HowTos JavaScript FTP S3


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
๐ŸŽ‰ We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
We strong support Gender Equality & Diversity.

We stand in solidarity with Ukraine - Make a donation to UNHCR -