LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to make permanent changes to environment variables? (https://www.linuxquestions.org/questions/programming-9/how-to-make-permanent-changes-to-environment-variables-758568/)

cgchayan 09-29-2009 09:26 PM

how to make permanent changes to environment variables?
 
Hi,
Is there a way to change the values of some environment variables permanently? Or may be I write a shell script that changes the value of an environment variable and it automatically runs at the start of each new session?

Thanks

smeezekitty 09-29-2009 09:28 PM

i was wondering the same thing except i am to busy writing a kernel

manwithaplan 09-29-2009 09:36 PM

You can always use your ~/.bashrc. Which environment variables are you referring? I have several global variables declared in my ~/.bashrc

Something like this in my ~/.bashrc
e.g.
Code:

# Global FLAGS
export CHOST="x86_64-pc-linux-gnu"
export CFLAGS="-mtune=core2 -march=core2 -O2 -pipe -mfpmath=sse -ftree-vectorize -mmmx -msse -msse2 -msse3 -mssse3 \
              -ftracer -ftree-loop-distribution -floop-block -floop-interchange -floop-strip-mine -fgraphite \
              -findirect-inlining -ftree-switch-conversion"
export CXXFLAGS="${CFLAGS}"
export LDFLAGS="-Wl,-O1 -Wl,--as-needed"
export MAKEOPTS="-j3"


bgeddy 09-29-2009 11:45 PM

This is from the bash man page :
Quote:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes com-
mands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.pro-
file, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used
when the shell is started to inhibit this behavior.

rob.rice 09-30-2009 01:47 AM

you can also set them system wide in /etc/profile you should make a back up of this file BEFORE YOU EDIT IT

cgchayan 09-30-2009 04:49 AM

Thanks.. I got it

carbonfiber 09-30-2009 04:58 AM

Quote:

Originally Posted by smeezekitty (Post 3701244)
i was wondering the same thing except i am to busy writing a kernel

Science H. Logic...

smeezekitty 09-30-2009 12:26 PM

Quote:

Originally Posted by carbonfiber (Post 3701624)
Science H. Logic...

WTF does that mean?

carbonfiber 09-30-2009 02:57 PM

Not a fan of South Park, I guess? I don't blame you, who has time to watch South Park when they're busy writing a kernel.


All times are GMT -5. The time now is 03:08 PM.