Window上的子Linux系统,不再需要装虚拟机!
https://learn.microsoft.com/zh-cn/windows/wsl/about
常用命令
参考:https://learn.microsoft.com/zh-cn/windows/wsl/basic-commands
- 安装 WSL 和 Linux 的默认 Ubuntu 发行版
wsl --install
无法从“https://raw.githubusercontent.com/microsoft/WSL/master/distributions/DistributionInfo.json”中提取列表分发。无法与服务器建立连接:
解决办法:https://blog.csdn.net/u012782078/article/details/106109620 - 更新 WSL
wsl --update - 列出已安装的 Linux 发行版
wsl --list --verbose - 列出可用的 Linux 发行版
wsl --list --online - 安装其他 Linux 发行版
wsl --install < Distribution Name > - 设置默认 Linux 发行版
wsl --set-default < Distribution Name > - 将目录更改为主页
wsl ~ - 通过 PowerShell 或 CMD 运行特定的 Linux 发行版
wsl --distribution --user < User Name > - 检查 WSL 状态
wsl --status - 检查 WSL 版本
wsl --version - 更改发行版的默认用户
config --default-user < Username > - 关机
wsl --shutdown - 注销或卸载 Linux 发行版
wsl --unregister < DistributionName > - 装载磁盘或设备
wsl --mount < DiskPath > - 退出登录回到Windows 命令窗口
exit - 运行指定的发行版本
wsl -d < sys name >
如 :
wsl -d Ubuntu-20.04
wsl -d Ubuntu-22.04
一些小妙招
- 设置bash终端的初始目录
如何使得一进入wsl就让当前的目录在~ ?
在~/.bashrc中加入一行代码:cd ~
问题与解决
1)wsl: 检测到 localhost 代理配置,但未镜像到 WSL。NAT 模式下的 WSL 不支持 localhost 代理:
打开或创建WSL配置文件(位于C:/User/%你的用户名/.wslconfig),并添加以下内容:
[experimental]
autoMemoryReclaim=gradual
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true
https://learn.microsoft.com/zh-cn/windows/wsl/wsl-config#configuration-settings-for-wslconf
在wsl2上使用NVIDIA cuda
https://docs.nvidia.com/cuda/wsl-user-guide/index.html
https://learn.microsoft.com/zh-cn/windows/wsl/tutorials/gui-apps
windows子系统wsl2备份还原系统
https://blog.csdn.net/PC_small_wang/article/details/132380593
参考文献
https://aiops.com/news/post/37166.html