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


and other folders under /home/.

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


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

export PATH="$PATH:/opt/rh/rh-php71/root/usr/bin"
  • 2
    Maybe redundant: but updates to environment files don't take effect in your current session, you need to either log out & back in again, or source the environment file manually (with a single dot followed by a space and the (path to) the file with environment settings i.e. . /root/.bashrc ) Also how you become root changes (if and) how and which files will be sourced too. – HBruijn Apr 18 '19 at 10:48

Set it in /root/.bashrc

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

But maybe consider creating links to /usr/sbin

  • Already added (please see my updated question above), but it still doesn't show in echo $PATH. Btw what do you mean by maybe consider creating links to /usr/sbin ? Sorry I'm a total noob in this unix linux thingy – imin Apr 18 '19 at 10:27
  • did you call reset or logout/login? – Aroly7 Apr 18 '19 at 10:59
  • Thanks, working after I logout and login again – imin Apr 18 '19 at 15:28

How do you become root? Do you login as root, or do you use su? If you use su, try su - instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.