问题
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 .bashrc, but the default path is not in there. I am looking for it just to know where it is located because all the tutorials explain that its in .profile... but what if you don't have one? Where is it located then? Anybody have any ideas?
回答1:
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.
回答2:
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.
回答3:
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.
回答4:
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.
来源:https://stackoverflow.com/questions/9832770/where-is-the-default-terminal-path-located-on-mac