Trouble accessing /usr files on terminal

Hi all. I am trying to access and open /usr files from the terminal. Keep getting the following:

zsh: permission denied: /usr

Things I have tried so far:

  1. Went to system preferences and granted terminal full disk access
  2. Went to /usr folder physically and checked that it is not "locked"
  3. Checked that my usernames does have read write permission
  4. Tried changing the ownership to my username anyway
chown -R $username:$username /usr


Still stuck and unable to access. I would like to access it because down the line, some other applications have dependencies present in /usr/local/bin and was having trouble at the time. Thanks!

MacBook Air 13″, macOS 14.2

Posted on Dec 16, 2023 3:36 AM

Reply
Question marked as Top-ranking reply

Posted on Dec 16, 2023 4:23 AM

You are attempting to modify a folder containing operating system commands located on the read-only System volume and that cannot be done on macOS Sonoma.


When you place applications in /usr/local/bin that cause namespace collisions with applications included in the operating system, and you want to access those /usr/local/bin applications first, you change your PATH statement in your shell dot file to access /usr/local/bin before $PATH.


export PATH=".:/usr/local/bin:${PATH}"


Now, if for example, I install the complete Zsh shell in /usr/local/bin, it will be accessed and run without collision with /bin/Zsh installed by macOS.



The fact that you thought you could alter permissions of a key part of macOS instead of the above suggests to me that you have much to learn about the Terminal UNIX command line, and you should not be using it without more knowledge of command consequences.

Similar questions

5 replies
Question marked as Top-ranking reply

Dec 16, 2023 4:23 AM in response to skt29

You are attempting to modify a folder containing operating system commands located on the read-only System volume and that cannot be done on macOS Sonoma.


When you place applications in /usr/local/bin that cause namespace collisions with applications included in the operating system, and you want to access those /usr/local/bin applications first, you change your PATH statement in your shell dot file to access /usr/local/bin before $PATH.


export PATH=".:/usr/local/bin:${PATH}"


Now, if for example, I install the complete Zsh shell in /usr/local/bin, it will be accessed and run without collision with /bin/Zsh installed by macOS.



The fact that you thought you could alter permissions of a key part of macOS instead of the above suggests to me that you have much to learn about the Terminal UNIX command line, and you should not be using it without more knowledge of command consequences.

Dec 16, 2023 6:28 AM in response to VikingOSX

What I really wanted to post and the hosting system blocked:


Ok, now I understand. Here is how /usr/local is permitted on my macOS Sonoma 14.2 system:


drwxr-xr-x 17 root wheel 544 Dec 11 14:39:03 2023 local


And /usr/local/bin will have permission:


chown $USER:admin /usr/local/bin


What I said earlier about the PATH remains true, especially if you had installed the Xcode Command Line Tools whose Python3 interpreter is installed in /usr/bin. Python3 installed using a Python.org installer goes into /usr/local/bin as a link back to its framework library binaries in:


/Library/Frameworks/Python.framework/Versions/3.12/bin

Dec 16, 2023 7:55 AM in response to skt29

What VikingOSX is most of the usual cases. But… Depending in exactly what you are doing here, you might also need to enable Full Disk Access for the apps involved.


While many parts of macOS are and will remain blocked, access to other areas of a macOS install will require the app have full disk access—full disk access itself being a misnomer, as various parts are well sealed against access—and this access must be enabled for any apps needing that access.


Apps can’t themselves enable full disk access. Only the user via GUI, or managed or supervised via an MDM profile loaded.


There’s another wrinkle here for prohibited storage access too, with a not-publicly-documented data vault and app entitlements. Which can cause issues for third-party backup tools and file search tools. That case is not involved here, though.


This full disk access how-to-enable sequence described in a slightly different context:


Use the systemsetup command-line utility on macOS Catalina 10.15 - Apple Support


Dec 16, 2023 4:53 AM in response to VikingOSX

Hi thanks for the help. I wasn't exactly trying to modify /usr

I was trying to access /usr/local/bin to be precise, not sure why I did not mention that. But /usr/local/bin has some files I need to be able to access (python, R script)

I think I should be able to access /usr/local/bin given the loads of guides I find on cleaning up, uninstalling CLT and Homebrew and reinstalling them again.

Also I should atleast be able to access /Users/username/ on the terminal right?

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.

Trouble accessing /usr files on terminal

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