Recently, I came across the problem of readdressing the Mathematica user folder for a sort-of-portable version of Mathematica. In Linux this folder resides in the user’s home directory as `~/.Mathematica`

and contains all user defined settings as well as additional packages. Its contents can grow quite large over time and there are situations where you want to outsource it (maybe to an USB flash drive) or simply have in a non-default location (maybe relevant for virtual machines). Redirecting `~/.Mathematica`

to another place by a symbolic link is not always an option. The only documented possibility is to set an environment variable called `MATHEMATICA_USERBASE`

with the desired location as value and then run Mathematica. This works and here is my quick tip on how to make it more or less permanent. In Linux Mathematica is started by a shell script (called `Mathematica`

) inside the `Executables`

folder relative to the installation directory. What I wanted (in my case) was to move the user folder inside the installation one. Funnly enough, it can be done with no effort. Just open the file `Executables/Mathematica`

in a text editor and got to the very end and add

UsrBaseDir="${TopDirectory}"/.Mathematica
export MATHEMATICA_USERBASE=${UsrBaseDir}

right before the

"${MathematicaFE}" -topDirectory "${TopDirectory}" "$@"

line. Done. Notice that `${TopDirectory}`

is derived in the rest of the script and I cavalierly reused it here. You can modify `UsrBaseDir=/path/to/your/folder`

to customize it for your needs. I tested it with Mathematica 8 and 9 and it also works for the command line version `Executables/math`

and the other executables.

### Like this:

Like Loading...

*Related*

## About goobypl5

pizza baker, autodidact, particle physicist