Ubuntu无界面安装MATLAB 2021a

Ubuntu无界面安装MATLAB 2021a

系统环境

  • 华为云服务器,可通过堡垒机访问
  • Ubuntu 20.04
  • 操作终端:MobaXterm

安装步骤

准备好的安装文件包括:

Matlab910R2021a_Lin64.iso和Crack文件夹,Crack文件夹里有4个文件:libmwlmgrimpl.solicense.liclicense_server.liclicense_standalone.lic,文件上传到服务器/opt/matlab路径下

安装前注意是否已经有java环境,可以通过java -version测试,如果没有则可以通过apt install default-jdk -y安装最新版jdk,或者通过apt install openjdk-11-jdk安装指定版本。

1. iso文件挂载

  • 创建一个文件夹,用于挂载iso文件:mkdir /media/matlab
  • 创建一个文件夹,作为matlab的安装位置:mkdir /usr/local/matlab/2021a
  • 进行挂载:mount -o loop /opt/matlab/Matlab910R2021a_Lin64.iso /media/matlab

2. 创建激活配置文件

  • 切换到配置文件路径:cd /usr/local/matlab/2021a
  • 创建配置文件:touch activate.ini
  • 添加文件内容:vim activate.ini
isSilent=true 
activateCommand=activateOffline
licenseFile=/opt/matlab/Crack/license_standalone.lic
  • 使文件生效:source activate.ini

3. 开始安装

  • 切换到安装文件路径:cd /media/matlab
  • 执行命令并等待:./install -mode silent -fileInstallationKey 09806-07443-53955-64350-21751-41297 -agreeToLicense yes -licensePath /opt/matlab/Crack/license_standalone.lic -destinationFolder /usr/local/matlab/2021a -activationPropertiesFile /usr/local/matlab/2021a/activate.ini

4. 破解并激活

  • 复制破解文件:cp /opt/matlab/Crack/libmwlmgrimpl.so /usr/local/matlab/2021a/bin/glnxa64/matlab_startup_plugins/lmgrimplcp /opt/matlab/Crack/license.lic /usr/local/matlab/2021a/licenses
  • 运行激活命令:/usr/local/matlab/2021a/bin/activate_matlab.sh -propertiesFile /usr/local/matlab/2021a/activate.ini

5. 取消iso挂载

  • umount -l /media/matlab

6. 将matlab添加到环境变量

  • vim ~/.bashrc,文件最后添加下面内容:
MATLAB_HOME=/usr/local/matlab/2021a
export PATH=$PATH:$MATLAB_HOME/bin
  • 使配置生效:source ~/.bashrc

7. 命令测试

  • matlab -h
Usage:  matlab [-h|-help] | [-n | -e]
                   [v=variant]
                   [-c licensefile] [-display Xdisplay | -nodisplay]
                   [--noFigureWindows]
                   [-nosplash] [-debug]
                   [-softwareopengl | -nosoftwareopengl]
                   [-desktop | -nodesktop | -nojvm]
                   [-batch MATLAB_command | -r MATLAB_command]
                   [-sd folder | -useStartupFolderPref]
                   [-logfile log]
                   [-singleCompThread]
                   [-jdb [port]]
                   [-Ddebugger [options]]
                   [-nouserjavapath]

    -h|-help                - Display arguments.
    -n                      - Display final environment variables,
                              arguments, and other diagnostic
                              information. MATLAB is not run.
    -e                      - Display ALL the environment variables and
                              their values to standard output. MATLAB
                              is not run. If the exit status is not
                              0 on return then the variables and values
                              may not be correct.
    v=variant               - Start the version of MATLAB found
                              in bin/glnxa64/variant instead of bin/glnxa64.
    -c licensefile          - Set location of the license file that MATLAB
                              should use.  It can have the form port@host or
                              be a colon separated list of license files.
                              The LM_LICENSE_FILE and MLM_LICENSE_FILE
                              environment variables will be ignored.
    -display Xdisplay       - Send X commands to X server display, Xdisplay.
                              Linux only.
    -nodisplay              - Do not display any X commands. The MATLAB
                              desktop will not be started. However, unless
                              -nojvm is also provided the Java virtual machine
                              will be started.
    -noFigureWindows        - Disables the display of figure windows in MATLAB.
    -nosplash               - Do not display the splash screen during startup.
    -softwareopengl         - Force MATLAB to start with software OpenGL
                              libraries. Not available on macOS.
    -nosoftwareopengl       - Disable auto-selection of software OpenGL
                              when a graphics driver with known issues is detected.
                              Not available on macOS.
    -debug                  - Provide debugging information especially for X
                              based problems. Linux only.
    -desktop                - Allow the MATLAB desktop to be started by a
                              process without a controlling terminal. This is
                              usually a required command line argument when
                              attempting to start MATLAB from a window manager
                              menu or desktop icon.
    -nodesktop              - Do not start the MATLAB desktop. Use the current
                              terminal for commands. The Java virtual machine
                              will be started.
    -singleCompThread       - Limit MATLAB to a single computational thread. 
                              By default, MATLAB makes use of the multithreading 
                              capabilities of the computer on which it is running.
    -nojvm                  - Shut off all Java support by not starting the
                              Java virtual machine. In particular the MATLAB
                              desktop will not be started.
    -jdb [port]             - Enable remote Java debugging on port (default 4444)
    -batch MATLAB_command   - Start MATLAB and execute the MATLAB command(s) with no desktop
                              and certain interactive capabilities disabled. Terminates
                              upon successful completion of the command and returns exit
                              code 0. Upon failure, MATLAB terminates with a non-zero exit.
                              Cannot be combined with -r.
    -r MATLAB_command       - Start MATLAB and execute the MATLAB_command.
                              Cannot be combined with -batch.
    -sd folder              - Set the MATLAB startup folder to folder, specified as a string.
                              Cannot be combined with -useStartupFolderPref.
    -useStartupFolderPref   - Set the MATLAB startup folder to the value
                              specified by the Initial working folder option
                              in the General Preferences panel.
                              Cannot be combined with -sd.
    -logfile log            - Make a copy of any output to the command window
                              in file log. This includes all crash reports.
    -Ddebugger [options]    - Start debugger to debug MATLAB.
    -nouserjavapath         - Ignore custom javaclasspath.txt and javalibrarypath.txt files.
  • matlab -display Xdisplay
 MATLAB is selecting SOFTWARE OPENGL rendering.

                                                                                                                                                                < M A T L A B (R) >
                                                                                                                                                      Copyright 1984-2021 The MathWorks, Inc.
                                                                                                                                                     R2021a (9.10.0.1602886) 64-bit (glnxa64)
                                                                                                                                                                 February 17, 2021

 
To get started, type doc.
For product information, visit www.mathworks.com.
 
>> 

参考链接