ls: .: Operation not permitted - Mac 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 on the desktop.
Security and Privacy Option
Security and Privacy Option
Select the 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.

Copyright Β© Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap