0

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

/usr/pgsql-9.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

So everything is correct for root user.

I then type

sudo su postgres 
echo $PATH

It lists:

/sbin:/bin:/usr/sbin:/usr/bin

/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
0

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

Try

 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.