sudo open -e ~/.bash_profile Permission denied mac sudo open -e ~/.bash_profile Permission denied mac bash bash

sudo open -e ~/.bash_profile Permission denied mac


The problem is that the file isn't owned by your user, but by root. You need to change the owner of the file to your user, then you can open and edit the file without the use of sudo:

sudo chown farheen ~/.bash_profile

This will, as the super-user, change the owner of the file back to you.


For Mac User Catalina,

.bash_profile not open, they need grant permission to edit this file. You can achieve by below steps

1) Open the terminal and enter below command ex: sudo chown iMac ~/.bash_profile

sudo chown {your username} ~/.bash_profile

2) Open editor in the terminal, here i used nano

nano .bash_profile

3) Edit your text you want.

4) To save the changes you've made, press Ctrl + O

5) To exit nano, press Ctrl + X

6) And finally to load your changes, enter below command

source .bash_profile


OR

You can give permission and make it executable file using like below:

That error likely means that 'bash_profile' isn't executable. If it's in the current directory, you can make it executable with chmod +x bash_profile.