你有没有想过你可以用一个命令行为 Linux 安装 Windows 子系统(install Windows Subsystem for Linux with a single command line)?它现在正式可用,您可以使用它在Windows 11上轻松安装WSL。
如何在Windows 11上安装适用于Linux的(Linux)Windows 子系统(Windows Subsystem)
之前,安装Windows Subsystem for Linux的过程过于复杂,涉及很多软件包。您需要解决多个设置并在您的 PC 上安装WSL 。微软(Microsoft)现在已经简化了这个过程,它只是一个命令。
您只需输入一个命令,让该命令负责在您的 PC 上安装适用于Linux的(Linux)Windows 子系统的整个过程。(Windows Subsystem)您只需拥有一个具有管理权限的帐户,该帐户已加入Windows 11 上的Windows 预览体验计划。
要在Windows 11上安装适用于Linux的(Linux)Windows 子系统(Windows Subsystem)( WSL ) ,
- (Run Command Prompt)以管理员身份运行命令提示符
- 复制/粘贴命令 wsl.exe –install 并按 Enter
- 重新启动您的 PC 以使安装准备好使用。
要开始使用,请从“开始(Start)”菜单以管理权限打开(administrative privileges)命令提示符(Command Prompt)并输入以下命令,然后按Enter。
wsl --install
现在,该命令将在您的 PC 上启用WSL和虚拟机平台(Virtual Machine Platform)组件,从而消除安装WSL的所有手动步骤。然后,它将下载并安装最新版本的Linux内核和Linux发行版。您将在命令提示符(Command Prompt)窗口中看到状态。完成后,使用适用于Linux的(Linux)Windows 子系统(Windows Subsystem)( WSL ) 重新启动您的 PC,阅读使用。
安装后打开WSL(WSL)需要几分钟,因为它需要解压缩文件并将其存储在您的 PC 上。该过程完成后,为您的WSL创建一个用户帐户。之后,您将能够立即打开它。
如何查看可用Linux发行版的列表
除了在您的 PC 上安装Windows Subsystem for Linux ( WSL ) 的命令之外,还有几个命令可以让您查看可在您的 PC 上安装的Linux发行版的完整列表。(Linux)
要查看它们,请使用管理员权限打开命令提示符(Command Prompt)并键入以下命令并按 Enter:
wsl --list --online
它将向您显示列表,您可以使用以下命令从中选择要安装的版本,您必须将分发名称替换为您在列表中看到的名称。
wsl --install -d <Distribution Name>
此命令将停止安装Linux发行版的默认版本并开始安装选定的发行版。它还可用于在现有安装中安装其他Linux发行版。(Linux)要查看 Linux 的Windows子系统(Linux)状态(Windows Subsystem)以及配置、分发类型、默认分发、内核版本的一般信息,可以使用以下命令。
wsl --status
它将在您的 PC 上显示有关WSL的所有信息。(WSL)
如何手动更新适用于Linux的(Linux)Windows 子系统(Windows Subsystem)
有可用的命令可用于更新WSL Linux内核或回滚并更新到前一个内核。
要手动更新适用于Linux的(Linux)Windows 子系统,请在(Windows Subsystem)命令提示符(Command Prompt)中键入以下命令,然后按Enter。
wsl --update
要将更新回滚到以前的版本,请使用以下命令。
wsl --update rollback
这些是可用于在您的 PC 上安装Windows Subsystem for Linux ( WSL ) 的各种命令,请参阅可用Linux发行版列表、更新或回滚更新的WSL。
这些命令不仅可在Windows 11上使用,而且如果您在Windows Insiders Program中并且拥有Windows 10操作系统的预览版本(版本 20262 或更高版本),您可以使用这些命令在您的Windows 10 PC上获取上述所有功能.
我可以使用适用于Linux的(Linux)Windows 子系统(Windows Subsystem)做什么?
在您的 PC 上安装适用于Linux的(Linux)Windows 子系统(Windows Subsystem)后,您可以使用命令行Linux工具和应用程序以及现有的Windows工具。您可以使用命令从WSL访问所有文件。
如何手动安装 WSL?
您可以通过两种方式在Windows 11/10WSL 。您必须下载所有安装包,在您的 PC 上启用虚拟机平台(Machine Platform)组件等的旧方法。现在,如果您在Windows Insider Program中并且与(Windows Insider Program)Windows 11/10的最新版本一致,您可以使用命令安装。
相关阅读:(Related read:) 如何在 Windows 上安装适用于 Linux 2 的 Windows 子系统。
How to install Windows Subsystem for Linux on Windows 11
Did you ever imagine that you can install Windows Subsystem for Linux with a single command line? It is now officially available, using which you can install WSL easily on your Windows 11.
How to install Windows Subsystem for Linux on Windows 11
Earlier, the process to install Windows Subsystem for Linux is too complicated, involving many packages. You need to work around multiple settings and install WSL on your PC. Microsoft has now eased the process, and it is just a command away.
You can just enter a command and let the command take care of the entire process of installing Windows Subsystem for Linux on your PC. All you need to have is an account with administrative privileges, joined in the Windows Insiders Program on Windows 11.
To install Windows Subsystem for Linux (WSL) on Windows 11,
- Run Command Prompt as an administrator
- copy/paste the command wsl.exe –install and press Enter
- Restart your PC to make the installation ready for use.
To get started, open Command Prompt with administrative privileges from the Start menu and enter the following command, and press Enter.
wsl --install
Now, the command will enable the WSL and Virtual Machine Platform components on your PC, eliminating all the manual steps that will install WSL. Then, it will download and install the latest version of the Linux kernel and then Linux distribution. You will see the status on Command Prompt window. When it is done, restart your PC with Windows Subsystem for Linux (WSL), read to use.
It will take a few minutes to open the WSL for a time after the installation as it needs to decompress files and store it on your PC. When the process is completed, create a user account for your WSL. After that, you would be able to open it in a jiffy.
How to see a list of available Linux distributions
In addition to the command to install Windows Subsystem for Linux (WSL) on your PC, there are a couple more commands that let you see the complete list of Linux distributions that are available to install on your PC.
To see them, open Command Prompt with administrator privileges and type the following command and press Enter:
wsl --list --online
It will show you the list out of which you can choose a version to install using the following command, where you have to replace the distribution name with the one you see in the list.
wsl --install -d <Distribution Name>
This command will stop installing the default version of Linux distribution and start installing the selected one. It can also be used to install additional Linux distributions to the existing installation. To see the Windows Subsystem for Linux status with general information of the configuration, distribution type, default distribution, kernel version, you can use the following command.
wsl --status
It will display all the information about the WSL on your PC.
How to manually update Windows Subsystem for Linux
There are commands available that can be used to update your WSL Linux kernel or roll back and update to the previous one.
To manually update the Windows Subsystem for Linux, type the following command in the Command Prompt and press Enter.
wsl --update
To roll back an update to the previous version, use the following command.
wsl --update rollback
These are the various commands which can be used to install Windows Subsystem for Linux (WSL) on your PC, see the list of available Linux distributions, update or roll back the updated WSL.
These commands are usable not only on Windows 11 but if you are on the Windows Insiders Program and have a preview build of Windows 10 OS (build 20262 or higher), you can use the commands to get all the above functionalities on your Windows 10 PC.
What can I do with Windows Subsystem for Linux?
With Windows Subsystem for Linux installed on your PC, you can use command-line Linux tools and apps along with the existing Windows tools. You can access all the files from the WSL using commands.
How do I manually install WSL?
You can install WSL on Windows 11/10 in two ways. The good-old method where you have to download all the installation packages, enable Virtual Machine Platform components on your pc, etc. Now, if you are on the Windows Insider Program and are in line with the latest builds of Windows 11/10, you can install using a command.
Related read: How to install Windows Subsystem for Linux 2 on Windows.