Note on Ubuntu

要用Ubuntu的一些个环境: PettingZoo.

Win10下配置Ubuntu可视化窗口

Ubuntu on Windows

太长不看版, 下载安装到GUI运行一条龙: WSL2 Ubuntu GUI, 其代码见wsl2/ubuntu_gui_youtube.

  1. 安装WSL2和Ubuntu, Windows Subsystem for Linux Installation Guide for Windows 10.

    Windows Subsystem for Linux (WSL) is a compatibility layer for running Linux binary executables (in ELF format) natively on Windows 10, Windows 11,[2] and Windows Server 2019.

    Ubuntu (/ʊˈbʊntuː/ uu-BUUN-too)[7] (Stylized as ubuntu) is a Linux distribution based on Debian and composed mostly of free and open-source software.[8][9][10] Ubuntu is officially released in three editions: Desktop,[11] Server,[12] and Core[13] for Internet of things devices[14] and robots.[15][16] All the editions can run on the computer alone, or in a virtual machine.[17] Ubuntu is a popular operating system for cloud computing, with support for OpenStack.[18] Ubuntu's default desktop has been GNOME, since version 17.10.

  2. 安装过程最麻烦的报错是Error 0x80370102 The Virtual machine could not be started because a required feature is not installed .... #436, 解决方法可参照ktmn的回答, 具体如下:

    1. win+R → 键入msinfo32后回车 → 查看BIOS Mode的值, 见How to Fix UEFI Firmware Settings Missing Windows 10 [Partition Magic].
      1. 若为UEFI, win+I → 搜索BIOS → 点击Advanced startup下的Restart now, 之后依次点击TroubleshootAdvanced optionsUEFI Firmware Settings即可进入BIOS, 见How to enter the BIOS on a Windows 10 PC
      2. 若为Legacy, 则只能重启电脑手动进入BIOS. 若电脑重启速度过快, 则按电源旁边的重启键强制重启, 按F2进入 (按键因人而异).
    2. 进入BIOS, 搜索Virtualization并启动.
  3. GUI运行:sudo /etc/init.d/xrdp start, 详见WSL2 Ubuntu GUI.

云服务器

You are here: Home / Tutorial / How To Check Your IP Address in Ubuntu [Beginner’s Tip] How To Check Your IP Address in Ubuntu [Beginner’s Tip]: 给出了详细的步骤和图示, 并且有对ufw的简单使用教程.

记录在Linux系统Ubuntu 20.04中安装xrdp远程桌面连接RDP: 唯一看了之后才成功的😠, 重要的几点如下:

  • 安装桌面后重启服务器.
  • 避开Windows的3389端口, 比如文中使用了13389端口

同时需要注意IP (以下使用0.0.0.0代替) 的获取方式有

  • ipconfigEthernet adapter 以太网中的IPv4 Address.
  • 一直点你的网络直到进入Settings, 查看Properties中的IPv4 address.

具体的过程如下:

1
2
3
sudo apt update
sudo apt install ubuntu-desktop
sudo apt install xrdp
1
2
3
4
5
6
sudo ufw status
sudo ufw reset
sudo ufw enable
sudo ufw allow from 0.0.0.0 to any port 13389
sudo ufw reload
sudo ufw status
1
2
3
sudo sed -i 's/3389/13389/g' /etc/xrdp/xrdp.ini
sudo systemctl status xrdp
sudo systemctl restart xrdp

之后又会遇到很多问题:

  • 打开黑屏或者报错😡

    1
    2
    3
    - Sorry, Ubuntu 20.04 has experienced an internal error.
    - Send problem report to the developers?
    If you notice further rpoblems, try restarting the computer.

    解决方法为How did I connect to Ubuntu 18.04 Xfce 4 desktop from Windows 7 via xrdp?, 和Ubuntu on Windows的配置类似.

  • 打不开命令行👿, 报错

    1
    2
    - Failed to execute default Ternimal Emulator.
    Input/output error.

    解决方法见Getting input/output error running anything on remote desktop, 具体为安装并选择xfce4-terminal.

    1
    2
    sudo apt-get install xfce4-terminal
    sudo update-alternatives --config x-terminal-emulator

常用命令

Ununtu命令 含义 参见
lsb-release -a 查看Ubuntu版本
sudo apt update && sudo apt -y upgrade 更新
clear 清屏
hostname -I 查看IP
Terminal命令 含义 参见
dpkg -s <packagename> | grep '^Version:' 查看包的版本 How can I find the version number of an installed package via dpkg?

Installation

App: Run Linux GUI apps on the Windows Subsystem for Linux (preview)

.deb:

Install/Uninstall .deb files

.tar.tz:

  1. 若有./config, 见How do I install a .tar.gz (or .tar.bz2) file?, 具体为:

    1
    2
    3
    4
    tar xvzf PACKAGENAME.tar.gz 
    ./configure
    make
    sudo make install
  2. 若无, 见How to Install Python IDE PyCharm in Ubuntu and Other Linux Distributions, 具体为

    1
    2
    3
    4
    5
    tar -xzf file.tar.gz
    cd file
    cd bin
    chmod u+x file.sh
    sh file.sh

.sh:

1
2
chmod u+x file.sh
sh file.sh

google-research/football

Imported target "Boost::filesystem" includes non-existent path "/include" in its interface_include_directories #311

1
sudo ln -s /usr/include /include

CPLEX

czet88/OCT_Benders

每日一破防.

fatal error: cplex.h: No such file or directory

就是没装CPLEX, 保姆教程见How to install CPLEX on Ubuntu 20.4, 具体报错如下:

1
2
3
4
5
6
7
8
9
(base) carlos@DESKTOP-R4H3HQA:~/Github/OCT_Benders/src$ make
gcc -O2 -c -m64 -fPIC -fno-strict-aliasing -I../../../../encs/pkg/cplex-12.7.1/root/cplex/include/ilcplex/ main.c -o main.o
In file included from main.c:1:
headers.h:7:10: fatal error: cplex.h: No such file or directory
7 | #include "cplex.h"
| ^~~~~~~~~
compilation terminated.
make: *** [Makefile:36: main.o] Error 1

undefined reference to `dladdr'

Compilation of MAX_HS solver with IBM CPLEX, 具体报错如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
(base) carlos@DESKTOP-R4H3HQA:~/Github/OCT_Benders/src$ make
gcc -O2 -m64 -fPIC -fno-strict-aliasing -I/opt/ibm/ILOG/CPLEX_Studio_Community201/cplex/include/ilcplex/ -L/opt/ibm/ILOG/CPLEX_Studio_Community201/cplex/lib/x86-64_linux/static_pic main.o read_data.o output_data.o TwoIndex.o ThreeIndex.o FourIndex.o Heuristics.o Benders.o Benders_master.o Benders_subproblem.o CLM_utils.o CLM_graph.o CLM_OCSTP.o -o main -lcplex -lm -lpthread
/bin/ld: /opt/ibm/ILOG/CPLEX_Studio_Community201/cplex/lib/x86-64_linux/static_pic/libcplex.a(load_dll_static_patched.o): in function `_Init_MKL_Loader':
load_dll.c:(.text+0x20cf): undefined reference to `dladdr'
/bin/ld: /opt/ibm/ILOG/CPLEX_Studio_Community201/cplex/lib/x86-64_linux/static_pic/libcplex.a(mkl_memory_patched.o): in function `mkl_serv_set_memory_limit':
mkl_memory.c:(.text+0x5d1): undefined reference to `dlopen'
/bin/ld: mkl_memory.c:(.text+0x5ee): undefined reference to `dlsym'
/bin/ld: mkl_memory.c:(.text+0x62f): undefined reference to `dlclose'
/bin/ld: mkl_memory.c:(.text+0x642): undefined reference to `dlsym'
/bin/ld: mkl_memory.c:(.text+0x658): undefined reference to `dlsym'
/bin/ld: mkl_memory.c:(.text+0x73f): undefined reference to `dlerror'
/bin/ld: mkl_memory.c:(.text+0x7a9): undefined reference to `dlopen'
/bin/ld: mkl_memory.c:(.text+0x84d): undefined reference to `dlopen'
......

Troubling Shooting

黑屏问题

Ubuntu 18.04, Blank screen after login from Windows 10 #1358

  1. Jarez95好答案, 但没看.

  2. affansaied给出了两种GUI的配置方法, 我没试成功.

  3. (没有效果)

    更改startwm.sh的内容, 见How to Fix Black Screen When Remote Desktop to Ubuntu Desktop 20 from Windows 10 Using XRDP.原文内容见Restore contents of /etc/xrdp/startwm.sh, 有两处需要修改:

    1. wsl2/ubuntu_gui_youtube
    2. How to Fix Black Screen When Remote Desktop to Ubuntu Desktop 20 from Windows 10 Using XRDP

    更改后内容如下:

    ERROR: No matching distribution found for setuptools

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    #!/bin/sh
    # xrdp X session start script (c) 2015, 2017 mirabilos
    # published under The MirOS Licence

    if test -r /etc/profile; then
    . /etc/profile
    fi

    if test -r /etc/default/locale; then
    . /etc/default/locale
    test -z "${LANG+x}" || export LANG
    test -z "${LANGUAGE+x}" || export LANGUAGE
    test -z "${LC_ADDRESS+x}" || export LC_ADDRESS
    test -z "${LC_ALL+x}" || export LC_ALL
    test -z "${LC_COLLATE+x}" || export LC_COLLATE
    test -z "${LC_CTYPE+x}" || export LC_CTYPE
    test -z "${LC_IDENTIFICATION+x}" || export LC_IDENTIFICATION
    test -z "${LC_MEASUREMENT+x}" || export LC_MEASUREMENT
    test -z "${LC_MESSAGES+x}" || export LC_MESSAGES
    test -z "${LC_MONETARY+x}" || export LC_MONETARY
    test -z "${LC_NAME+x}" || export LC_NAME
    test -z "${LC_NUMERIC+x}" || export LC_NUMERIC
    test -z "${LC_PAPER+x}" || export LC_PAPER
    test -z "${LC_TELEPHONE+x}" || export LC_TELEPHONE
    test -z "${LC_TIME+x}" || export LC_TIME
    test -z "${LOCPATH+x}" || export LOCPATH
    fi

    # [How to Fix Black Screen When Remote Desktop to Ubuntu Desktop 20 from Windows 10 Using XRDP]
    # (https://www.youtube.com/watch?v=0PlG6vCOmjc)
    unset DBUS_SESSION_BUS_ADDRESS
    unset XDG_RUNTIME_DIR
    . $HOME/.profile

    if test -r /etc/profile; then
    . /etc/profile
    fi

    # test -x /etc/X11/Xsession && exec /etc/X11/Xsession
    # exec /bin/sh /etc/X11/Xsession

    # xfce
    startxfce4

  4. 终极办法, 重启xrdp.

    1
    sudo /etc/init.d/xrdp restart
  5. 貌似解决了的办法, 进入Xfce Power ManagerDisplay, Security把会熄屏的选项调成Never.

XX is Already Running

这是黑屏后附带产生的问题, 可以通过ApplicationsSystemTask Manager观察其运行状况, 也可以直接用pkill -f XX关闭, 见Pycharm is "Already running" while trying to launch from ubuntu terminalfuras的评论.

curl: (60) SSL certificate problem: unable to get local issuer certificate

今天又被Ubuntu整破防了, 起因是想搞点DCMST的实验, 比如这个malbarbo/dcmstp-instances, 这次我学乖了直接上Ubuntu, make时跳标题错误, 我就看了

  • SSL Certificate Verification
  • curl: (60) SSL certificate problem: unable to get local issuer certificate
  • How do you add a certificate authority (CA) to Ubuntu?, 这里写了个命名坑

我滴操作如下

  1. 下载cacert.pem
  2. 运行mv /home/carlos/downloads/mycert.crt /usr/local/share/ca-certificates/移动并进入
  3. sudo mv ca-certificates.crt mycert.crt将其命名为mycert.crt
  4. 上述目录运行sudo mv ca-certificates.crt mycert.crt
  5. 命名环境变量export CURL_CA_BUNDLE="/usr/local/share/ca-certificates/mycert.crt"

搞不定了, 歇了...

好了我最后靠把Makefile里所有的curl都加上-k解决了, 见curl: (60) SSL certificate problem: unable to get local issuer certificate.

(然而这个库的链接挂了, 搞了半天还是用不了, 我暴哭😢)

ls: command not found

环境变量烂了, 每次进terminal都报错.

1
2
3
4
5
6
ubuntu@VM-4-5-ubuntu:~$ ls
Command 'ls' is available in the following places
* /bin/ls
* /usr/bin/ls
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
ls: command not found

解决方法见Command 'ls' is available in '/bin/ls', 具体为

  • .bashrc'中加入export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"`.
  • .profile中加入PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games".
  • 保证/etc/environmentPATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin".