WSL 介绍:
可以在 Windows 10 或 Windows 11 里面直接运行一个 Linux 环境。这就不需要docker 或是 VMware 或 多引导设置,Windows 直接带了一个 ubuntu (默认). 还可以指定 Debian Kali 什么的。
最早的 WSL 1.0 不支持 GUI,它部署的 OS 是一个基于终端的 Linux 环境。
如果需要 GUI ,你需要升级到 Windows 11,印像 10 的后期版好像也是 WSL 2.0, 这个版本可以使用分离的应用窗口, 不是完整的 GUI 桌面。
使用场景:
比如,我经常在 NAS 部署 image 后,再启动新 Image 的 container,程序会出错,少个字库,python 包/库不全,就可以先在 WSL 里运行,再部署。
1. 安装 WSL 默认是 ubuntu
需要以管理员身份执行 PowerShell
在 powershall 里,执行命令 wsl --install (默认是 ubuntu)
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
PS C:\WINDOWS\system32> wsl --install
Ubuntu is already installed.
Launching Ubuntu...
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 5.15.153.1-microsoft-standard-WSL2 x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Thu Nov 21 19:58:31 CST 2024
System load: 0.16 Processes: 63
Usage of /: 0.2% of 1006.85GB Users logged in: 0
Memory usage: 2% IPv4 address for eth0: 172.30.17.216
Swap usage: 0%
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
This message is shown once a day. To disable it please create the
/home/jia/.hushlogin file.
dave@Dave-Laptop:~$
就这么完成了, 以后每次使用:
只需以 管理员身份 进入 cmd 或者 powershell, 执行 wsl
2. 查看可以安装的其它 Linux
CMD: wsl --list --online
3. 部署其它Linux OS
实例中是安装 Kali Linux:
4. 查看已经安装的部署状态
CMD:wsl --list --verbose
5. 获取更多部署 访问:微软商店 Store, 关键词 Linux
6. 再次登录 WSL 中的一个部署
使用参数 -d <名字>, 不指定就是默认的 ubuntu
7. 卸载一个部署 --unregistor
8. 修改默认 部署
9. 关于 WSL 2 with GUI
接上开头于 WSL 介绍中的 GUI 部分, WSL 2 是支持 GUI,但它是以分割的窗口来显示,不是一个完整是 desktop 抢夺 Windows 桌面的主权。
在下面图的示例中, 我在 ubuntu 安装了 gedit 一个 GUI 编辑器, 然后使用它:
这就有点像 很早 Unix 们,可以使用 X-Window? X server? 太早记不清。还是什么 X-11的 什么。可以用 远程连接 这种方法去 投屏 或 被支持桌面显示的远程连接访问。 想起才入行时用Nixdorf,换工作后 SunOS2.6 为这份工作还考了它的认证,翻 Oracle 7/8 无聊,去考 CCNP ,没几年,这些公司在中国的产品都黄了。