Windows下的Linux子系统 (WSL)

2024-01-18 渥太华微生活
来源:博客园

installubuntu.gif


什么是WSL

WSL: Windows subsystem for Linux,是用于Windows上的Linux的子系统。

作用很简单,可以在Windows系统中获取Linux系统环境,并完全直连计算机硬件,无需通过虚拟机虚拟硬件,不会影响Windows系统本身。

tear-tab.gif


为什么使用WSL

WSL作为自Windows10以来的全新特性正逐步颠覆开发人员的选择。

传统方式下,获取Linux操作系统环境,是安装完整的虚拟机,如VMware。

但使用WSL,是可以以非常轻量化方式,得到Linux的系统环境。


WSL部署

WSL为Windows自带功能,我们只需要把它开启即可。

在搜索里找到控制面板,点击程序,点击启用或关闭Windows功能,向下滑动找到适用于Linux的Windows子系统点击确定进行重启。

3056894-20240117111050986-1612834743.png

在微软商店,搜索Ubuntu,点击下载即可,等待安装成功,就可以去使用了。

(额...失败了)

错误提示是WSL2的问题 (抱歉,没有截图)。


解决WSL2安装错误

查找微软WSL文档:

How to install Linux on Windows with WSL

https://learn.microsoft.com/en-us/windows/wsl/install

1、我们会发现当我们启用Windows下的Linux子系统时WSL就已经安装启用完成了(所以第一步安装跳过)

2、对于第二步

若要更新到 WSL 2,需要运行 Windows 10及以上。

  • 对于 x64 系统:版本 1903 或更高版本,内部版本为 18362.1049 或更高版本。

  • 对于 ARM64 系统:版本 2004 或更高版本,内部版本为 19041 或更高版本。

3、启用虚拟功能

安装 WSL 2 之前,必须启用“虚拟机平台”可选功能。计算机需要虚拟化功能才能使用此功能。(从这可以看到,我们之前只启用了Windows下的Linux子系统)

以管理员身份打开 PowerShell 并运行:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

重新启动计算机,以完成 WSL 安装并更新到 WSL 2。

4、下载Linux内核更新安装包

Linux 内核更新包会安装最新版本的 WSL 2 Linux 内核,以便在 Windows 操作系统映像中运行 WSL。

(若要运行 Microsoft Store 中的 WSL 并更频繁地推送更新,请使用 wsl.exe --install 或 wsl.exe --update。)

下载最新包:(如果使用的是 ARM64 计算机,请下载ARM64包)

安装完成后,请继续执行下一步 - 在安装新的 Linux 分发时,将 WSL 2 设置为默认版本。

(如果希望将新的 Linux 安装设置为 WSL 1,请跳过此步骤。)

5、将将 WSL 2 设置为默认版本

打开 PowerShell,然后在安装新的 Linux 发行版时运行以下命令,将 WSL 2 设置为默认版本:

wsl --set-default-version 2

打开刚才下载好的Ubuntu,可以运行了 (完结撒花)。


配置Ubuntu

配置好用户名和密码

其它根据个人习惯进行配置

3056894-20240117115211864-1897810078.png

祝贺你!(你成功的安装了Windows上的Linux的子系统)

编者注:新闻取自各大新闻媒体,新闻内容并不代表本网立场!文字和图片来自网络,版权归原作者所有。如有侵权,请速联系小编,立即删除。

960
全部评论 (1)
Krista 发表评论于:2025-05-17 05:25:52
If some one wants expert view about blogging after that i suggest him/her to pay a visit this web site, Keep up the good job. casino en ligne France Hello, everything is going sound here and ofcourse every one is sharing facts, that's truly good, keep up writing. casino en ligne Howdy! I know this is kind of off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I'm using the same blog platform as yours and I'm having trouble finding one? Thanks a lot! casino en ligne fiable I do not even know how I ended up here, but I thought this post was good. I don't know who you are but definitely you're going to a famous blogger if you are not already ;) Cheers! casino en ligne fiable I do accept as true with all the ideas you have introduced on your post. They're very convincing and will certainly work. Still, the posts are too short for beginners. Could you please lengthen them a bit from next time? Thank you for the post. casino en ligne fiable Heya i am for the first time here. I came across this board and I find It really useful & it helped me out a lot. I hope to give something back and aid others like you helped me. casino en ligne Hi, Neat post. There is a problem with your site in web explorer, may test this? IE still is the marketplace leader and a big portion of people will miss your excellent writing because of this problem. casino en ligne fiable My partner and I stumbled over here from a different web page and thought I may as well check things out. I like what I see so now i'm following you. Look forward to finding out about your web page again. casino en ligne Hi, yup this paragraph is in fact good and I have learned lot of things from it on the topic of blogging. thanks. casino en ligne Hello there, just became aware of your blog through Google, and found that it's really informative. I'm going to watch out for brussels. I'll be grateful if you continue this in future. A lot of people will be benefited from your writing. Cheers! casino en ligne
展开快速发表评论
二维码 | 渥太华微生活

科技专栏