updating environment variables
i updated one of the environment variables, PATH. but I don't know how to keep it in my environment variables list. i mean when I close the session, it's gone.
I am using red-hat linux. is there any way to do it? Thanks. |
If you are using bash, you can add the extra PATH elements in your ~/.bash_profile
PATH=$PATH":your/new/directory/here" --- rod. |
Quote:
Thanks for the reply. I edited the file in vi mode. export PATH='/java/bin:$PATH' but when I check ('env'), it doesn't show the updated one. is there any command after I save the bash_profile? cuz i remember that i did something in unix something like ". .profile". can anybody tell me what it is? Thanks. |
try
Code:
source ~/.bash_profile |
Quote:
I got the following error. "if: Expression Syntax."... here is my profile. # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin JAVA_HOME='/java' PATH=$JAVA_HOME/bin:$PATH |
Code:
PATH=$PATH:$HOME/bin **EDIT** Upon rereading: Did anyone understand what I just said? **EDIT** Remove both PATH lines and replace it with one for simplicity: Code:
PATH=$ORIGINAL_PATH:$HOME/bin:$JAVA_HOME/bin for me this is Code:
/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/games |
Quote:
so I changed like this. it has only PATH. But it still returns the same error. ----------------------------------------------------------------- # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$HOME/bin |
Just so that you understand, the ~/.bash_profile is run when you log in. You want this for changes in the PATH variable, because if you used ~/.bashrc, you will be re-adding things to your PATH variable everytime a new shell is opened.
Quote:
|
here is my whole profile. I commented out all variables. I have only if statement. it still fails with or without "#!/bin/bash".
#!/bin/bash # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi |
Could you post your ~/.bashrc for us
|
Quote:
Here it is... ------------------------------------------ . /etc/skel/bashrc-DEFAULT # Add customizations below this line # Default Local Timezone set to PST8PDT # uncomment out the entry below to change it # #export TZ=CST6CDT |
Are you actually using 'bash'? There are other shells, csh and kin in particular, that don't have the same scripting language.
Try Code:
echo $SHELL Code:
source .bash_profile Just looking at your second post (first reply), you have enclosed everything in your assignment to PATH in single quotes. This will prevent the expansion of the existing PATH variable. Use the syntax I used in my example. --- rod. |
Quote:
when I execute echo $SHELL, I got "/bin/csh". How can I change it to bash? sorry.. i am a newbie for linux. |
Find your entry in /etc/passwd. As root, change from /bin/csh to /bin/bash
I'm pretty sure this won't apply to you, but just for completeness, you may need/want to copy stuff from your ~/.cshrc file to the new .bashrc &/or .bash_profile. Of course you'd have to modify the scripting as necessary. --- rod. |
All times are GMT -5. The time now is 06:46 PM. |