Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I am trying to change $GRAILS_HOME from /usr/grails-1.3.7 to /usr/grails-2.0.0

If I just do export GRAILS_HOME=/usr/grails-2.0.0 it doesn't persist when I log out and back in.

I found a line in /etc/profile using grep -R "GRAILS_HOME" /etc/ which reads like

export PATH ... GRAILS_HOME ...

So I changed that and logged out. The change does not seem to have taken effect, although my edits to the file remain. I cannot reboot the machine as it is serving stuff for my buddy and he is only giving me some space. But I do want the environment variable changed permanently and everywhere. What do I need to do?

share|improve this question
What shell do you use? – Kyle Jones Mar 7 '12 at 22:02
echo $SHELL says /bin/bash – Mikey Mar 7 '12 at 22:59
up vote 1 down vote accepted

Use export GRAILS_HOME=/usr/grails-2.0.0 in /etc/profile. If you leave off the export part, you're not making GRAILS_HOME persistent in the environment.

share|improve this answer
That was already in on another line. Editing my question to make that clear. – Mikey Mar 7 '12 at 23:08
What I would do is put an echo $GRAILS_HOME at the end of /etc/profile so you can both see what the variable value is at that point and verify that /etc/profile is actually being sourced when you login. – Kyle Jones Mar 7 '12 at 23:20
I did that and it now spits out /usr/grails-2.0.0 when I log in but then when i type echo $GRAILS_HOME first thing it says /usr/grails-1.2.2... Ok its also getting set in .bash_profile. There we go. – Mikey Mar 7 '12 at 23:25
The accepted is really for "What I would do..." Nice troubleshooting idea!! – Mikey Mar 7 '12 at 23:26

You would need to have export GRAILS_HOME as well. Without the export, GRAILS_HOME is only set as an internal shell variable; the export statement turns it into an environment variable that's visible by the processes launched by that shell. You can combine export with the assignment, i.e. write

export GRAILS_HOME='/usr/grails-2.0.0'

If it's not there, then GRAILS_HOME is being set from some other place on your system as well, and you need to go and change that. The other place may or be under /etc or in your account, try with another account.

If GRAILS_HOME is being set from /etc/environment, that's not a shell source file, it just looks a bit like one. But the assignments there are just VAR="VALUE", there are no export statements.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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