Matlab on Remote Linux


To run Matlab remotely without graphics, use the command:

matlab -nojvm -nodesktop -nodisplay

In the background

To run Matlab remotely without graphics and in the background (namely, to keep Matlab running after your PC disconnects from the Linux workstation), use the commands


matlab -nojvm -nodesktop -nodisplay

When your PC reconnects to the Linux workstation, you can use the following commands to recover Matlab

screen -r

press “Ctrl-A”, then “?”

See here for a tutorial of “screen.”

Graphical interface

The following part is for remotely running Matlab with a graphical interface on Linux. Since it uses more resources, we do not recommend it. It is based on VNC through an SSH tunnel.

On your PC/Mac, download and install

  1. an SSH client with the tunneling function (e.g., PuTTy for Windows)

  2. a VNC client (e.g., TightVNC’s vncviewer)

Set up your SSH client and connect to the Linux workstation. Start a remote VNC service at an unused port x (e.g., 0, 1, 2, ….) by

vncserver :x

If this is the first time the command is called, you will be asked for a VNC password and then a subfolder .vnc containing a script file xstartup will be created under your home. For better graphics, the default xstartup can be replaced by this file. If the port x is in use, try a different port number.

If the above command is successful, close your connection and re-open your SSH client. Configure an SSH tunnel, mapping source port 590x to destination localhost:590x. Now, reconnect the SSH client to the Linux workstation.

While keeping the SSH connection, open your vnc client on PCMac and connect to “localhost:x/”. You may be prompt for the password you entered when you run vncserver for the first time. Now you can start Matlab from an xterm window by

matlab &

When you disconnect your SSH client from the Linux workstation, the graphical session, as well as any programs you have started under the session, will continue running. You will recover the graphical interface once you reconnect through SSH and restart the VNC client.

After you finish all your Matlab jobs, you can close the graphical session and release port x by

vncserver -kill :x

If you Matlab still runs, running this command will kill Matlab.