Can't edit /etc/profile on my mac

/etc/profile is readonly.

You can make it writable with

$ sudo chmod +w /etc/profile

or better yet in vi, overwrite a readonly file with Esc-wq!


Maybe this is not what you are after, but if you can create a .profile file in your home directory and put your user-specific configuration changes in there and then you don't need to worry about the one in /etc/profile. However, perhaps you are looking to change the configuration for all users and not just a single user. If so, then the above two answers are on target.


Running ls -l on /etc/profile reveals that not even the owner has write permission:

$ ls -la /etc/profile 
-r--r--r--  1 root  wheel  189 May  4  2009 /etc/profile

You can let the owner edit it like this:

sudo chmod u+w /etc/profile

Then you should be able to edit it as root.