在win10安装wsl2和图形化界面,报错积累Error: cannot open display: localhost:0,XLaunch黑屏
一、安装wsl2(ubuntu20.04)
(由于某些资源是外网资源,下载速度可能特别慢,需要采用特殊上网)
(1)准备
检查更新
勾选三个选项
控制面板——>卸载程序
重启。
下载Linux内核更新包
点击下载linux内核更新包
双击更新包安装。
可以直接参考官网给出的步骤。官网指导参考
(2)Ubuntu下载和安装(两种方法):
1、第一种:官网或者Microsoft Store下载(默认安装位置,如果你想安装在其他位置,看第二种方法)
Microsoft Store
迅雷下载 提取码:a4wc
2、第二种:将wsl选择安装在非系统盘
手动下载适用于 Linux 的 Windows 子系统发行版包
将下载下来的.appx文件改为.zip文件解压到想要安装的位置
点击安装。
wsl 改为wsl2
查看自身发行版本:wsl --list --verbose
或 wsl -l -v
若要设置发行版,请运行:wsl --set-version <Distro> 2
并且确保将 替换为你的发行版的实际名称。如:wsl --set-version Ubuntu-20.04 2
此外,如果要使 WSL 2 成为你的默认体系结构,可以通过此命令执行该操作:wsl --set-default-version 2
二、图形化界面的安装
(1)下载VcXsrv
1、官网地址下载
2、迅雷下载: 提取码:zcqx
(2)配置
四个任选一个,点下一步
可以选择保存配置,将配置文件放在桌面下次直接打开使用。
(3)安装相应的组件
输入命令:
sudo apt-get update
sudo apt-get upgrade
升级
再分别输入命令:
sudo apt-get install ubuntu-desktop
sudo apt-get install unity
sudo apt-get install compiz-plugins
sudo apt-get install compizconfig-settings-manager
耐心等待,约三十分钟左右。
输入命令:sudo vim ~/.bashrc
进入编辑模式在最后插入下面命令, 保存退出。
export DISPLAY=`cat /etc/resolv.conf | grep nameserver | awk '{print $2}'`:0
如图:
输入下方命令,刷新一下
source ~/.bashrc
接着输入命令sudo ccsm
,设置需要的功能
选择OK
选择如下(可以根据需求选择):
选择完毕后,close
回到终端输入:sudo compiz
成功了!
错误积累:
问题1:错误信息:Error: cannot open display: localhost:0
解决方法:
输入命令:sudo vim ~/.bashrc
,插入
export DISPLAY=`cat /etc/resolv.conf | grep nameserver | awk '{print $2}'`:0
然后敲ESC :wq保存退出。
问题2 输入sudo compiz
后出现如下运行结果,XLaunch且一直处于黑屏,看不到桌面。
compiz (core) - Info: Loading plugin: core
compiz (core) - Info: Starting plugin: core
compiz (core) - Info: Loading plugin: ccp
compiz (core) - Info: Starting plugin: ccp
compizconfig - Info: Backend : ini
compizconfig - Info: Integration : true
compizconfig - Info: Profile : default
可能是由于没有勾选如图所示:
或者由于发生冲突,被取消勾选了,
解决办法:
重启 XLaunch,执行sudo ccsm
,重新将ubuntu unity plugin勾选。再执行sudo compiz
。