Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use WSL 2

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to use WSL 2. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Install WSL 2

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

Enable "

Virtual machine platform (Virtual Machine Platform)

"optional component

Use the command line to set up the distribution to be supported by WSL 2

Verify the WSL version used by your distribution

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

Enable the optional components of the Virtual Machine platform

Open PowerShell as an administrator and run:

Enable-WindowsOptionalFeature-Online-FeatureName VirtualMachinePlatform

After enabling these changes, you need to restart your computer.

Use the command line to set up the distribution to be supported by WSL 2

To run in PowerShell:

Wsl-- set-version 2

And make sure that it will be replaced with the actual name of the distribution. (you can find them using the following command: wsl-l). You can also change back to WSL 1 at any time by running the same command as above, but replace "2" with "1".

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

Wsl-- set-default-version 2

This will initialize any new distribution you install to the WSL 2 release.

Complete the verification of the WSL version used by the release

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

Wsl-list-verbose or wsl-l-v

The distribution you selected above should now display "2" under the "version" column. Now that you're done, you can start using your WSL 2 distribution at any time!

Experience changes in WSL 2

When you first start using WSL, you will notice some changes in the user experience. Here are the two most important changes in this preview.

Put the Linux file in the Linux root file system

Ensure that frequently accessed files in Linux applications are placed in the Linux root file system to enjoy file performance benefits. In the past, Microsoft has emphasized putting files on disk C when using WSL 1, but this is not the case in WSL 2. To enjoy faster file system access in WSL 2, these files must be placed in the Linux root file system. And now Windows applications can access the Linux root file system, such as File Explorer! Try running it in the home directory of the Linux distribution: explorer.exe. Exe. See what happens), which will make this conversion easier.

Use dynamic IP addresses to access Linux network applications in the initial build

WSL 2 has made significant architectural changes, using virtualization technologies, and is still working to improve network support. Because WSL 2 is now running in a virtual machine, you need to use the IP address of the VM to access the Linux network application from Windows, and vice versa, you need the IP address of the Windows host to access the Windows network application from Linux. The goal of WSL 2 is to use localhost to access network applications as much as possible! Complete details and steps on how to do this can be found in the documentation.

To learn more about user experience changes, refer to the documentation: user experience changes between WSL 1 and WSL 2.

New WSL command

WSL has added some new command options to help control and view WSL versions and distributions.

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

Wsl-shutdown

Immediately terminate all running distributions and WSL 2 lightweight utility virtual machines.

In general, virtual machines that support WSL 2 distributions are managed by WSL, so they are turned on when needed and turned off when not needed. But there may also be situations where you want to shut it down manually, and this command allows you to do this by terminating all distributions and shutting down the WSL 2 virtual machine.

Wsl-list-quiet

Only the release name is listed. This command is useful for scripting because it only prints the name of the distribution you have installed and does not display other information, such as the default release, version, and so on.

Wsl-list-verbose

Displays detailed information about all distributions. This command lists the name of each release, the status of the release, and the version that is running. The default distribution is marked with an asterisk.

Thank you for reading! This is the end of this article on "how to use WSL 2". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report