Linux running on Windows: WSL 2 Getting Started | Linux China

640?wx_fmt=jpeg Following Microsoft released WSL 2 (Windows Subsystem for Linux 2), two days before the official update provides WSL2, in user Insider Fast channel can experience the latest version of the Windows build 18917 WSL2 by installing the update. - Craig Loewen

Following Microsoft released WSL 2 (Windows Subsystem for Linux 2), two days before the official update provides WSL2, in user Insider Fast channel can experience the latest version of the Windows build 18917 WSL2 by installing the update.

In this article, we will describe how to get started, the new  wsl.exe command as well as some important tips. For complete documentation can WSL 2 in the Microsoft documentation pages found on.

Installation WSL 2

To install and start using WSL 2, complete the following steps:

◈ enable the "virtual machine platform Virtual Machine Platform" ◈ optional components using the command line WSL set up to verify the version of your distribution used by WSL 2 supported releases ◈

Please note that you need to run Windows 10 build 18917 or later to use WSL 2, and you need to install the WSL (can here find instructions).

Enable the "virtual machine platform" Optional Components

Open PowerShell as an administrator and run:

 
  
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

When you enable these changes, you need to restart your computer.

Using the command line to set the release supported by the WSL 2

Run in PowerShell:

 
  
wsl --set-version <Distro> 2--set-version <Distro> 2

And ensure  <Distro> replaced with the actual name of the release. (You can find them using the following command: wsl -l). You can also change by running the same command as above at any time back WSL 1, but will be " 2" replaced with " 1."

Also, if you want to make WSL 2 become the default schema, you can do this using the following command:

 

 
  
wsl --set-default-version 2--set-default-version 2

This will make any initialization you install a new release of WSL 2 release.

WSL verified using version release

To verify the version of each release WSL used, use the following command:

 
  
wsl --list --verbose--list --verbose
wsl -l -v-l -v

Release your choice above should now be listed under "2" appears in the "version". Is now complete, you can always start using your WSL 2 release it!

Experience of change WSL 2

When you first start using the WSL, you'll notice some changes in the user experience. The following is a preview of this the two most important changes.

The files in Linux Linux root file system

Be sure to file the application in Linux frequently accessed on the Linux root file system, the file in order to enjoy the performance benefits. In the past, Microsoft has been emphasizing the use of WSL 1 when files into the C drive, but the situation WSL 2 is not the case. To enjoy WSL 2 in faster file system access, these files must be placed inside the Linux root file system. And now Windows applications can access the Linux root file system (such as File Explorer in Linux distributions try to run home directory:! explorer.exe . See what happens), which will make this transition easier.

Access Linux network applications that use dynamic IP addresses in the initial construction of the

WSL 2 made a huge change in architecture, using virtualization technology, and is still working to improve network support. Because WSL 2 now run in a virtual machine, so you need access to Linux network applications using the IP address of the VM and vice versa from Windows, you need the IP address to host Windows network access to Windows applications from Linux. WSL 2 goal is to use as much as possible  localhost to access network applications! You can document find full details and procedures on how to do this.

To find out more information about the user experience changes, please refer to the document: WSL 1 and user experience changes between the WSL 2 .

The new WSL command

WSL added some new options to help control commands and view WSL version and release.

In addition to the above mentioned   --set-version and  --set-default-version , there are:

◈  wsl --shutdown

Immediately terminate all releases running and WSL 2 lightweight utility virtual machine.

In general, support WSL 2 release virtual machine is managed by the WSL, and therefore will be opened when needed and turn it off when not needed. But there may also be that you wish to manually turn it off, this command allows you to do this by halting all releases WSL 2 and close the virtual machine.

◈  wsl --list --quiet

Lists only release the name. This command is useful for scripting, because it will only release the name of the output that you have installed, without displaying additional information, such as the default release, version and so on.

◈  wsl --list --verbose

Show all detailed information about the release. This command lists the name of each release, which the state distribution and its version running. The default release marked with an asterisk.

Feedback

If you encounter any problems, please submit questions on Github:  https://github.com/microsoft/wsl/issues  , if you have general questions about WSL, you can in this Twitter list to find all members of the team on of Twitter.

640?wx_fmt=jpeg


Guess you like

Origin blog.csdn.net/F8qG7f9YD02Pe/article/details/92027415