What is the difference in doing

$ MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=384m"

to doing

$ export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=384m"

and is there any side-effect of doing either in an SSH connection?


The 1st one sets the value to the variable. For instance you can do


and have it return the value but if you would issue that outside your shell you will have an empty string returned.

In comes export.

Export is an instruction to the shell. It tells the shell to make this environment variable available to other programs. Without the export, they are only available within the shell itself.

If you want the variable to be permanently available ssh reads ~/.ssh/environment,ssh2 reads /etc/environment and ~/.ssh2/environment, and adds lines of the format VARNAME=value to the environment. From the ssh man page.

| improve this answer | |
  • Though, if I issue the export within an SSH connection and the disconnect, that variable won't be available to subsequent connections. how do I make it permanent? – Pomario Apr 30 '12 at 13:11
  • Of course it does not :) @pomario added in ssh and ssh2 methods for adding envs! – Rinzwind Apr 30 '12 at 13:20
  • No, wait! :) What I mean is, I connect to the server using SSH and i want to add an environment variable that will be accessible to Jenkins web interface. is there any way of accomplishing this? – Pomario Apr 30 '12 at 13:26
MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=384m"

Sets a shell variable named MAVEN_OPTS. It is probably followed by an export MAVEN_OPTS command to make this variable available as environment variable to child programs, or a shell command that uses it like java $MAVEN_OPTS ...

export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=384m"

Sets a environment variable named MAVEN_OPTS. This environment variable is also available to child programs.

There are no side-effects except for that some java memory limits are adjusted for maven (a build system iirc).

| improve this answer | |
  • darn it Lekensteyn. Thats's the 4th time today. Go do something else! >:D – Rinzwind Apr 30 '12 at 13:05
  • @Rinzwind Doing so in #bumblebee on Freenode IRC :P – Lekensteyn Apr 30 '12 at 13:06
  • More than 2 good answer is not bad thing :) – Tachyons Apr 30 '12 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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