Why can't my user see environment variable?

Tags:

Answer: 1

5 hours ago

I have a .sh file with some environment variables under /etc/profile.d/vars.sh. Its content looks like this:

export PORT=8080

This is an Ubuntu 14.04 running on AWS EC2. When I log in via SSH with the default user (ubuntu) and run echo $PORT I get 8080 back.

However if I:

sudo su
su ubuntu
echo $PORT

I get nothing back. Why is that? How can I set environment variables for all my users (or specifically for ubuntu) so they will see it even in a non interactive shell session?

Thanks!

Added by: Lauretta Kozey III

Answer: 2

6 hours ago

Use the -l option on su to get a full user login:

su -l ubuntu

That should give you the ubuntu environment you expect.

Added by: Jevon Braun

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9