windows10下wsl2、Ubuntu20.04、Rust、vscode安装配置总结

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

1、 Microsoft Store 中安装 windows Terminal

2、 更新 wsl 或 Microsoft Store 中安装 wsl2

wsl --version  # 查看 wsl 版本
wsl --update   # 更新 wsl

3、 设置wsl2为默认

wsl --set-default-version 2

4、 Microsoft Store 中安装 Ubuntu 20.04.5 LTS

wsl --install   # 也可以命令安装

5、 wsl2 迁移 ubuntu

5.1 LxRunOffline 安装并添加至环境变量

# git库
https://gitcode.net/mirrors/ddosolitary/lxrunoffline?utm_source=csdn_github_accelerator
# 下载地址
https://github.com/DDoSolitary/LxRunOffline/releases

5.2 查看安装的 ubuntu系统

LxRunOffline list  # 输出 Ubuntu-20.04

5.3 停止 wsl

wsl --shutdown

5.4 移动 ubuntu 文件

  • 先在d盘或其他地方建立文件夹D:\ubuntu_wsl
LxRunOffline move -n Ubuntu-20.04 -d D:\ubuntu_wsl

5.5 查看路径

LxRunOffline get-dir -n Ubuntu-20.04

6、 更新源

sudo vim /etc/apt/source.list
  • 没有权限修改时转换成超级用户
sudo su
  • 或切换默认账户为管理员win命令
ubuntu2004 config --default-user root
  • ubuntu20.04 阿里云源
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
  • 更新系统
sudo apt update && sudo apt upgrade -y

7、 安装 aptitude 包管理工具

sudo apt-get install aptitude

8、 安装gcc

sudo aptitude install build-essential
sudo apt update && sudo apt upgrade -y  # 更新下系统(安装过程中多更新问题就少些)

9、 安装 Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

10、 vscode 相关

  • win中安装 vscode

  • win中安装插件Remote Development

  • ubuntu命令code . 启动 vscode

  • 安装 Rust 插件rust-analyzer、Even Better Toml、rust syntax 、Tabnine

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: windowsUbuntu