Windows 子系统 (WSL)的使用
1.什么是适用于 Linux 的 Windows 子系统 (WSL)?
Linux 的 Windows 子系统让开发人员无需虚拟机就可以直接在 Windows 上运行 Linux 环境,包括大多数命令行工具、程序和应用。
2.WSL 面向哪些用户?
这主要是一种面向开发人员的工具,尤其是 web 开发人员、在开源项目中工作或部署到 Linux 服务器环境的工具。 WSL 适用于喜欢使用 Bash、常见 Linux 工具 和 Linux 优先框架 (Ruby、Python 等 ) 但还喜欢使用 Windows 生产力工具的任何用户。
3.WSL 有哪些作用?
WSL 使你能够使用选择的分发 (Ubuntu、Debian、OpenSUSE、Kali、Alpine 等) 在 Bash shell 中运行 Linux。 使用 Bash 可以运行命令行 Linux 工具和应用。 更形象地说,你可轻松的打开一个Linux系统,就像打开CMD一样,再也不用等虚拟机启动等待半天了;你可以随心所欲把在linux下操作windows的目录,再也不用忍受虚拟机复杂的操作了。
使用 WSL 的好处是:
- 与在虚拟机下使用 Linux 相比,WSL 更加流畅;
- WSL 可以对 Windows 文件系统下的文件直接进行读写,文件传输更方便;
- 剪贴板互通,可以直接在 Windows 下其它地方复制文本内容,粘贴到 WSL;
4.如何使用?
1)设置->搜索 Windows功能


2)下载安装喜欢的WSL发行版本
可以直接在微软应用商店搜WSL ,然后选择安装你喜欢的Linux 发行版本
如果无法使用Microsoft Store ,可以点下面的链接手动安装Linux发行版本:原文档
- Ubuntu 20.04
- Ubuntu 20.04 ARM
- Ubuntu 18.04
- Ubuntu 18.04 ARM
- Ubuntu 16.04
- Debian GNU/Linux
- Kali Linux
- SUSE Linux Enterprise Server 12
- SUSE Linux Enterprise Server 15 SP2
- openSUSE 闰15。2
- 适用于WSL 的Fedora Remix
笔者安装的是Ubuntu ,下载好点击安装即可,然后设置用户名和密码,就发现直接进入Ubuntu界面了
3)操作使用
WSL 可以访问 Windows 文件系统中的文件,WSL 根目录 /mnt 目录下有 c、d 等文件夹,分别表示本地的C盘、D盘 ,直接使用 cd 命令,即可访问。
apt 更换阿里云源
执行下面命令,备份 apt 安装源:
$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bakvim 编辑 sources.list :
$ sudo vim /etc/apt/sources.list在 sources.list 中添加 apt 阿里云源:
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
其他和linux 操作一样。