laitimes

Install a Linux development environment above Window 10

author:Cheng Ge blog
I happened to see that you can run Linux on Window, you can use Window to run Linux commands, maybe it can be used to cross-compile, record the following

Confirm the Windows version

Not all Windows supports WSL, so make sure your system version is Windows 10 Build 16237 or later. You can check the system version number through Settings.

Install a Linux development environment above Window 10

Start the WSL service

You need to first enable Windows Subsystem for Linux in Windows.

Open "Control Panel" - > "Programs and Features", select "Enable or turn off Windows features" in the left sidebar, find "Windows Subsystem for Linux" in the dialog box that opens and tick, click [OK] to close the dialog box, wait for the system installation of new features to complete, and restart the computer as prompted.

Install a Linux development environment above Window 10

The Microsoft Store installs a Linux distribution

Install a Linux development environment above Window 10

Configure the user name and password

Install a Linux development environment above Window 10

Replace the source

After installing ubuntu 20.04, the default software update source is foreign, and the use speed in China is very slow, and it needs to be replaced with a domestic source so that the software can be installed and updated normally.

# 首先备份源列表
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup

# 打开sources.list文件
sudo vim /etc/apt/sources.list
           

Edit the /etc/apt/sources.list file and add the Alibaba Cloud image source at the front of the file:

#中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

#添加清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse multiverse
           

Refresh the list

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
           

Modify WSL memory

Open Windows Explorer, enter %UserProfile% in the address bar, create a file in this directory, the name is .wslconfig, and the example of the writing content is as follows (my computer 8GB memory, allocated 2GB of WSL memory, and set the swap partition 4GB)

[wsl2]
memory=20GB
swap=8GB
localhostForwarding=true
           

cmd performs wsl --shutdown to close WSL and reopen it

VSCODE CONSOLE ACCESS

Install a Linux development environment above Window 10
Install a Linux development environment above Window 10

Copyright statement: This article is the original article of "Chengge Blog", in accordance with the CC 4.0 BY-SA copyright license, please attach the original source link and this statement.

Original link: https://www.chengzz.com/398.html