WSL1-Ubuntu18相关配置,问题解决

  • Post author:
  • Post category:其他




一、问题

微软商店安装Ubuntu后,因识别为WSL2报错,在命令行中输入如下命令即可解决:


wsl --set-default-version 1



二、换源

1.备份list文件

进入目录:

cd /etc/apt/


备份:

sudo cp sources.list sources.list.bak

2.修改list文件:

sudo nano sources.list


将里面的内容全部删除,替换为

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

3.更新软件列表:

sudo apt update



sudo apt upgrade



三、映射系统文件

依次打开文件资源管理器-此电脑-映射网络驱动器,如图所示:



选择驱动器盘符,在文件夹中输入:

Ubuntu18.04版本:

\\wsl$\Ubuntu-18.04


Ubuntu20.04版本:

\\wsl$\Ubuntu-20.04

由此打开系统文件



四、配置桌面

1.安装桌面:

sudo apt install xfce4 xfce4-terminal gtk2-engines-pixbuf libappstream4


2.下载VcXsrv,打开Xlaunch,选择 “one large window” ,“Display number” 设置为 0,Extra settings中将“Native opengl”的勾去掉,其它选项默认,打开窗口

3.修改配置文件

bash:


echo "export DISPLAY=:0.0" >> ~/.bashrc



source ~/.bashrc


zsh:


echo "export DISPLAY=:0.0" >> ~/.zshrc



source ~/.zshrc


4.运行桌面:

startxfce4


在这里插入图片描述

运行成功

注:注销WSL-Ubuntu-18.04:命令行输入

wsl --unregister Ubuntu-18.04



版权声明:本文为qq_45529538原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。