Operating System - HP-UX
1832860 Members
2940 Online
110048 Solutions
New Discussion

Re: Permanant environment variable setting (newbie)

 
SOLVED
Go to solution
Scott Sabo
Frequent Advisor

Permanant environment variable setting (newbie)

How do I make an environment setting permanent? Example: I have to set an environment variable for a license file using EXPORT, however, I don't want to do it every time I log in.

Thank you!
7 REPLIES 7
Robert-Jan Goossens
Honored Contributor

Re: Permanant environment variable setting (newbie)

Hi,

You could edit your $HOME/.profile and add your export variable in there.

Hope this helps,
Robert-Jan
Mel Burslan
Honored Contributor

Re: Permanant environment variable setting (newbie)

You can put it at the end of your .profile in the following format

VARIABLE_NAME=value

Hope it helps
________________________________
UNIX because I majored in cryptology...
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Permanant environment variable setting (newbie)

Two ways:

For everybody, put an export statement in /etc/profile.

e.g.
export MYVAR=Furpsplat


or for just one user put the same statement in .profile.

Because /etc/profile is read before .profile, if the same variable is set in both, the last export wins so that it is possible to override the values set in /etc/profile.

If it ain't broke, I can fix that.
Mel Burslan
Honored Contributor

Re: Permanant environment variable setting (newbie)

Also if you are the sysadmin of this box and want to have this value set for all of the users of this system, you can put it in the file /etc/profile
________________________________
UNIX because I majored in cryptology...
Bharat Katkar
Honored Contributor

Re: Permanant environment variable setting (newbie)

adding in /etc/profile seems to be the best option. Add following:
"export VARIBLE=value"
You need to know a lot to actually know how little you know
Scott Sabo
Frequent Advisor

Re: Permanant environment variable setting (newbie)

Wow! Thanks for the many replies.

What is the difference in just putting:

MY_APP_LICENSE=/licenses/license.dat

and

export MY_APP_LICENSE=/licenses/license.dat

in /etc/profile?

If I just do MY_APP_LICENSE=/licenses/license.dat
It seems to hit everyone.

Scott
Bharat Katkar
Honored Contributor

Re: Permanant environment variable setting (newbie)

** Export allows the Varible to be inherited by the Sub Shells.
You need to export the variable since it is inherited by the sub shell that may be used by the users after login.

You need to know a lot to actually know how little you know