Environment Variables (setting path)

Quick to answer questions about finding your way around Linux Mint as a new user.
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. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Octitude

Environment Variables (setting path)

Post by Octitude »

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.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
viking777

Re: Environment Variables (setting path)

Post by viking777 »

I have always understood it to be /etc/environment, but you are right, there is ample scope for confusion :?
garda

Re: Environment Variables (setting path)

Post by garda »

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.
Locked

Return to “Beginner Questions”