Skip to content

Fixing /etc/profile

The “traditional” way of setting up paths in *nix bash environments is to use the ~/.profile file. However, I recently read about /etc/paths and /etc/paths.d and wanted to give them a try. I tried rearranging /etc/paths to look like this:

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

Then I restarted my Terminal and inspected the path. No change. That’s strange. My principle of least surprise felt violated.

Thanks to a nice write-up (also mentioned here), I got a handle on what was happening. My solution was to change /etc/profile to look like this:

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
    PATH=”"
    eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc
fi

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*