WSL学习笔记

笔者今天了解到了WSL,简单介绍一下:

WSL(Windows Subsystem for Linux)是微软在Windows 10上推出的功能,它允许用户在Windows操作系统中运行本地的Linux发行版。这种功能使得开发人员和系统管理员可以在他们喜欢的Linux环境中使用工具和命令行界面,而无需离开Windows操作系统。

WSL通过在Windows操作系统上提供一个兼容的Linux内核接口来实现,这样用户就可以在Windows中运行原生的Linux二进制文件。它提供了一个完整的Linux系统用户态环境,包括常见的命令行工具、实用程序和应用程序,使得开发、测试和运行Linux应用程序在Windows环境中更加便捷。

WSL有两个主要版本:WSL 1和WSL 2。WSL 1是在Windows内核上通过适配器来运行Linux系统调用的子系统,而WSL 2则使用了一个真正的Linux内核,这使得WSL 2更加接近于原生的Linux体验,并且具有更好的性能和兼容性。

关于WSL的安装:超详细Windows10/Windows11 子系统(WSL2)安装Ubuntu20.04(带桌面环境)_wsl安装ubuntu20.04-优快云博客

在安装gnome桌面环境时候遇到一点问题:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
debianutils : Breaks: x11-common (< 1:7.7+23~) but 1:7.7+19ubuntu14 is to be installed
gdm3 : Depends: gnome-session-bin (>= 3.10) but it is not installable
Depends: gnome-shell (>= 3.19.92) but it is not installable
Recommends: xserver-xephyr but it is not installable

………………


xorg : Depends: xserver-xorg (>= 1:7.7+19ubuntu14) but it is not installable
xwayland : Depends: libgl1 but it is not installable
E: Unable to correct problems, you have held broken packages. 

进行一些更新之后依旧没有解决问题,此时我退出WSL,再进时cmd报错:

 nsenter: cannot open /proc/26/ns/time: No such file or directory

在参考文章

[WSL] [05] 配置systemD 和解决nsenter: cannot open /proc/320/ns/time: No such file or directory 的问题_执行过ubuntu-wsl2-systemd-script.sh ubuntu无法启动-优快云博客

之后,总结解决方法如下:

#先运行
wsl -e bash --norc -m -p
#再运行
sudo nano /usr/sbin/enter-systemd-namespace

然后可以看到如下文本,里面的箭头的参数-a,是错误的

我们把他改成 -m,-p就可以

修改完之后,然后按Ctrl + O保存,并按Ctrl + X退出编辑模式。

之后可以正常启动wsl时

以后只需以管理员身份运行cmd,然后输入“bash”即可进入到Ubuntu系统下。

继续查阅资料后发现:我安装的是Ubuntu22.04版本,和上述安装教程版本不同,而安装gnome桌面环境时的报错是软件源问题导致的,故我替换了软件源:ubuntu | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

4.25更新:学长说不需要图形化界面,于是我就不下载gnome了嘿嘿。不过被安利了一个vscode插件WSL,这个插件支持在vscode下使用WSL。WSL+VSCode食用指南 - 知乎

搭配 VS Code Remote 远程开发扩展在 WSL 下开发 - 知乎

4/28更新:

vscode打开wsl时遇到问题

your 131072x1 screen size is bogus. expect trouble your 131072x1 screen size is bogus

解决方法如下:your 131072x1 screen size is bogus. expect trouble your 131072x1 screen size is bogus-优快云博客

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值