• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2378
  • Last Modified:

Setting environment variables in ubuntu

I'm trying to permanently set some environment variables in ubuntu.  I want to set CPATH and LD_LIBRARY_PATH.  So, I go to /etc/profile and add in the following commands:

export CPATH="/mypath"
export LD_LIBRARY_PATH = "/mypath"

I restart Linux, and when I type echo $CPATH on the bash terminal, my specified path does not appear.  The variable is empty.

So, I have to keep typing export CPATH="/mypath" everytime I open up a bash window.  How do I set these variables permanently?

Thanks.
0
chsalvia
Asked:
chsalvia
1 Solution
 
sheetbirdCommented:
try putting in .~/bashrc  in your home directory.

This will only work for that user however.  It seems strange that it doesn't work in /etc/profile, it should.    Look in ~/.bash_profile ~/.bash_login and ~/.bashrc to make sure it's not getting set to null e.g.  export CPATH;
0
 
rindiCommented:
Did you try it without the "export"?
0
 
chsalviaAuthor Commented:
Okay, I got it working.  

For some reason ubuntu ignored my commands when I placed them in /etc/profile or in ~/.bash_profile or other user-specific settings files.

It only worked when I placed it in /etc/bash.bashrc

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now