2025-03-14 21:59:59 -06:00
|
|
|
|
# wsl
|
|
|
|
|
|
|
|
|
|
|
|
> 从命令行管理适用于 Linux 的 Windows 子系统。
|
2026-02-18 06:55:01 -07:00
|
|
|
|
> 更多信息:<https://learn.microsoft.com/windows/wsl/reference>。
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
|
|
- 启动 Linux Shell(在默认发行版中):
|
|
|
|
|
|
|
|
|
|
|
|
`wsl {{shell_命令}}`
|
|
|
|
|
|
|
|
|
|
|
|
- 在不使用 Shell 的情况下运行 Linux 命令:
|
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
|
`wsl {{[-e|--exec]}} {{命令}} {{命令参数}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
|
|
- 指定特定的发行版:
|
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
|
`wsl {{[-d|--distribution]}} {{发行版}} {{shell_命令}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
|
|
- 列出所有可用发行版:
|
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
|
`wsl {{[-l|--list]}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
|
- 将发行版导出到 `.tar` 文件:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
|
`wsl --export {{发行版}} {{路径\distro_fs.tar}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
|
- 从 `.tar` 文件导入发行版:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
|
`wsl --import {{发行版}} {{路径\安装位置}} {{路径\distro_fs.tar}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
|
|
- 更改指定发行版的版本:
|
|
|
|
|
|
|
|
|
|
|
|
`wsl --set-version {{发行版}} {{版本}}`
|
|
|
|
|
|
|
|
|
|
|
|
- 关闭适用于 Linux 的 Windows 子系统:
|
|
|
|
|
|
|
|
|
|
|
|
`wsl --shutdown`
|