# WSL 快速入门
# 1. 介绍
说明:
- WSL(Windows Subsystem for Linux)
- Windows 系统中自带 Linux 子系统
优势:
- 不会产生传统虚拟机或双启动设置开销
- 实现 Windows 系统与 Linux 系统磁盘资源的共享
- 相对其他 Bash,更接近原生 Linux 系统
- 网络设置等配置与 Windows 系统保持一致,减少维护
- 等等
# 2. 安装
# 2.1. Ubuntu 18.04.5 LTS
windows子系统,可在 Microsoft Store 下载
在 Microsoft Store 安装后,打开失败:
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x8007019e
The Windows Subsystem for Linux optional component is not enabled. Please enable it and try again.
See https://aka.ms/wslinstall for details.
Press any key to continue...
解决方案:(用管理员权限打开 PowerShell)
PS C:\WINDOWS\system32> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
是否立即重启计算机以完成此操作?
[Y] Yes [N] No [?] 帮助 (默认值为“Y”):
(打开 Ubuntu 18.04.5 LTS 后)注册 Linux 账号:
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: wuqinfei
Enter new UNIX password: 123456
Retype new UNIX password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
wuqinfei@DESKTOP-VEHNPFE:~$
参考:
# 2.2. Ubuntu 22.04.2 LTS
0x80370114:
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80370114
Error: 0x80370114 ??????????????????
解决 0x80370114:
- 启用 “Virtual Machine Platform”(虚拟机平台)windows 功能
# 3. 配置软件源
命令:
su
cp /etc/apt/sources.list /etc/apt/sources_bk.list
vi /etc/apt/sources.list
内容:
deb 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 https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
# 4. 设置 root 账号的密码
sudo passwd
# [sudo] password for wuqinfei: 123456
# New password: 123456
# Retype new password: 123456
# passwd: password updated successfully
# 5. 盘符
ls /mnt
# c d w wsl wslg
# 6. 卸载
点击 window 搜索按钮,输入“应用与功能” 然后选择对应的 app 进行删除。
# 7. 参考
上一篇: 下一篇:
本章目录