LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   setting Environment variables? (https://www.linuxquestions.org/questions/linux-newbie-8/setting-environment-variables-588794/)

muby 10-02-2007 01:42 AM

setting Environment variables?
 
hii all, I'm very new to Linux & I'm using fedora7 for ns2, after installation i export the Environment variables this way:


>export PATH=/root/ns-allinone-2.31/bin:/root/ns-allinone-2.31/tcl8.4.14/
unix:/root/ns-allinone-2.31/tk8.4.14/unix
>export LD_LIBRARY_PATH= /root/ns-allinone-2.31/otcl-1.13:/root/ns-allinone-2.31/lib
> export TCL_LIBRARY=/root/ns-allinone-2.31/tcl8.4.14/library

but I when i check the environment variables using "env". i dont see my new variables!!
please how can i solve this problem? what im doing wrong?

Thank You

Muby

lbdgwgt 10-02-2007 01:57 AM

use "echo" for example to see your new PATH:
Code:

# echo $PATH
using env you can do:
Code:

# env | grep PATH

HTH,

kWzTa 10-02-2007 02:38 AM

Hi Muby,

I think that the problem comes from the fact you override the PATH
environment variable. As a result, when you try to use 'env' command,
the shell does not know where it is.

You should try like this:

Code:

export PATH=${PATH}:/root/ns-allinone-2.31/bin:/root/ns-allinone-2.31/tcl8.4.14/unix:/root/ns-allinone-2.31/tk8.4.14/unix
Proceeding this way allows you to add new paths to the existing list of paths of the PATH variable.

HTH,

colucix 10-02-2007 02:50 AM

Furthermore, take in mind that if you export a variable from the command line, it will be available to the open shell only (that is if you open another terminal you start a new shell which will not be aware of the modified environment). To make your changes really global, you have to put the export statement in a file which will be sourced every time you start a new shell (usually .bashrc if using bash).

muby 10-02-2007 04:39 AM

colucix, lbdgwgt & kWzTa Thank you guys you were helpfull, but i found that my setting are not global. which bashrc file i should modify with export statement? & what line should change?

[root@localhost ~]# locate bashrc
/etc/bashrc
/etc/skel/.bashrc
/home/Mubarak/.bashrc
/root/.bashrc
/usr/share/doc/bash-3.2/startup-files/bashrc
statement

Thanks again guys

colucix 10-02-2007 05:21 AM

If you want to define environment variables on a per-user basis, you should put export statements in .bashrc under user's home (e.g. /home/Mubarak/.bashrc from your list). If you want a system wide configuration, the better place is under the /etc/profile.d directory. Look at its content: you will find some .sh and .csh scripts. These contain environment settings from specific applications. You can create your own, for example a script called ns.sh.
Just for completeness, these scripts are sourced from /etc/profile, which - on my system - has the following relevant piece of code:
Code:

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        . $i
    fi
done

unset i



All times are GMT -5. The time now is 04:55 PM.