Windows 安装WSL2 Linux 子系统

WSL2子系统

Windows 安装WSL2 Linux 子系统

  • 将 WSL 版本设置为 1 或 2
wsl --set-version <distribution name> <versionnumber>
  • 设置默认 WSL 版本
wsl --set-default-version <version>
  • 设置默认 Linux 发行版
wsl --set-default <distribution name>
  • 将目录更改为主页
wsl ~
  • 更新 WSL
wsl --update
  • 检查 WSL 状态
wsl --status
  • 检查 WSL 版本
wsl --version

安装步骤

  1. 启动WSL
  • 以管理员身份打开 PowerShell 工具并运行以下命令。
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
  1. 启用“虚拟机平台”
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  1. 下载 Linux 内核更新包
  1. 设置 WSL 2 为默认值
wsl --set-default-version 2

Windows 安装WSL2 Linux 子系统

  1. 查询可以安装的 Linux 版本
wsl --list --online

Windows 安装WSL2 Linux 子系统

  1. 安装需要的版本
wsl --install -d Ubuntu-20.04

Windows 安装WSL2 Linux 子系统

  1. 查询安装的版本
wsl --list --verbose

Windows 安装WSL2 Linux 子系统

把子系统迁移到D盘指定位置

  1. 关闭wsl
wsl --shutdown
  1. 导出Ubuntu-22.04LTS
wsl --export Ubuntu-20.04 D:\WindowsSubsystemLinux\img\Ubuntu-20.04.tar
  1. 卸载当前Ubuntu-22.04LTS
wsl --unregister Ubuntu-20.04
  1. 导入刚才导出的的Ubuntu-22.04.tar
wsl --import Ubuntu-20.04 D:\WindowsSubsystemLinux\Ubuntu-20.04 D:\WindowsSubsystemLinux\img\Ubuntu-20.04.tar

Windows 安装WSL2 Linux 子系统

  1. 设置默认用户
ubuntu2004 config --default-user your-name
  1. 开启或停止服务
# 停止服务
net stop LxssManager
# 启动服务
net start LxssManager

换源

  1. 备份镜像源源文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  1. 用 vi 编辑器打开源文件
sudo vi /etc/apt/sources.list
  1. 更改镜像源
#  阿里源
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
# 清华源
#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
#deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
#deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
#deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
#deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
#deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
#  中科大源
#deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
#deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
#deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
#deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
#deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu/ jammy main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ jammy universe
# deb-src http://archive.ubuntu.com/ubuntu/ jammy universe
deb http://archive.ubuntu.com/ubuntu/ jammy-updates universe
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu.com/ubuntu/ jammy multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted
deb http://security.ubuntu.com/ubuntu/ jammy-security universe
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security universe
deb http://security.ubuntu.com/ubuntu/ jammy-security multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security multiverse
  1. 更新系统源
sudo apt-get -y update && sudo apt-get -y upgrade
  1. 提示缺少公匙

Windows 安装WSL2 Linux 子系统

  1. 添加相应公匙后再次更新源
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
sudo apt-get -y update && sudo apt-get -y upgrade
  1. 更新git
sudo apt-get install git
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

Windows 安装WSL2 Linux 子系统

桌面安装

  • 不安装桌面
@版权声明 1 本站名称:Liuwei's Blog
2 本站网址:https://www.liuwei.vin
3 本站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长进行删除处理。
4 本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报。
5 本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。
6 本站所有内容,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
算法

常用简单滤波算法

2022-12-25 9:42:37

Linux

Ubuntu20.24(WSL) tensorflow环境搭建

2023-2-16 16:43:59

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
有新私信 私信列表
搜索