Users on a RHEL 7.x / CentOS 7.x system may desire to have all members of a specific group receive an altered $PATH environment variable to run 3rd party programs without modifying the user-specific PATH settings. This can be accomplished by adding *.sh files to the system-wide /etc/profile.d/ directory. Here is a sample I created to demonstrate.
I’m using “-z” to test whether the “bash” shell is being used, and the “=~” matching operator to compare the output of “id -nG” to a specific group name. Note that this will match the named group anywhere in the group list, so please review group names on your system to make sure it won’t match other groups you want to exclude. The convenient “pathmunge” function is used to add to the PATH since it is defined in both /etc/profile and /etc/bashrc which call (source) /etc/profile.d/*.sh