Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com 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

2 Answers 2

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:

cd
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

If you are comformatble using vim that should work fine.

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

Your Answer

 
discard

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