Notes 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进入 (按键因人而异). (因为不了解BIOS系统遇到过的白痴情况: 自然重启正常, 按F2重启后主板boot绿灯常亮, 显示屏无输出, 折腾了半天技术人员怀疑到了显示器上, 还真是这样😵 我连了三个显示器, 其中一个不插电, 后来插了电发现BIOS界面就显示在这个屏幕上. 看了一眼主板, 发现绿灯常亮, 也就是说绿灯常亮是在BIOS界面内的意思)
    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

常用命令

AMD64 or Intel x86 - how to check?

Ununtu Explaination Reference
lsb-release -a 查看Ubuntu版本
sudo apt update && sudo apt -y upgrade 更新
clear 清屏
hostname -I 查看IP
dpkg -s [package name] |grep '^Version:' 查看包的版本 How can I find the version number of an installed package via dpkg?
wsl.exe –shutdown 重启 Rebooting Ubuntu on Windows without rebooting Windows?
trash-empty 清理垃圾 Four Ways to Empty the Trash/Recycle Bin in Ubuntu
explorer.exe . 打开资源管理器 How Do I Transfer Files from WSL to Windows - Linux Hint, How to open windows explorer from current working directory of WSL shell?
... 2>&1 tee output.txt 终端输出并存档 What does 2>&1 | tee mean?
grep -rnw '/path/to/somewhere/' -e 'pattern' 查找内容 How to find all files containing specific text (string) on Linux
watch --interval 2 nvidia-smi 周期执行命令 watch - execute a program periodically, showing output fullscreen
df -h 查看储存空间 How do I find the amount of free space on my hard drive?
WSL Explaination Reference
wsl –shutdown 关闭
wsl –list –online 查看可用的发布版本 Change the default Linux distribution installed - Microsoft Docs
wsl –install -d 下载某发布版本 🔼
wsl –list –verbose 查看版本 Check which version of WSL you are running - Microsoft Docs
wsl –set-default-version <Version#> 设置版本 🔼
wsl –setdefault 设置名字 🔼
wsl -d 运行 🔼

Windows Manager

Screen Tmux
List screen -ls tmux ls / Ctrl+B+S (list-sessions), Esc
New screen -S [name] tmux new -s [name]
Detach Ctrl+A+D (:detach) Ctrl+B+D (:detach)
Attach screen -r [name] tmux attach-session -t mysession / Ctrl+B+S, Enter
Kill screen -X -S [session to kill] quit tmux kill-session -t mysession / Ctrl+B+X
Reference Screen User’s Manual
How To Use Linux Screen
How To Set Up a Minecraft Server on Linux
How to Use tmux on Linux (and Why It’s Better Than Screen)
Tmux Cheat Sheet & Quick Reference

Find

Find Explaination Reference
find / -size +10M -size -12M -ls Find files between 10MiB and 12MiB. What's a command line way to find large files/directories to remove and free up space?

常用快捷键

Switch 切屏

  • Setting special keys as keyboard shortcuts: 详细介绍了快捷键的设置方式, 如下三条就能搞定

    1
    2
    3
    gsettings get org.gnome.desktop.wm.keybindings switch-windows
    gsettings set org.gnome.desktop.wm.keybindings switch-windows "['<Alt>Tab']"
    gsettings reset org.gnome.desktop.wm.keybindings switch-windows
  • How to disable/rebind Super+` in Ubuntu 17.10 (gnome)?: Lpgfmk给出了置为空的方式, 即设置为"[]"

  • How to Fix the Alt Tab in Remote Desktop (RDP) Sessions: 搞了半天都不行, 发现不是Ubuntu设置的锅, 远程控制在Local ResourcesKeyboard中把设置改一下就好了

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

装anaconda的例子, 见[How To Install Anaconda on Ubuntu 18.04 Quickstart]

1
2
3
cd /tmp
curl -O https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh
bash Anaconda3-2019.03-Linux-x86_64.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

czet88/OCT_Benders

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

具体报错如下:

1
2
3
4
5
6
7
8
(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

原因就是没装CPLEX, 保姆教程见How to install CPLEX on Ubuntu 20.4, 装好后把Makefile中的CPLEXDIR = ../../../../encs/pkg/cplex-12.7.1/root/cplex改为CPLEXDIR = /opt/ibm/ILOG/CPLEX_Studio221/cplex/.

undefined reference to `dladdr'

具体报错如下:

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'
......

解决方法见Compilation of MAX_HS solver with IBM CPLEX, 具体为把Makefile中的CLNFLAGS = -lcplex -lm -lpthread改为CLNFLAGS = -lcplex -lm -lpthread -ldl.

CPLEX

  • Installation of IBM ILOG CPLEX Optimization Studio on Linux Platforms

    The installer for IBM ILOG CPLEX Optimization Studio is distributed as a .bin file cplex_studioXXX.linux-x86-64.bin. .bin files are Linux self extracting files. Once you download the installer, follow the steps below:

    1. Make sure the .bin file is executable. If necessary, change its permission using the chmod command from the directory where the .bin is located: chmod +x cplex_studioXXX.linux-x86-64.bin
    2. Enter the following command to start the installation process: ./cplex_studioXXX.linux-x86-64.bin
  • Installing CPLEX Optimization Studio

  • How do I download CPLEX Optimization Studio?

视频中How to install CPLEX on Ubuntu 20.4使用的安装文件为cplex_studio128.linux-x86.bin应是版本12.8.0.0的CPLEX; 查找之前的安装路径是/opt/ibm/ILOG/CPLEX_Studio_Community201/cplex. 然而现在最新的版本是22.1.0, 而且免费版本可能有性能限制, czet88/OCT_Benders的奇怪报错可能是上述原因导致的.

先卸载旧版本的CPLEX, 见[Uninstalling CPLEX Optimization Studio](https://www.ibm.com/docs/en/icos/12.9.0?topic=v1290-uninstalling-cplex-optimization-studio):

1
2
3
sudo find / -name cplex
sudo find /opt/ibm/ -name Uninstall
sudo /opt/ibm/ILOG/CPLEX_Studio_Community201/Uninstall/Uninstall

安装时的一些有用信息:

  • Default Install Folder: /opt/ibm/ILOG/CPLEX_Studio221

  • Python:

    1
    2
    3
    4
    5
    If you want to use the CPLEX or CP Optimizer engines through their Python
    APIs, you need to tell Python where to find them. To do so, enter the
    following command into a terminal :
    <<<<<<
    python /opt/ibm/ILOG/CPLEX_Studio221/python/setup.py install

Anacodna & Pycharm

How to install Anaconda on WSL Windows 10 using Ubuntu Linux App

Configure an interpreter using WSL | PyCharm - JetBrains: 注意一定要浏览到可执行文件python, 若浏览到环境所在文件夹会报错process finish with exit code 0

Pygame

Pettingzoo的Pistonball渲染后报错pygame.error: windows not available; 而pygame.init()后报错

1
2
3
4
5
6
7
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory

尚未解决, 见pygame tries to use alsa.

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".

Microsoft Store Erro Code 0x80190001

无法连接应用商城, 设置 → 选择网络和Internet → 代理, 关闭后恢复正常, 见微软商店,打开就显示无法加载该页面 代码0x80131500,这个情况怎么解决? - 甘蔗的回答 - 知乎.

wsl failed to fetch archive

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Need to get 217 kB/54.7 MB of archives.
After this operation, 210 MB of additional disk space will be used.
Err:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 fonts-quicksand all 0.2016-2
Connection failed [IP: 185.125.190.39 80]
Err:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 libfcitx-utils0 amd64 1:4.2.9.7-3
Connection failed [IP: 91.189.91.38 80]
Err:3 http://archive.ubuntu.com/ubuntu focal/universe amd64 libfcitx-gclient1 amd64 1:4.2.9.7-3
Connection failed [IP: 185.125.190.39 80]
Err:4 http://archive.ubuntu.com/ubuntu focal/universe amd64 libfcitx-config4 amd64 1:4.2.9.7-3
Connection failed [IP: 91.189.91.38 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fonts-quicksand/fonts-quicksand_0.2016-2_all.deb Connection failed [IP: 185.125.190.39 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fcitx/libfcitx-utils0_4.2.9.7-3_amd64.deb Connection failed [IP: 91.189.91.38 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fcitx/libfcitx-gclient1_4.2.9.7-3_amd64.deb Connection failed [IP: 185.125.190.39 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fcitx/libfcitx-config4_4.2.9.7-3_amd64.deb Connection failed [IP: 91.189.91.38 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
  • Apt-get update and apt-get upgrade fail #4435: 试了关VPN, 在/etc/resolv.conf里写入nameserver 8.8.8.8, 都没有用
  • E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? [duplicate]: 指出sudo apt-get cleansudo apt-get update但没有解决问题
  • Unable to fetch some archives - recently modified ubuntu package sources [duplicate]: 指出可能是要换个镜像, 观察报错信息得知是http://archive.ubuntu.com/ubuntu focal/universe无法连接, 于是在Change Ubuntu 18.04 update source to mirror site in China找到了阿里云镜像, 即把archive.ubuntu.com替换为mirrors.aliyun.com, 随后在/etc/apt/sources.list中的focal/universe项把网址替换一下就好了!

占用空间过大

  • How do I get back unused disk space from ubuntu on wsl2?: 减少ext4.vhdx的空间


    title: Notes on Ubuntu date: 2021-09-17 16:49:17 tags:
  • Notes
  • Ubuntu categories:
  • [Notes] mathjax: False copyright: true

要用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进入 (按键因人而异). (因为不了解BIOS系统遇到过的白痴情况: 自然重启正常, 按F2重启后主板boot绿灯常亮, 显示屏无输出, 折腾了半天技术人员怀疑到了显示器上, 还真是这样😵 我连了三个显示器, 其中一个不插电, 后来插了电发现BIOS界面就显示在这个屏幕上. 看了一眼主板, 发现绿灯常亮, 也就是说绿灯常亮是在BIOS界面内的意思)
    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

常用命令

AMD64 or Intel x86 - how to check?

Ununtu 含义 参见
lsb-release -a 查看Ubuntu版本
sudo apt update && sudo apt -y upgrade 更新
clear 清屏
hostname -I 查看IP
dpkg -s [package name] |grep '^Version:' 查看包的版本 How can I find the version number of an installed package via dpkg?
wsl.exe –shutdown 重启 Rebooting Ubuntu on Windows without rebooting Windows?
trash-empty 清理垃圾 Four Ways to Empty the Trash/Recycle Bin in Ubuntu
explorer.exe . 打开资源管理器 How Do I Transfer Files from WSL to Windows - Linux Hint, How to open windows explorer from current working directory of WSL shell?
... 2>&1 tee output.txt 终端输出并存档 What does 2>&1 | tee mean?
grep -rnw '/path/to/somewhere/' -e 'pattern' 查找内容 How to find all files containing specific text (string) on Linux
watch --interval 2 nvidia-smi 周期执行命令 watch - execute a program periodically, showing output fullscreen
screen -S mc # 创建新的窗口
screen -ls # 查看运行列表
cd minecraft_server.1.15.2/
bash start-game.sh
screen -X -S [session to kill] quit # 删除detached screen
screen -r mc # 离线运行开始后,每次进入shell查看运行情况
后台运行进程
screen tmux
List screen -ls tmux ls / Ctrl+B+S (list-sessions), Esc
New screen -S [name] tmux new -s [name]
Detach Ctrl+A+D (:detach) Ctrl+B+D (:detach)
Attach screen -r [name] tmux attach-session -t mysession / Ctrl+B+S, Enter
Kill screen -X -S [session to kill] quit tmux kill-session -t mysession / Ctrl+B+X
Reference Screen User’s Manual
How To Use Linux Screen
How To Set Up a Minecraft Server on Linux
How to Use tmux on Linux (and Why It’s Better Than Screen)
Tmux Cheat Sheet & Quick Reference
WSL 含义 参见
wsl –shutdown 关闭
wsl –list –online 查看可用的发布版本 Change the default Linux distribution installed - Microsoft Docs
wsl –install -d 下载某发布版本 🔼
wsl –list –verbose 查看版本 Check which version of WSL you are running - Microsoft Docs
wsl –set-default-version <Version#> 设置版本 🔼
wsl –setdefault 设置名字 🔼
wsl -d 运行 🔼

常用快捷键

Switch 切屏

  • Setting special keys as keyboard shortcuts: 详细介绍了快捷键的设置方式, 如下三条就能搞定

    1
    2
    3
    gsettings get org.gnome.desktop.wm.keybindings switch-windows
    gsettings set org.gnome.desktop.wm.keybindings switch-windows "['<Alt>Tab']"
    gsettings reset org.gnome.desktop.wm.keybindings switch-windows
  • How to disable/rebind Super+` in Ubuntu 17.10 (gnome)?: Lpgfmk给出了置为空的方式, 即设置为"[]"

  • How to Fix the Alt Tab in Remote Desktop (RDP) Sessions: 搞了半天都不行, 发现不是Ubuntu设置的锅, 远程控制在Local ResourcesKeyboard中把设置改一下就好了

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

装anaconda的例子, 见[How To Install Anaconda on Ubuntu 18.04 Quickstart]

1
2
3
cd /tmp
curl -O https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh
bash Anaconda3-2019.03-Linux-x86_64.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

czet88/OCT_Benders

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

具体报错如下:

1
2
3
4
5
6
7
8
(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

原因就是没装CPLEX, 保姆教程见How to install CPLEX on Ubuntu 20.4, 装好后把Makefile中的CPLEXDIR = ../../../../encs/pkg/cplex-12.7.1/root/cplex改为CPLEXDIR = /opt/ibm/ILOG/CPLEX_Studio221/cplex/.

undefined reference to `dladdr'

具体报错如下:

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'
......

解决方法见Compilation of MAX_HS solver with IBM CPLEX, 具体为把Makefile中的CLNFLAGS = -lcplex -lm -lpthread改为CLNFLAGS = -lcplex -lm -lpthread -ldl.

CPLEX

  • Installation of IBM ILOG CPLEX Optimization Studio on Linux Platforms

    The installer for IBM ILOG CPLEX Optimization Studio is distributed as a .bin file cplex_studioXXX.linux-x86-64.bin. .bin files are Linux self extracting files. Once you download the installer, follow the steps below:

    1. Make sure the .bin file is executable. If necessary, change its permission using the chmod command from the directory where the .bin is located: chmod +x cplex_studioXXX.linux-x86-64.bin
    2. Enter the following command to start the installation process: ./cplex_studioXXX.linux-x86-64.bin
  • Installing CPLEX Optimization Studio

  • How do I download CPLEX Optimization Studio?

视频中How to install CPLEX on Ubuntu 20.4使用的安装文件为cplex_studio128.linux-x86.bin应是版本12.8.0.0的CPLEX; 查找之前的安装路径是/opt/ibm/ILOG/CPLEX_Studio_Community201/cplex. 然而现在最新的版本是22.1.0, 而且免费版本可能有性能限制, czet88/OCT_Benders的奇怪报错可能是上述原因导致的.

先卸载旧版本的CPLEX, 见[Uninstalling CPLEX Optimization Studio](https://www.ibm.com/docs/en/icos/12.9.0?topic=v1290-uninstalling-cplex-optimization-studio):

1
2
3
sudo find / -name cplex
sudo find /opt/ibm/ -name Uninstall
sudo /opt/ibm/ILOG/CPLEX_Studio_Community201/Uninstall/Uninstall

安装时的一些有用信息:

  • Default Install Folder: /opt/ibm/ILOG/CPLEX_Studio221

  • Python:

    1
    2
    3
    4
    5
    If you want to use the CPLEX or CP Optimizer engines through their Python
    APIs, you need to tell Python where to find them. To do so, enter the
    following command into a terminal :
    <<<<<<
    python /opt/ibm/ILOG/CPLEX_Studio221/python/setup.py install

Anacodna & Pycharm

How to install Anaconda on WSL Windows 10 using Ubuntu Linux App

Configure an interpreter using WSL | PyCharm - JetBrains: 注意一定要浏览到可执行文件python, 若浏览到环境所在文件夹会报错process finish with exit code 0

Pygame

Pettingzoo的Pistonball渲染后报错pygame.error: windows not available; 而pygame.init()后报错

1
2
3
4
5
6
7
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory

尚未解决, 见pygame tries to use alsa.

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".

Microsoft Store Erro Code 0x80190001

无法连接应用商城, 设置 → 选择网络和Internet → 代理, 关闭后恢复正常, 见微软商店,打开就显示无法加载该页面 代码0x80131500,这个情况怎么解决? - 甘蔗的回答 - 知乎.

wsl failed to fetch archive

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Need to get 217 kB/54.7 MB of archives.
After this operation, 210 MB of additional disk space will be used.
Err:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 fonts-quicksand all 0.2016-2
Connection failed [IP: 185.125.190.39 80]
Err:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 libfcitx-utils0 amd64 1:4.2.9.7-3
Connection failed [IP: 91.189.91.38 80]
Err:3 http://archive.ubuntu.com/ubuntu focal/universe amd64 libfcitx-gclient1 amd64 1:4.2.9.7-3
Connection failed [IP: 185.125.190.39 80]
Err:4 http://archive.ubuntu.com/ubuntu focal/universe amd64 libfcitx-config4 amd64 1:4.2.9.7-3
Connection failed [IP: 91.189.91.38 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fonts-quicksand/fonts-quicksand_0.2016-2_all.deb Connection failed [IP: 185.125.190.39 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fcitx/libfcitx-utils0_4.2.9.7-3_amd64.deb Connection failed [IP: 91.189.91.38 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fcitx/libfcitx-gclient1_4.2.9.7-3_amd64.deb Connection failed [IP: 185.125.190.39 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fcitx/libfcitx-config4_4.2.9.7-3_amd64.deb Connection failed [IP: 91.189.91.38 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
  • Apt-get update and apt-get upgrade fail #4435: 试了关VPN, 在/etc/resolv.conf里写入nameserver 8.8.8.8, 都没有用
  • E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? [duplicate]: 指出sudo apt-get cleansudo apt-get update但没有解决问题
  • Unable to fetch some archives - recently modified ubuntu package sources [duplicate]: 指出可能是要换个镜像, 观察报错信息得知是http://archive.ubuntu.com/ubuntu focal/universe无法连接, 于是在Change Ubuntu 18.04 update source to mirror site in China找到了阿里云镜像, 即把archive.ubuntu.com替换为mirrors.aliyun.com, 随后在/etc/apt/sources.list中的focal/universe项把网址替换一下就好了!

占用空间过大

  • How do I get back unused disk space from ubuntu on wsl2?: 减少ext4.vhdx的空间 >>>>>>> dab0645bed89d54cfc87e455a69f2b83c991ce63