How to add a file to /usr/bin so I can access this from any folder via Terminal?

Hi,


I'm wanting to add a file to /usr/bin. It's an assembler that I'm using to code with using Terminal.

I could put it in each folder where I store my code, but I thought it would be easier to put it in /usr/bin so it would only need to occur once. But I get permission errorns when I try to do this.


Can anyone help? Is it the /usr/bin folder I should be adding it to so I can access this command in any folder via Terminal?


Thanks

MacBook Pro (M1, 2020)

Posted on Jul 14, 2023 7:57 AM

Reply
Question marked as Top-ranking reply

Posted on Jul 14, 2023 8:13 AM

The /usr/bin location on Catalina and later is now on a read-only System volume that disabling SIP will not gain you access too. It is off limits.


Why not create a bin directory in your home directory (~/bin) and put the assembler in there. Then modify your PATH statement in your respective shell dot file:


export PATH=".:${HOME}/bin:${PATH}"


and then make it current for your relevant shell dot file where this PATH resides:


source ~/.zshrc
source ~/.bashrc
source ~/.bash_profile


and now, any time you need that assembler, regardless of the current folder, it will be found by the shell whether Zsh or Bash. I use the leading dot so I don't have to do "./something with scripts or files.

8 replies
Question marked as Top-ranking reply

Jul 14, 2023 8:13 AM in response to colinjoss

The /usr/bin location on Catalina and later is now on a read-only System volume that disabling SIP will not gain you access too. It is off limits.


Why not create a bin directory in your home directory (~/bin) and put the assembler in there. Then modify your PATH statement in your respective shell dot file:


export PATH=".:${HOME}/bin:${PATH}"


and then make it current for your relevant shell dot file where this PATH resides:


source ~/.zshrc
source ~/.bashrc
source ~/.bash_profile


and now, any time you need that assembler, regardless of the current folder, it will be found by the shell whether Zsh or Bash. I use the leading dot so I don't have to do "./something with scripts or files.

Jul 14, 2023 11:15 AM in response to VikingOSX

Okay. I didn't have a .zshrc file so I created one.


Now the export PATH=".:${HOME}/bin:${PATH}"


I'm assuming this is to append my new bin directory to the path where it picks up all the other commands? Is that right?


Now my assembler is located at So I used nano and added export PATH=~/Users/colinjoss/bin:PATH


My assembler IS found and I've lost all the other terminal commands like ls and nano


Any ideas?

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.

How to add a file to /usr/bin so I can access this from any folder via Terminal?

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