Alex F
Alex F

Reputation: 43311

Linux/Unix environment variables

Where Linux/Unix environment variables are kept? How can I add my own environment variable and make it persistent, not only within currently running script?

Upvotes: 3

Views: 7735

Answers (4)

Abhijith
Abhijith

Reputation: 11

To see the env variables use the printenv command.

To set a new variable you can use the ~/.bash_rc file:

export new_variable=10

new_variable will be accessible for all shells.

Upvotes: 1

Amarghosh
Amarghosh

Reputation: 59451

Add export statements to ~/.bash_login

Upvotes: 1

Anders Abel
Anders Abel

Reputation: 69260

Are you looking for the export keyword?

More information:

Upvotes: 1

ghostdog74
ghostdog74

Reputation: 342313

you can add them in your profile, eg ~/.bash_profile. global profile is usually located in /etc. eg /etc/profile. Take a look also at /etc/profile.d directory if you have it.

Upvotes: 3

Related Questions