Error zsh: permission denied in Terminal of MAC OS Sonoma 14.3.1

Hi,


I am trying to run a cmd file, either in the terminal or in Visual Studio. In both of them I get zsh: permission denied error.


I checked my access to the folder, I have read and write access. I am the only admin on this laptop.

Using ls -l command shows I have -rw-rw-r-- access to the file and folders. (I wonder if there should be an x there as well?)

Also the Terminal app and VS also have full access to the drive.

I also used command chmod 755, my rights remains the same.



Thanks for your support.

MacBook Pro 16″

Posted on Feb 20, 2024 11:14 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 20, 2024 12:24 PM

I think I solved it using


chmod +x <filename>


I found the solution here: https://youtu.be/416g7bsxMck


11 replies

Feb 26, 2024 3:39 AM in response to VikingOSX

VikingOSX wrote:

The chmod +x applies a 755 mask (e.g. rwx-rx-rx) to a file allowing the user full privileges, while group and other can only read and execute the file. When applied to a directory, then the x means search. The chmod man page is a good reference to these masks.

It is a good point to mention the man page for chmod. I do use man relatively frequently.


The +x adds the x capability. Whether this ends up as 755 or not depends on the previous state.


Having learned binary numbers long ago, I am more partial to using chmod in a direct fashion, e.g.,

chmod 755 myfile


instead of


 chmod a+x myfile


or similar. Habits one gets from using these for 40+ years.... 😎




Feb 20, 2024 11:31 AM in response to The_Point

The_Point wrote:

Hi,

I am trying to run a cmd file, either in the terminal or in Visual Studio. In both of them I get zsh: permission denied error.

I checked my access to the folder, I have read and write access. I am the only admin on this laptop.
Using ls -l command shows I have -rw-rw-r-- access to the file and folders. (I wonder if there should be an x there as well?)
Also the Terminal app and VS also have full access to the drive.
I also used command chmod 755, my rights remains the same.


Thanks for your support.


what command?


Old issue, new issue, what changed?


Is Terminal.app included in the Full Disk Access?

ref Controlling app access to files in macOS


Feb 20, 2024 11:46 AM in response to leroydouglas

Thanks for your reply.


It's not a command it's a .cmd file that I am trying to run by entering it this way in my terminal

./rest-test.cmd


When I used ls -l it printed:

-rw-rw-r--@ 1 <myusername> staff 224 Jan 11 11:48 rest-test.cmd


The group name staff in this line caught my attention because I am logged in as admin. I used chown -R command but it remains unchanged.


Hope that sheds some light.

Feb 20, 2024 12:50 PM in response to The_Point

Ordinarly Bash shell scripts have .sh extensions and Zsh scripts have .zsh. You can also put the contents of either script in a file that ends with .command, and that is double-clickable from the Finder, launches Terminal, runs the script, and then quits that Terminal session.


Although, you can end a script in .cmd, make it user executable, and then run it, your choice of a .cmd extension will confuse some people, and isn't normally used in a UNIX operating system — which is macOS.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Error zsh: permission denied in Terminal of MAC OS Sonoma 14.3.1

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.