一、安装子系统
1.打开控制面板-->程序-->程序和功能,选择启动或关闭windows功能
2.勾选以下功能,安装完成之后,重启系统
3.安装wsl,
按 Win+X, 找到 Windows PowerShell (管理员),并复制执行命令:Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
之后再复制执行命令wsl --update
4.安装ubuntu
进入Microsoft Store 搜索ubuntu ,安装ubuntu 18,安装完成之后启动,输入用户名和密码进入系统
二、安装ubuntu桌面,可以在windows上开发ubuntu桌面程序或打开ubuntu软件开发工具
1.更新源
vim /etc/apt/sources.list
复制阿里云源或清华源
阿里云源
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
清华源
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
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
更新
sudo apt-get update
sudo apt-get upgrade
2. 复制命令 sudo apt-get install xfce4 xfce4-terminal 即可,安装之后就可以在windows启动Ubuntu终端,同时也可以在wsl中进行界面开发
三、wsl相关操作
1.wsl 导入导出
导出:
wsl --export Ubuntu-22.04 D:\Ubuntu.tar
wsl --unregister Ubuntu-22.04
导入:
wsl --import Ubuntu-22.04 D:\Ubuntu D:\Ubuntu.tar --version 2
ubuntu.exe config --default-user aci
2.wsl卸载
wslconfig /u Ubuntu-22.04