Where is the default terminal $PATH located on Mac?

后端 未结 4 1397
挽巷
挽巷 2021-01-30 00:52

I have been looking throughout the system but I cannot find it. When I do echo $PATH I get the stuff I added, plus the default path. I do not have a .profile, and I do have a .b

相关标签:
4条回答
  • 2021-01-30 01:15

    If you do sudo man path_helper, it talks a bit about how it puts the path together. You might look in /etc/paths and /etc/paths.d. I did, and found what I was looking for.

    0 讨论(0)
  • 2021-01-30 01:22

    Many system-wide settings including PATH are set in /etc/profile which is read in by bash at startup. On Mac OS X this file usually uses path_helper to set PATH. This utility in turn reads the information from other system configuration files under /etc (see path_helper manpage).

    Note that even if you disable the reading of the initialization files by bash (e.g. with command-line options like --noprofile) it will still inherit the environment of the parent process.

    0 讨论(0)
  • 2021-01-30 01:24

    If you start at /etc/profile, it should look something like this:

    if [ -x /usr/libexec/path_helper ]; then
        eval `/usr/libexec/path_helper -s`
    fi
    

    It's testing to see if the file exists and if so, executes it. If you execute it by hand, you'll get something like this:

    PATH="/usr/bin:/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"; export PATH;
    

    I believe that's what you're looking for. So it comes from /etc/profile, which in turn calls an executable that sets the path.

    0 讨论(0)
  • 2021-01-30 01:32

    The .profile file on Mac is located in your user folder: ~/Users/youruser/ However, the .profile file is hidden. You can press Command+shift+. (command, shift, dot) while on Finder to see them.

    0 讨论(0)
提交回复
热议问题