Install Linux on Windows with WSL2 (使用 WSL2 在 Windows 上安装 Linux)

news2024/9/30 5:29:13

Install Linux on Windows with WSL2 (使用 WSL2 在 Windows 上安装 Linux)

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

在 Windows 上运行 Linux - 在 Windows 11 上运行 Ubuntu 20.04 LTS

Developers can access the power of both Windows and Linux at the same time on a Windows machine. The Windows Subsystem for Linux (WSL) lets developers install a Linux distribution (such as Ubuntu, OpenSUSE, Kali, Debian, Arch Linux, etc) and use Linux applications, utilities, and Bash command-line tools directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.
开发人员可以在 Windows 计算机上同时访问 Windows 和 Linux 的强大功能。 通过适用于 Linux 的 Windows 子系统 (WSL),开发人员可以安装 Linux 发行版 (例如 Ubuntu、OpenSUSE、Kali、Debian、Arch Linux 等),并直接在 Windows 上使用 Linux 应用程序、实用程序和 Bash 命令行工具,不用进行任何修改,也无需承担传统虚拟机或双启动设置的费用。

1. Windows 11 系统设置

1.1 Check requirements for running WSL 2 (检查运行 WSL 2 的要求)

To update to WSL 2, you had better to run Windows 11.

To check your version and build number, select Windows logo key + R, type winver, select OK.
若要检查 Windows 版本及内部版本号,选择 Windows 徽标键 + R,然后键入 winver,选择 OK

在这里插入图片描述

1.2 Enable the Windows Subsystem for Linux (启用适用于 Linux 的 Windows 子系统)

You must first enable the “Windows Subsystem for Linux” optional feature before installing any Linux distributions on Windows.
需要先启用 [适用于 Linux 的 Windows 子系统] 可选功能,然后才能在 Windows 上安装 Linux。

1.3 Enable Virtual Machine feature (启用虚拟机功能)

Before installing WSL 2, you must enable the Virtual Machine Platform optional feature. Your machine will require virtualization capabilities to use this feature.
安装 WSL 2 之前,必须启用 [虚拟机平台] 可选功能。计算机需要虚拟化功能才能使用此功能。

  1. 开始 -> 设置 -> 应用 -> 可选功能

在这里插入图片描述

  1. 可选功能 -> 更多 Windows 功能

在这里插入图片描述

  1. 勾选 [适用于 Linux 的 Windows 子系统] 和 [虚拟机平台]

在这里插入图片描述

  1. Wait to restart your machine and move on to the next step.
    请等待重新启动计算机,然后继续执行下一步。

2. WSL 命令无法 - 解析服务器的名称或地址

Microsoft Windows [版本 10.0.22621.1105]
(c) Microsoft Corporation。保留所有权利。

C:\Users\cheng>wsl --list --online
无法解析服务器的名称或地址

C:\Users\cheng>
  1. 开始 -> 设置 -> 网络和 Internet -> WLAN -> 属性

在这里插入图片描述

  1. DNS 服务器分配

手动 + 首选 DNS: 114.114.114.114
在这里插入图片描述

Microsoft Windows [版本 10.0.22621.1105]
(c) Microsoft Corporation。保留所有权利。

C:\Users\cheng>wsl --list --online
以下是可安装的有效分发的列表。
请使用“wsl --install -d <分发>”安装。

NAME                                   FRIENDLY NAME
Ubuntu                                 Ubuntu
Debian                                 Debian GNU/Linux
kali-linux                             Kali Linux Rolling
Ubuntu-18.04                           Ubuntu 18.04 LTS
Ubuntu-20.04                           Ubuntu 20.04 LTS
Ubuntu-22.04                           Ubuntu 22.04 LTS
OracleLinux_8_5                        Oracle Linux 8.5
OracleLinux_7_9                        Oracle Linux 7.9
SUSE-Linux-Enterprise-Server-15-SP4    SUSE Linux Enterprise Server 15 SP4
openSUSE-Leap-15.4                     openSUSE Leap 15.4
openSUSE-Tumbleweed                    openSUSE Tumbleweed

C:\Users\cheng>

3. Download the Linux kernel update package (下载 Linux 内核更新包)

  1. Download the latest package: WSL2 Linux kernel update package for x64 machines https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

wsl_update_x64.msi

在这里插入图片描述

  1. Run the update package downloaded in the previous step. (Double-click to run - you will be prompted for elevated permissions, select ‘yes’ to approve this installation.)
    运行上一步中下载的更新包。(双击以运行 - 系统将提示你提供提升的权限,选择 yes 以批准此安装。)

Once the installation is complete, move on to the next step - setting WSL 2 as your default version when installing new Linux distributions. (Skip this step if you want your new Linux installs to be set to WSL 1).
安装完成后,请继续执行下一步 - 在安装新的 Linux 分发时,将 WSL 2 设置为默认版本。(如果希望将新的 Linux 安装设置为 WSL 1,请跳过此步骤。)

4. Set WSL 2 as your default version (将 WSL 2 设置为默认版本)

Open PowerShell and run this command to set WSL 2 as the default version when installing a new Linux distribution:
在安装新的 Linux 发行版时运行以下命令,将 WSL 2 设置为默认版本:

Microsoft Windows [版本 10.0.22621.1105]
(c) Microsoft Corporation。保留所有权利。

C:\Users\cheng>wsl --set-default-version 2
有关与 WSL 2 的主要区别的信息,请访问 https://aka.ms/wsl2
操作成功完成。

C:\Users\cheng>

5. Change the default Linux distribution installed (更改默认安装的 Linux 发行版)

By default, the installed Linux distribution will be Ubuntu. This can be changed using the -d flag.
默认情况下,安装的 Linux 分发版为 Ubuntu。 可以使用 -d 标志进行更改。

To change the distribution installed, enter: wsl --install -d <Distribution Name>. Replace <Distribution Name> with the name of the distribution you would like to install.
若要更改安装的发行版,请输入:wsl --install -d <Distribution Name>。 将 <Distribution Name> 替换为要安装的发行版的名称。

To see a list of available Linux distributions available for download through the online store, enter: wsl --list --online or wsl -l -o.
若要查看可通过在线商店下载的可用 Linux 发行版列表,请输入:wsl --list --onlinewsl -l -o

To install additional Linux distributions after the initial install, you may also use the command: wsl --install -d <Distribution Name>.
若要在初始安装后安装其他 Linux 发行版,还可使用命令:wsl --install -d <Distribution Name>

Please try running wsl --list --online to see a list of available distros and run wsl --install -d <DistroName> to install a distro.
请尝试运行 wsl --list --online 以查看可用发行版列表并运行 wsl --install -d <DistroName> 以安装发行版。

Microsoft Windows [版本 10.0.22621.1105]
(c) Microsoft Corporation。保留所有权利。

C:\Users\cheng>wsl --list --online
以下是可安装的有效分发的列表。
请使用“wsl --install -d <分发>”安装。

NAME                                   FRIENDLY NAME
Ubuntu                                 Ubuntu
Debian                                 Debian GNU/Linux
kali-linux                             Kali Linux Rolling
Ubuntu-18.04                           Ubuntu 18.04 LTS
Ubuntu-20.04                           Ubuntu 20.04 LTS
Ubuntu-22.04                           Ubuntu 22.04 LTS
OracleLinux_8_5                        Oracle Linux 8.5
OracleLinux_7_9                        Oracle Linux 7.9
SUSE-Linux-Enterprise-Server-15-SP4    SUSE Linux Enterprise Server 15 SP4
openSUSE-Leap-15.4                     openSUSE Leap 15.4
openSUSE-Tumbleweed                    openSUSE Tumbleweed

C:\Users\cheng>
C:\Users\cheng>wsl --install -d Ubuntu-20.04
正在安装: Ubuntu 20.04 LTS
已安装 Ubuntu 20.04 LTS。
正在启动 Ubuntu 20.04 LTS…

C:\Users\cheng>

在这里插入图片描述

文件夹目录
在这里插入图片描述

6. bash 启动

6.1 WIN + R -> cmd -> bash

在这里插入图片描述

在这里插入图片描述

6.2 WIN + R -> bash

在这里插入图片描述

在这里插入图片描述

7. 任务栏启动

固定到任务栏
在这里插入图片描述

在这里插入图片描述

使用 exit 退出环境。

8. Ubuntu 20.04 LTS 保存位置

AppData 默认是隐藏的。
在这里插入图片描述

C:\Users\cheng\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState

在这里插入图片描述

References

https://yongqiang.blog.csdn.net/
https://learn.microsoft.com/en-us/windows/wsl/install-manual

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/348847.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

实验十三、阻容耦合共射放大电路的频率响应

一、题目 利用 Multism 从以下几个方面研究图1所示的阻容耦合共射放大电路的频率响应。图1阻容耦合共射放大电路图1\,\,阻容耦合共射放大电路图1阻容耦合共射放大电路&#xff08;1&#xff09;设 C1C210μFC_1C_210\,\textrm{μF}C1​C2​10μF&#xff0c;分别测试它们所确定…

6万字电力行业系统解决方案光伏电站综合安防系统解决方案

【版权声明】本资料来源网络&#xff0c;知识分享&#xff0c;仅供个人学习&#xff0c;请勿商用。【侵删致歉】如有侵权请联系小编&#xff0c;将在收到信息后第一时间删除&#xff01;完整资料领取见文末&#xff0c;部分资料内容&#xff1a; 目录 第 一 章背景与需求 1.1行…

2023年收银管理系统排行榜新鲜出炉

随着新零售的模式普及&#xff0c;越来越多的零售店选择了用收银系统代替收银机。因为收银系统不仅具备收银等功能&#xff0c;其实还有各种店铺数据管理功能、经销商信息管理&#xff0c;销售数据分析等许多功能等。所以如果想清晰地知道门店每天盈利情况和库存情况和采购过程…

这些小众却足够惊艳的素材库,你知道吗?

推荐几个我经常使用的网站&#xff0c;绝对够惊艳。 1、菜鸟图库&#xff08;免费设计素材&#xff09; https://www.sucai999.com/?vNTYxMjky 这是一个为新手设计师提供免费素材的设计网站&#xff0c;站内有超多平面模板、海报、UI设计、电商设计等相关素材&#xff0c;质…

JS设计模式

文章目录1 什么是设计模式&#xff1f;2 发布-订阅模式2.1 DOM事件2.2 基于Broadcast Channel实现跨页面通信2.3 基于localStorage实现跨页面通信2.4 使用 Vue 的 EventBus 进行跨组件通信2.4 使用 React 的 EventEmitter 进行跨组件通信3 装饰器模式3.1 React 高阶组件 HOC3.2…

MySql图形化界面工具--DataGrip安装和使用

一、下载安装 1、官网下载安装包&#xff0c;双击开始安装 2、点击next&#xff0c;一步一步的完成安装 3、选择DataGrip的安装目录&#xff0c;然后选择下一步 4、下一步&#xff0c;执行安装 二、使用 1、添加数据源 配置以及驱动jar包下载完毕之后&#xff0c;…

Pod基本概念与Pod应用生命周期

Pod是一个逻辑抽象概念&#xff0c;kubernetes创建和管理的最小单元&#xff0c;一个Pod由一个容器或多个容器组成。特点&#xff1a;一个Pod可以理解为是一个应用实例&#xff0c;提供服务Pod中容器始终部署在一个Node上Pod中容器共享网络、存储资源Pod主要用法&#xff1a;运…

大件传输的9种方法

不知道你有没有试过用电子邮件进行大文件传输&#xff0c;由于文件大小的限制&#xff0c;往往会发送失败。同时&#xff0c;一些文件共享服务对传输的文件有大小限制&#xff0c;使得你无法与朋友分享电影片段或向客户展示你的工作样本。还有一些要求你注册一个账户&#xff0…

【JVM基础内容速查表】JVM基础知识 默认参数 GC命令 工具使用 JVM参数设置、说明、使用方法、注意事项等(持续更新)

目录一、JVM前置知识1. -X、-XX含义2. JVM参数值的类型和设置方式3. 查看GC时用到的命令和JVM参数4. 查看JVM默认参数二、垃圾收集器选择-XX:UseSerialGC-XX:UseParallelGC-XX:UseParallelOldGC-XX:UseParNewGC-XX:UseConcMarkSweepGC-XX:UseG1GC三、垃圾收集器特有参数1. ParN…

pyinstaller打包遇到的问题

1、ModuleNotFoundError: No module named ‘scipy.spatial.transform_rotaion_groups’ 解决办法&#xff1a;–hidden-import scipy.spatial.transform._rotation_groups 2、FileNotFoundError:[Errno 2] No such file or directory:‘C:\Users\Gw0021\AppData\Local\Temp\_M…

leaflet 选择一个marker,点击后设置其为中心点(070)

第070个 点击查看专栏目录 本示例的目的是介绍演示如何在vue+leaflet中引用geojson文件,显示marker,点击某个marker后,设置其为中心点,并panTo到中心点。 直接复制下面的 vue+leaflet源代码,操作2分钟即可运行实现效果 文章目录 示例效果配置方式示例源代码(共81行)相…

【数据库】MySQL 索引视图详解

目录 MySQL索引视图 视图 一&#xff0c;什么是视图 二&#xff0c;为什么需要视图 三&#xff0c;视图的作用和优点 四&#xff0c;创建视图 案例&#xff1a; 五&#xff0c;视图使用规则 六&#xff0c; 修改视图 1&#xff0c;修改列名 2&#xff0c;创建复杂视图…

把盏言欢,款款而谈,当WorkPlus接入了ChatGPT机器人

ChatGPT到底有多火&#xff1f; “谷歌AI聊天机器人出错&#xff0c;市值一夜蒸发7172亿”&#xff1b;“百度类ChatGPT项目‘文心一言’或将直接接入百度搜索”&#xff1b;“阿里确认正研发类ChatGPT产品&#xff0c;目前处于内测阶段”&#xff1b;“网易有道将推出教育场景…

电脑技巧:分享六个小众且非常实用的工具

❤️作者主页&#xff1a;IT技术分享社区 ❤️作者简介&#xff1a;大家好,我是IT技术分享社区的博主&#xff0c;从事C#、Java开发九年&#xff0c;对数据库、C#、Java、前端、运维、电脑技巧等经验丰富。 ❤️荣誉&#xff1a; CSDN博客专家、数据库优质创作者&#x1f3c6;&…

黑马】后台管理-路由懒加载

当打包构建项目时&#xff0c; JavaScript 包会变得非常大&#xff0c;影响页面加载。如果我们能把不同路由对应的组件分割成不同的代码块&#xff0c;然后当路由被访问的时候才加载对应组件&#xff0c;这样就更加高效了。具体需要 3 步&#xff1a;① 安装 babel/plugin-synt…

【Big Data】Hadoop--MapReduce经典题型实战(单词统计+成绩排序+文档倒插序列)

&#x1f34a;本文使用了3个经典案例进行MapReduce实战 &#x1f34a;参考官方源码&#xff0c;代码风格较优雅 &#x1f34a;解析详细 一、Introduction MapReduce是一个分布式运算程序的编程框架&#xff0c;核心功能是将用户写的业务逻辑代码和自身默认代码整合成一个完整的…

震源机制沙滩球(focal mechanism beach ball)绘制之傻瓜式教程

目录 1. 断层的定义 2. 绘制流程 3. 更多示例 沙滩球的含义可阅读&#xff1a;震源机制(Focal Mechanisms)之沙滩球(Beach Ball)_ddd...e_bug的博客-CSDN博客 1. 断层的定义&#xff08;&#xff09; 走向&#xff08;strike&#xff09;&#xff1a;正北方顺时针旋转到走向…

第五十四章 DFS进阶(二)——迭代加深

第五十四章 DFS进阶&#xff08;二&#xff09;——迭代加深一、DFS的缺陷二、迭代加深1、什么是迭代加深2、复杂度分析3、算法步骤三、例题1、问题2、分析3、代码一、DFS的缺陷 我们知道DFS是一条路走到黑&#xff0c;直到将整条路走完以后才会回头。 这就导致了一个问题&am…

dynamic-Echonet左心室语义分割——学习记录

1简单介绍 1.1 论文简介 论文地址Video-based AI for beat-to-beat assessment of cardiac function 数据集地址&#xff1a;here获取好像还挺麻烦的。需要在网站上填写并申请数据集&#xff0c;斯坦福那边会发邮件并拉入一个box组&#xff0c;就可以访问公开的超声心动数据集…

图解LeetCode——剑指 Offer 26. 树的子结构

一、题目 输入两棵二叉树A和B&#xff0c;判断B是不是A的子结构。(约定空树不是任意一个树的子结构) B是A的子结构&#xff0c; 即&#xff1a;A中有出现和B相同的结构和节点值。 二、示例 2.1> 示例 1&#xff1a; 【输入】A [1,2,3], B [3,1] 【输出】false 2.2> 示…