bash Group Specific PATH for RHEL 7.x

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

About notesbytom

Keeping technology notes on to free up my mind to solve new problems rather than figuring out the same ones repeatedly :-).
This entry was posted in Linux and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s