If you are new to Mac OS X, you may need to know how to edit your PATH. The good news is that this is an extremely easy task on Mac OS X.

Step 1: Open up a Terminal windows (this is in your Applications/Utilites folder by default)

Step 2: Enter the follow command:

$ sudo vi /etc/paths

This will open the paths file in vi (a simple command line file editor included on your system).

Step 3: Edit the contents of your PATH file by putting each path you want included on a separate line.

Step 4: Save the contents of your PATH file by pressing SHIFT + Z twice.

That’s it! Now you know how to edit the PATH on your Mac OS X computer system.

{ 9 comments… read them below or add one }

Keir Briscoe July 18, 2008 at 5:04 pm

I am able to open my path using the above command. But I am not able to add any lines or change any existing ones. What do I have to do to get into Edit mode?

Reply

Ben Hathaway July 18, 2008 at 6:14 pm

You can refer to vi editor commands for help with the specifics of using vi to edit files. To switch into edit mode though, you should be able to press “a” once and then ESC will get you out of edit mode. Then press “ZZ” to save the file.

Reply

Keir Briscoe July 18, 2008 at 6:22 pm

Thank you. I found that if I presses “i” I was able to insert a line of text.

Unfortunately my python script will still not run.

Thanks for your reply.

Reply

Mitur Binesderti July 15, 2010 at 12:17 pm

Thank you SO much! This worked perfectly! I would suggest for vi novices like myself it would be easier to use the pico editor like so “sudo pico /etc/paths”.

Reply

Henning Heinz March 9, 2011 at 10:25 am

Many people suggest editing your .profile file but your solution looks much much better to me. Thank you for taking the time for sharing this.

Reply

Ben March 9, 2011 at 10:32 am

Glad it helped. Editing the .profile is a good method if you are working in a multi-user environment because the .profile paths will only be loaded when you login. But if you want to make a global change for the system, the /etc/paths file will work better.

Reply

Mac Guider June 23, 2011 at 9:38 pm

I am trying to change PATH Environment Variables On Mac OS X for CakePHP too

Reply

Joe Devon November 30, 2011 at 3:03 pm

This information doesn’t cover the whole picture. There’s a good discussion here:
http://superuser.com/questions/69130/where-does-path-get-set-in-os-x-10-6-snow-leopard

Reply

Loke January 29, 2012 at 9:27 am

In place of vi, use nano. It’s not so complicated.

Reply

Leave a Comment

{ 3 trackbacks }