Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I've tryed to add environment variable in terminal:

loom@loom:~$ export DOOM=/home/loom/doom/
loom@loom:~$ echo $DOOM 
bash: /home/loom/doom/: Is a directory

Then I've closed terminal and reopened it. However, there isn't $DOOM variable now. How to add environment variable via terminal?

share|improve this question

marked as duplicate by Radu Rădeanu, karel, Avinash Raj, Seth, Braiam Dec 25 '13 at 6:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 3 down vote accepted

Environment variables set like this are only stored temporally. When you exit the running instance of bash by exiting the terminal, they get discarded. To save them permanentally, write the export x=y commands into /etc/profile (for all users) or ~/.profile (for yourself) Do this by editing/creating (?) the file using your preferred text editor (as root for /etc/profile). Examples:

sudo nano /etc/profile
gedit ~/.profile
# etc... kate, leafpad, vim, whatever you want to use
share|improve this answer
Better to use ~/.bashrc file instead ~/.profile file! – Radu Rădeanu Dec 24 '13 at 15:06
What's the difference? – the_Seppi Dec 24 '13 at 15:11
Please see .profile vs. .bash_profile vs. .bashrc – Radu Rădeanu Dec 24 '13 at 15:17
@RaduRădeanu: I don't understand what you base your claim on that ~/.bashrc is better than ~/.profile. Environment variables set in ~/.bashrc are not available in graphical shells.… – Gunnar Hjalmarsson Dec 24 '13 at 22:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.