How do I set the global PATH environment variable on OS X?

palmer’s GUI information is correct, but there is a more maintainable way to modify the path seen by the shell. Like mediaslave said, you can edit /etc/paths, but even better you can drop a text file in /etc/paths.d/ that has a path in it and all shells will construct the path correctly.

For example, on my system:

$ cat /etc/paths
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
$ ls /etc/paths.d
X11       git      postgres
$ cat /etc/paths.d/postgres
/Library/PostgreSQL/8.4/bin
$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Library/PostgreSQL/8.4/bin:/usr/X11/bin:/usr/local/mysql/bin

Leave a Comment