Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Setting Environment Variables in a Shell Profile

  • 21-08-2002 12:17AM
    #1
    Closed Accounts Posts: 1,322 ✭✭✭


    I'm running Mandrake 8.2 (which includes bash)

    According to some text I've been reading; when an instance of a shell is loaded, environment vars such as $PATH are set in a file called /usr/.bash_profile. I had a look for that file and it didn't exist (and yes I used ls -a, to get hidden files). But I did find a copy of it in my home dir. So I edited that file, updating the $PATH var, and setting up a new $CLASSPATH var, for myself. In the script, I exported both vars, after init. But when I start a shell the vars have not been changed/created. So either I have done something wrong, or else that script is not executed.

    I want these vars setup under my account, and not global amonst all accounts, so it does make sense as to why .bash_profile would exist in my home dir. Also I could write a small script to do this myself, but since a script to init these vars upon startup already exists I would love to know where it is.

    Cheers, and advTHANKSance. ;)

    ;-phobos-)


Comments

  • Registered Users, Registered Users 2 Posts: 513 ✭✭✭Cond0r


    Right,

    Now i'm sure i'll be corrected if i'm wrong but...
    There is probably also a file called '.bashrc' and AFAIK, that file is executed if it's found, instead of the '.bash_profile' one. So hop the lines you want executed into that file and see if it works. :)

    Hope it helps.

    C.


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    When you login, bash will first load global profile and bashrc files. usually from /etc/profile and /etc/bashrc. Then it will load your local files, usually ~/.bash_profile and ~/.bashrc. Check all of these files to see if anything is interfering with anything else.

    http://www.gnu.org/manual/bash/html_chapter/bashref_6.html#SEC63

    adam


  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    Originally posted by bedlam
    put the file in your $HOME not /usr
    No the file was already in $HOME. The book I was reading told me that I would find it in /usr.... (so I'm assuming any version in there would be global to all accounts, which I don't want in this case).

    Anyway cheers for the help coz that worked! ;)

    I edited the .bashrc in $HOME and it was invoked upon startup after the global profiles scripts are loaded. So the var values got appended correctly.

    Cheers

    ;-phobos-)


Advertisement