LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-29-2009, 09:26 PM   #1
cgchayan
LQ Newbie
 
Registered: Sep 2009
Posts: 8

Rep: Reputation: 0
Red face 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
 
Old 09-29-2009, 09:28 PM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
i was wondering the same thing except i am to busy writing a kernel
 
Old 09-29-2009, 09:36 PM   #3
manwithaplan
Member
 
Registered: Nov 2008
Location: ~/
Distribution: Arch || Sidux
Posts: 393

Rep: Reputation: 45
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"

Last edited by manwithaplan; 09-29-2009 at 09:38 PM.
 
Old 09-29-2009, 11:45 PM   #4
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
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.
 
Old 09-30-2009, 01:47 AM   #5
rob.rice
Senior Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 1,076

Rep: Reputation: 205Reputation: 205Reputation: 205
you can also set them system wide in /etc/profile you should make a back up of this file BEFORE YOU EDIT IT
 
Old 09-30-2009, 04:49 AM   #6
cgchayan
LQ Newbie
 
Registered: Sep 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks.. I got it

Last edited by cgchayan; 09-30-2009 at 05:02 AM.
 
Old 09-30-2009, 04:58 AM   #7
carbonfiber
Member
 
Registered: Sep 2009
Location: Sparta
Posts: 237

Rep: Reputation: 46
Quote:
Originally Posted by smeezekitty View Post
i was wondering the same thing except i am to busy writing a kernel
Science H. Logic...
 
Old 09-30-2009, 12:26 PM   #8
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by carbonfiber View Post
Science H. Logic...
WTF does that mean?
 
Old 09-30-2009, 02:57 PM   #9
carbonfiber
Member
 
Registered: Sep 2009
Location: Sparta
Posts: 237

Rep: Reputation: 46
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu Edgy where is the config file where xset variables can be set as permanent? jim0112 Ubuntu 2 10-01-2007 01:27 PM
How to create new permanent environment variable in Red hat Linux? halturata Linux - Newbie 2 04-10-2006 10:38 AM
How to make system wild environment variables? renshao Linux - Newbie 5 03-12-2006 05:50 AM
environment variables slinky2004 Linux - General 4 11-26-2005 09:59 AM
Environmental variables... permanent fabianrios Fedora 2 10-20-2005 05:06 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration