Why can't I install MATLAB with the root account in Linux when the installer works for my user account?

803 views (last 30 days)
When I try to run the install script as root on Linux, why am I unable to install MATLAB? I can start the installer normally on my user account.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 10 Feb 2023
Edited: MathWorks Support Team on 10 Feb 2023
This error is related to some of the environment variables from your user account not being passed to root when running the installer. There are 2 specific variables that will cause this, your DISPLAY variable, which will tell the install what screen to start on and XAUTHORITY which gives user permissions to display programs to that screen.
If you are unable to set these variables, please either speak to your IT department for assistance, or install MATLAB to a folder for which you have permissions.
This issue comes in two forms:
  • With no error message or a blank screen
  • With error messages
With no error message or blank screen
If no error message appears when running the MathWorks installer as root, particularly with MATLAB R2021b and later, it may be an issue with an inability to access the X Server. As a workaround, please try the following: 
  • Launch Terminal
  • Type the following in the terminal to allow the root user to access the running X server:
xhost +SI:localuser:root
  • After running the command above try running the installer "sudo ./install"
If this does not work, try the following:
  1. Move the installer folder to /opt/
  2. Give root ownership of the installer folder (for example: chown -R root:root matlab_R2023a_glnxa64)
  3. Run the installer from this folder as root
With error messages


On some distributions, other users are prevented from starting windows on X servers owned by other users. The XAUTHORITY environment variable points to the location of a key on your system that is required to start X applications on that display. Depending on your distribution, this key will be located in different locations. An error relating to XAUTHORITY may appear like the following or with no error message at all:
ERROR: No protocol specified
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':2' as the value of the DISPLAY variable.
The simplest way to get around this is to allow all users on this machine to start programs on this display:
xhost + localhost
If you are connecting to this machine remotely, run the below instead:
xhost +
This will also allow remote users to start programs on this display. After installing MATLAB, you may want to replace these restrictions with either:
xhost - localhost
xhost -


The DISPLAY environment variable tells program what display they should be started on. You will receive an error such as the below:
ERROR: Error: Installation cannot proceed. You may either:1. Set an X11 display, and restart the install process2. Use the silent install feature by specifying the -mode silent option
ERROR: Exception in thread "main" com.google.inject.ProvisionException: Guice provision errors:1) Error injecting constructor, java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment at com.mathworks.instutil.wizard.JEditorPaneHyperlinkHandler.<init>(JEditorPaneHyperlinkHandler.java:57) while locating com.mathworks.instutil.wizard.JEditorPaneHyperlinkHandler while locating com.mathworks.instutil.wizard.HyperlinkHandler for parameter 5 at com.mathworks.wizard.ui.components.SwingComponentFactoryImpl.<init>(SwingComponentFactoryImpl.java:111)
To resolve this, you can temporarily set the DISPLAY variable for root to the value that is set for your user account.
Run the below as your user account:
printenv | grep DISPLAY
This will show your display environment variable. Remember this for later. Now enter the below:
suexport <DISPLAY>
Where <DISPLAY> is the value of the DISPLAY variable from the printenv command.
If none of these suggestions work and you have an internet connection, try using MATLAB Package Manager to install MathWorks Products. The instructions and additional details for it can be found below.
MATLAB Package Manager

Sign in to comment.

More Answers (5)

Gerhard Giefing
Gerhard Giefing on 29 May 2019
I've only SSH access.... there is no Display var in any User or the root... any ideas... only need this server as computing machine... no GUI needed ... have only TUI
Zach Smith
Zach Smith on 25 Aug 2022
Edited: Zach Smith on 2 Nov 2022
@Maël Jeuffrard - no, they couldn't help me. But you can run via Docker and therefore circumvent the install.
The Docker instructions require signing in via the terminal on every start or otherwise having access to a license manager server (we will setup our own license manager server... but that as far as I can tell HAS to be installed via a UI and so we haven't done this yet).
But you can also start Docker with an explicit MAC address, which allows for running it with a regular license (the username is 'matlab' when you activate a license).
I've subsequently learned that it's pretty easy to do X11 forwarding on an Ubuntu server, so only having terminal access should not be a problem when running the installer. But better instructions would help!

Sign in to comment.

José Carlos Ferreira
José Carlos Ferreira on 18 Dec 2016
Edited: David on 17 Jan 2017
export <DISPLAY>
command, returns a natural error if the previous command show us that DISPLAY=:0 and we replace <DISPLAY> by "0" (without quotes).
export 0
This naturally ends up in the following error:
bash: export: `0': not a valid identifier

Sign in to comment.

Tech Support
Tech Support on 2 May 2018
Edited: MathWorks Support Team on 28 Jan 2021
If you are still experiencing this issue, please contact MathWorks support:

Gerhard Giefing
Gerhard Giefing on 29 May 2019
and it its not installing and gives no error

Matthew on 2 Dec 2022
I also was able to call the installer GUI with my user account, but not as root (with sudo). My solution was to copy my .Xauthority file from my home directory to /root/ . Then, I could run the installer as root using sudo bash ./install .


Find more on Introduction to Installation and Licensing in Help Center and File Exchange


No tags entered yet.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!