I am using Linux, and I would like to be able to programmatically open notebooks in a running Mathematica instance from the command line. Currently, doing something like

/opt/Wolfram/Mathematica/8.0/Executables/Mathematica foo.nb

launches a new kernel/frontend instance. Is it possible to re-use a running frontend for opening notebooks (short of enforcing single-instance behavior, for which I believe there is a command line option)?


1 Answer 1


You can start Mathematica with :

/opt/Wolfram/Mathematica/8.0/Executables/Mathematica -sl &

and then open your notebook in the same session with :

/opt/Wolfram/Mathematica/8.0/Executables/Mathematica -sl foo.nb

From the man page Mathematica --help :

-sl (--singlelaunch): Open in an existing process, if possible.

  • $\begingroup$ Yes, the -sl flag does the trick. Another instance of Mathematica can still be launched by omitting the flag; opening notebooks afterwards with the -sl flag will still be bringing them up in the first instance $\endgroup$ Commented Oct 27, 2012 at 20:19
  • 1
    $\begingroup$ It seems it's very important that the first instance is also started with -sl. $\endgroup$
    – Szabolcs
    Commented Jul 17, 2015 at 8:51
  • $\begingroup$ Is there an easy way to change the shortcut so this is the default always $\endgroup$
    – William
    Commented Oct 15, 2016 at 20:27
  • 2
    $\begingroup$ Its /usr/local/bin/Mathematica -sl in my version of ubuntu but yes it works. $\endgroup$
    – William
    Commented Oct 15, 2016 at 20:43
  • $\begingroup$ @William, did you find a convenient way to make this the default. (I open files by double-clicking and don't want to have to have to use the command line). (I would also be very happy creating many instances if not for the fact that Mathematica only allows me to open two instances probably for some crazy license reason). $\endgroup$
    – Kvothe
    Commented Sep 21, 2022 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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