Environment Variables (setting path)

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Level 1
Level 1
Posts: 5
Joined: Tue Feb 09, 2010 7:07 am

Environment Variables (setting path)

Postby Octitude » Tue Feb 09, 2010 7:17 am

Hi to all,

I am trying to set path for an application I have installed. What i'm trying to wrap my head around is if I want an environment variable to work in all terminals is it recommended I edit bash.bashrc or /etc/environment. Alternatively could I source bash.bashrc from ~/.bash_profile for this to work? What are the pros and cons?

So if I edit .bashrc then source that from ~/.bash_profile would that be a safe bet?

Im confused as there is no .bashrc or profile_bash by default and the default paths are set in etc/environment so is there any reason i can't just set the path in /etc/environment?

I think i'm over complicating the matter, i am however determined to wrap my head around this.

User avatar
Level 14
Level 14
Posts: 5139
Joined: Mon Dec 01, 2008 11:21 am

Re: Environment Variables (setting path)

Postby viking777 » Wed Feb 10, 2010 10:57 am

I have always understood it to be /etc/environment, but you are right, there is ample scope for confusion :?
Fujitsu Lifebook AH532. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Lubuntu 13.10,Ubuntu12.10 (Unity), Mint16 (Cinnamon), Manjaro (Xfce).

User avatar
Level 5
Level 5
Posts: 743
Joined: Sat Aug 30, 2008 2:55 am
Location: /root

Re: Environment Variables (setting path)

Postby garda » Wed Feb 10, 2010 12:46 pm

Environment variables and aliases defined or set in /etc/environment are applied system-wide; all variables inside it are applied to all users, including root.

Things defined or set in ~/.bashrc are applied to the user's session only upon login. This file is often used to define shell variables specific to a user's shell environment needs.

~/.bash_profile is a script that gets executed upon login. It may or may not contain a line that sources ~/.bashrc. /etc/profile is similar in purpose, except that it's system-wide -- it gets executed when anybody logs in.

Conclusion: Yes, sourcing ~/.bashrc from ~/.bash_profile is a safe bet.

Return to “Newbie Questions”

Who is online

Users browsing this forum: austin.texas, flute and 21 guests