LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why is the environment variable set in .bash_profile is not being in effect ? (https://www.linuxquestions.org/questions/linux-newbie-8/why-is-the-environment-variable-set-in-bash_profile-is-not-being-in-effect-923136/)

nkdblm 01-10-2012 05:35 PM

Why is the environment variable set in .bash_profile is not being in effect ?
 
Hi All, I am new to Linux and I got an opportunity to work on Linux now. I am quite excited, but had to post this simple question for all of you.

We had DB2 software installed in a specific directory /IBM/db2/V9.7/bin and my PATH variable isn't set for this. So, for all the db2 commands I have to type the path with command. So, I have updated the PATH variable at $ prompt and exported the variable, and it worked successfully. But after I logged off and logged back in, I had to do it again. So, with little knowledge and searching around I found .bash_profile where I could append the path to existing PATH. So, i have updated the .bash_profile with PATH=$PATH:/IBM/db2/V9.7/bin and logged off and logged back in again. Still I do not see the changes for the PATH variable taking effect from my .bash_profile. So, wondering if there is something else I need to do. Please let me know if you have any ideas on how I could get this resolved.

Thank you

nkdblm 01-10-2012 05:38 PM

Oh, and I also have the export PATH in .bash_profile after setting the variable.

David the H. 01-11-2012 09:41 AM

bash_profile is usually read by login shells, but not by non-login interactive shells. Those generally use bashrc. Read the INVOCATION section of the bash man page for details on the start-up files used in your distribution.

nkdblm 01-18-2012 07:27 PM

Thank you for the information. I have tried .bashrc also, and it is still not working. So, I am reading the books now to see if there is anything else, and will post the answer as soon as I find the solution.

catkin 01-19-2012 06:28 AM

What you have described should work. If your ~/.bash_profile contains
Code:

export PATH=$PATH:/IBM/db2/V9.7/bin
then the PATH should be modified.

How to diagnose the problem? One possibility is that PATH is being set to some other value later. To see what is happening you could add set -x at the beginning of ~/.bash_profile and log on at a virtual console (accessed from a graphical desktop by Ctrl+Alt+F1 or F2 ... Get back to the graphical desktop by typically Ctrl+Alt+F7 but try others if that doesn't work).

nkdblm 01-26-2012 09:23 PM

Thank you for your help. As I didn't find other options, I have created .profile file with the same command and this time it worked.

catkin 01-27-2012 12:52 AM

Glad you found a solution :)

Threads can be marked SOLVED via the Thread Tools menu.


All times are GMT -5. The time now is 10:13 AM.