RHEL 7.3 – Set Environment Variable for Root User

bashredhatrhel7

I managed to set the environment variable for my user imin by editing the .bash_profile under folder /home/imin and added the path to my php 71 bin. Now when I run echo $PATH it shows the changes that I made, but now I need to do the same for my root.

If I run echo $PATH under my user imin, it returns
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/imin/.local/bin:/home/imin/bin:/opt/rh/rh-php71/root/usr/bin

So all is fine and dandy. But for my user root, I tried adding the line /opt/rh/rh-php71/root/usr/bin at /root/.bash_profile and /etc/skel/.bash_profile but when I tried running echo $PATH it doesn't show the changes that I made. Instead it just show /sbin:/bin:/usr/sbin:/usr/bin.

And since I couldn't get my rh-php71 bin inside my root PATH variable, I can't run php.

I have tried find |grep .bash_profile and it just return

./etc/skel/.bash_profile
./root/.bash_profile

and other folders under /home/.

So where should I actually edit to have my root's PATH updated?

Thanks

Update:
Also added the line export PATH="$PATH:/opt/rh/rh-php71/root/usr/bin" to /root/.bashrc as per Aroly7's answer below, but it still doesn't show in ECHO $PATH.

Here's my /root/.bashrc now:

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

export PATH="$PATH:/opt/rh/rh-php71/root/usr/bin"

Best Answer

Set it in /root/.bashrc

export PATH="$PATH:/opt/rh/rh-php71/root/usr/bin"

But maybe consider creating links to /usr/sbin