8

Possible Duplicate:
How do I set a user environment variable? (permanently, not session)

To change the amount of PATH variable , I use : export PATH=...

But when I close the terminal, the amount of PATH becomes what it was at first.

I want to save the changes, so that the amount will be what I want after closing the terminal or logging out.

How can I do this work?

I use Fedora 17, kernel : 3.4.3

M0εiπ
  • 1,257
  • another possible duplicate about setting environment variables – jw013 Jul 02 '12 at 17:47
  • @Pierre.Vriens thank you for your edits/improvements! Something that I learned when starting to edit: realize that if you edit the text of a closed post (such as this one), it puts it into the ReOpen queue, so please continue to write good comments about what you changed, so that the reviewers know it was just typo-fixes and not an attempt to re-open the question. Thank you! – Jeff Schaller Jul 13 '17 at 14:23
  • @JeffSchaller merci for the comment, will try to do as you suggested. However I might as well skip the closed ones (there are still tons of similar ones to be edited / improved). Not "my" personal preference, but at least it prevents the side-effect you mentioned. – Pierre.Vriens Jul 13 '17 at 14:26
  • de rien! I don't mean to slow your efforts to improve the site. If it was me, I might focus on highly-viewed and/or highly-voted entries (even if they were closed), to provide a better face for them. Again, it makes the reviewers job easy if you clearly indicate what you were doing -- then it's just a "keep closed" vote. – Jeff Schaller Jul 13 '17 at 14:34

2 Answers2

9

make the setting persistent:

add this line: export PATH=/path/to/dir in your ~/.bashrc if using bash, or ~/.zshrc for zsh:

$ vim ~/.bashrc

export PATH=$PATH:/path/to/dir

:wq

or:

$ echo "export PATH=$PATH:/path/to/dir" >> ~/.bashrc

LATER EDIT!

fromnaboo
  • 6,932
7

Each time you execute a bash (non-login) shell instance, it reads and executes the .bashrc file in your home directory. Login shells, on the other hand, do that for .profile file, located in your home directory. You can find the difference between login and non-login shells by reading the bash manual.

In your case, open your ~/.bashrc and set there the variable that you want. For example:

PATH="/some/new/path:$PATH"

Save it, and reload it:

$ source ~/.bashrc

dkaragasidis
  • 1,906