Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I edit the bash_profile? I've tried using the command chflags but it shows the error

[Error writing. Bash_profile: Operation not permitted]

I'm using OS X Snow Leopard 10.6.8.

share|improve this question

migrated from Apr 6 '12 at 22:21

This question came from our site for professional and enthusiast programmers.

It could be useful to see the output of these commands id and ls -ld . .bash_profile – Brian Swift Apr 6 '12 at 23:29

In most cases, the file doesn't even exist unless you specifically create it. In order to do this, you don't need chflags. In fact, if you're a typical user, you don't need chflags at all with your Mac.

Just enter:

touch .bash_profile

You can then edit it with whatever application you like, for example a terminal-based editor like vim, nano, or even TextEdit:

vim .bash_profile
nano .bash_profile
open -a "TextEdit" .bash_profile

After you've edited the file, make sure to source the .bash_profile again. Otherwise, bash won't recognize the changes:

source .bash_profile

If for some reason you don't have permissions, make sure your .bash_profile looks like this when doing a directory listing with ls -la – i.e. mode 644, owned by yourself.

charon:~ werner$ ls -l .bash_profile 
-rw-r--r-- 1 werner  staff  1323 Apr  4 18:00 .bash_profile
share|improve this answer
Great ! You saved my day ! – Durai Amuthan.H May 20 '15 at 11:36

If you are comformatble using vim that should work fine.

  1. Open Terminal (/Applications/Utilities/
  2. Type vim .bash_profile
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.