LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Saving system environment variables (http://www.linuxquestions.org/questions/slackware-14/saving-system-environment-variables-687605/)

garyg007 12-01-2008 09:00 PM

Saving system environment variables
 
This is having me sitting under my desk and talking to myself.

I have been trying to add a couple of directories to the PATH
system environment variable; works fine and does what I want it to do
UNTIL I RE-BOOT --- then everything I added is no longer there.
I tried
Code:

PATH=$PATH:/stuff/I/added
and
Code:

export PATH=$PATH:/stuff/I/added
and
Code:

export PATH=all/the/old/stuff:stuff/I/added
nothing keeps the changes across system re-starts.

How do I make this happen?


Gary

T3slider 12-01-2008 09:06 PM

You should add one of those lines (probably the first one) to ~/.bashrc (or .bash_profile...). See `man bash` (see the INVOCATION section about .bashrc and .bash_profile for information on which one to use). Create the file if it doesn't exist.

Woodsman 12-01-2008 09:57 PM

The bulk of the stock Slackware PATH assignments are located in /etc/profile.d scripts. Those scripts are executed from within the /etc/profile script.

If your path assignments are system-wide and not specific to your normal user account, then create a new script in /etc/profile.d:

touch /etc/profile.d/local.sh
chmod +x /etc/profile.d/local.sh
mcedit /etc/profile.d/local.sh

Then add your new PATH variable as you desire:

PATH=$PATH:blah:blah
export PATH

Save the document.

If the PATH asssignments are specific only to y our normal user account, then place the commands in $HOME/.bashrc.

If you want more information about bash startup scripts:

Harmonizing the Bash Startup Scripts

garyg007 12-01-2008 11:12 PM

Woodsman, Thanks for the nice reply - only problem - with the link you provided - it's going to take my retired senile brain a few days to absorb enough to lift me out of the dangerous zone

Gary

acummings 12-02-2008 02:00 AM

Code:

al@G33T-M2:~$ cat .bashrc

[ -f /home/al/.term_aliases ] && . /home/al/.term_aliases
[ -f /etc/profile ] && . /etc/profile
export PATH=$PATH:/home/al/bin

FWIW (if this helps any) that export line in my .bashrc adds that folder onto my path (for me, user al)

Alan.

garyg007 12-03-2008 07:06 PM

I added this text file to /etc/profile.d;
Code:

!/bin/sh
#
# this is located in /etc/profile.d
#
export MYSQL_HOME=/usr/local/mysql:/usr/local/mysql/bin
echo $MYSQL_HOME
export PATH="${PATH}:${MYSQL_HOME}"
echo $PATH

that did the trick.

Thanks all;

Gary


All times are GMT -5. The time now is 05:07 AM.