Where does the bash PATH on CentOS 7 get /usr/local/bin from?
Other people have asked the same thing on the CentOS bug tracker. The earliest post I found was this one.
/usr/local/bin is hardcoded in /bin/bash.
As you will see this problem was first reported in May 2012, and has existed in CentOS 6 and CentOS 7.
So as confusing as it may be, it looks like your analysis the paths are not coming from /etc/profile is correct. The paths are coming from /bin/bash.
In the bash source "config-top.h" has this:
/* The default value of the PATH variable. */ #ifndef DEFAULT_PATH_VALUE #define DEFAULT_PATH_VALUE \ "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:." #endif /* The value for PATH when invoking `command -p'. This is only used when the Posix.2 confstr () function, or CS_PATH define are not present. */ #ifndef STANDARD_UTILS_PATH #define STANDARD_UTILS_PATH \ "/bin:/usr/bin:/sbin:/usr/sbin:/etc:/usr/etc" #endif
It definitely looks hard coded into
strings /bin/bash | grep "\/usr\/local\/bin" /usr/local/bin:/bin:/usr/bin
which seems to be the default PATH.
In addition to previous answers; If you are reaching you VM by ssh this could has sense.
# This sshd was compiled with PATH=/usr/local/bin:/usr/bin