机械蓝:win11系统通过WSL/WSL2安装ubuntu,开启图形桌面
这个链接的文章有图片,说明的比较细致,可以参考
----------------------------------------------------------------------------------------------------
从开始菜单 搜索 ,打开开发者模式。
控制面板>程序>启用或关闭 Windows功能> 打开 1 适用于 Linux的 Windows子系统 打开 2 虚拟机平台
----------------------------------------------------------------------------------------------------
下载 Linux 内核更新包 并安装
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
----------------------------------------------------------------------------------------------------
用管理员身份打开 Powershell 输入以下命令:
wsl --set-default-version 2
这行命令之后安装的所有 Linux 发行版都默认 WSL2 执行
查看版本
wsl -l -v
----------------------------------------------------------------------------------------------------
安装VcXsrv
下载地址:
https://sourceforge.net/projects/vcxsrv/
----------------------------------------------------------------------------------------------------
重启电脑
----------------------------------------------------------------------------------------------------
在 Microsoft store中搜索应用,选择ubuntu 18.04版本进行安装
安装1-2分钟即可,配置好用户名 密码
----------------------------------------------------------------------------------------------------
在ubuntu中配置Xlaunch
ubuntu 中输入
echo "export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0" >> ~/.bashrc
echo "export DISPLAY=<你的计算机名>:0.0" >> ~/.bashrc
source ~/.bashrc
----------------------------------------------------------------------------------------------------
在ubuntu中安装xfce4,如果比较慢,或者安装不成功,更换源为国内源,比如阿里源;
sudo apt install -y xfce4
换源
sudo vim /etc/apt/sources.list
输入49dd,就可以清除所有内容了,然后输入i就可以进行编辑了
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-get -y update && sudo apt-get -y upgrade
----------------------------------------------------------------------------------------------------
打开XLaunch
----------------------------------------------------------------------------------------------------
在ubuntu中启动xfce4服务,ubuntu输入:
startxfce4
----------------------------------------------------------------------------------------------------
后续会有每次重启电脑WSL 虚拟IP变化,导致图像桌面无法显示的问题,可以使用写的脚本解决该问题