I'm trying to add an environment path /usr/pgsql-9.5/bin for all users on my CentOS 7 system.

I created a new file under /etc/profile.d/

It looks like this:

export PATH="/usr/pgsql-95/bin:$PATH"

I then restart the system and login using root.

I type in echo $PATH, it lists


So everything is correct for root user.

I then type

sudo su postgres 
echo $PATH

It lists:


/usr/pgsql-9.5/bin is missing?

Why is the path not added for user postgres?

If I create a new user the path is correctly added $PATH.

  • Try sudo su - postgres, which will run the login process for postgres (see man su). – ridgy Dec 4 '16 at 11:07
  • Curiously , in my mind using sudo su postgres is fine while root had export environments variable PATH. i think you need double check what if user 'postgres' recover the profile. and if you have postgres 's password? try su postgres then put echo $PATH. – Se ven Dec 4 '16 at 13:52

You are using su not su -l

Using su -l will provide environment like direct login and it will set environment variable mentioned by you in /etc/profile.d/filename


 sudo su -l username

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.