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?
+2
A:
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.
ghostdog74
2010-03-17 08:08:04
I don't see /etc/profile, but I see /etc/profile.d which contains gvfs-bash-completion.sh and speechd-user-port.sh files. What exactly should I do to add environment variables for all users?
Alex Farber
2010-03-17 08:26:17
those in `/etc/profile.d` are custom profiles. For all users, if you don't have `/etc/profile` then create it.
ghostdog74
2010-03-17 09:17:18
+1
A:
To see the env variable use printenv command
To set a new variable you can use ~/.bash_rc file
export new_variable = 10
Thats all you have to do. It will accessible for shells
Abhi http://codeviews.com
Abhijith
2010-03-17 08:08:39
Thank you. Do you mean ~/.bashrc file? What about setting environment variable for all users?
Alex Farber
2010-03-17 08:24:38
I don't see ~/.bash_login file. Can I create it? What is the difference between ~/.bash_login and ~/.bashrc?
Alex Farber
2010-03-17 08:27:08
@alex You can create one. bash_login runs for login shells and bashrc for interactive shells - check the man page for details.
Amarghosh
2010-03-17 09:34:08