Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

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.

1 Answer

up vote 2 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
2  
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. help.ubuntu.com/community/… –  Gunnar Hjalmarsson Dec 24 '13 at 22:36
add comment

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