现在你可以在 Windows 中运行 Linux 应用了
微软 WSL
![](/data/attachment/album/202005/27/111439z64u19z6ct6r46kb.jpg)


微软最近的 “[Build 2020](https://news.microsoft.com/build2020/)” 开发者大会公布了一些有趣的公告。我不确定这该令人兴奋还是该令人怀疑 —— 但是微软，你现在比以往任何时候都受到我们的关注。


同时，在所有的这些公告中，能够在 WSL（Windows Subsystem for Linux）上运行 GUI 应用程序的功能备受关注。


更不要忘了 [Xamrin.Forms 更名为 MAUI 的尴尬结局](https://itsfoss.com/microsoft-maui-kde-row/)，它与 [Nitrux Linux](https://itsfoss.com/nitrux-linux/) 的 Uri Herrera 的现有开源项目（[Maui Project](https://mauikit.org/)）名字冲突。


以防你不清楚，WSL 是一种环境，可让你在 Windows 10 中获得 Linux 控制台的体验。它也是在 [Windows 中运行 Linux 命令的最佳方法](https://itsfoss.com/run-linux-commands-in-windows/)之一。


正如 [Liam Dawe](https://www.gamingonlinux.com/2020/05/microsoft-build-directx-and-linux-plus-more) 认为的那样，通过博客文章（[DirectX ❤ Linux](https://devblogs.microsoft.com/directx/directx-heart-linux/)）发布的公告可能是只是个公关诱饵。但是，仍然值得一提。


### WSL 上对 Linux GUI 应用程序的支持


![](/data/attachment/album/202005/27/110600xjhgiodn1pn1qghg.png)


最近，Microsoft 在在线开发者大会上宣布了 WSL（即 WSL 2）的一系列新功能。


[Windows 包管理器](https://devblogs.microsoft.com/commandline/windows-package-manager-preview/)、[Windows 终端 1.0](https://devblogs.microsoft.com/commandline/windows-terminal-1-0/)，以及其他一些功能的引入是其亮点。


但是， WSL 2 对 GPU 硬件加速的支持非常重要。


那么，是否意味着你可以使用 WSL 在 Windows 上运行 Linux 应用程序呢？看起来像是。


微软计划通过使用全新的 Linux 内核驱动程序 `dxgkrnl` 来实现它。为了给你一个技术性的简报, 我在这里引用他们的公告中的描述：


![](/data/attachment/album/202005/27/110701v6ctmn07w1i8mm0g.png)



> 
> dxgkrnl 是一个全新的 Linux 内核驱动程序，它将 `/dev/dxg` 设备提供给用户模式的 Linux。 `/dev/dxg` 提供了一组 IOCTL，它们与 Winodws 上的原生 WDDM D3DKMT 内核服务层非常相似。Linux 内核中的 dxgkrnl 通过 VM 总线连接到 Windows 主机上，并使用此 VM 总线连接与物理 GPU 进行通讯。
> 
> 
> 


我不是这方面的专家，但这意味着 WSL 上的 Linux 应用程序将与原生的 Windows 应用程序一样可以访问 GPU。


针对 GUI 应用程序的支持将在今年秋季的晚些时候提供（而不是 2020 年 5 月的更新） —— 所以我们要看看什么时候提供。


微软专门针对的是那些希望在 Windows 上轻松使用 Linux IDE 的开发人员。谷歌也在瞄准同样的用户群，[将 GUI Linux 应用程序引入到 Chromebook](https://itsfoss.com/linux-apps-chromebook/)。


那么，对于那些坚持使用 Windows 的用户来说，这是个好消息。但是，这是真的吗？


### 微软爱上了 Linux —— 真的吗？


![](/data/attachment/album/202005/27/110730uujjlybefey7s0ea.jpg)


他们在 Windows 上整合 Linux 环境来拥抱 Linux 及其优势的努力，绝对是一件好事。


但是，它真的能给**桌面 Linux 用户**带来什么好处呢？到目前为止，我还没有看到任何实际的好处。


在这里，你可以有不同的看法。但是，我认为 WSL 的开发对于 Linux 桌面用户来说没有真正的价值。至少，到目前为止没有。


有趣的是，[Linux Unplugged podcast](https://linuxunplugged.com/354) 上有人强调了微软的举动，认为这与他们的 EEE（<ruby> 拥抱、延伸和扑灭 <rt>  Embrace, extend, and extinguish </rt></ruby>）的思路是一致的。


可能吧，谁知道呢？当然，他们为实现这一目标而付出的努力值得赞赏 —— 同时又令人感到兴奋和神秘。


### 这是否意味着 Windows 用户将不必再转到 Linux?


微软之所以在其平台上集成 Linux，是因为他们知道 Liunx 的能力，也知道开发人员（或用户）喜欢使用它的原因。


但是，随着 WSL 2 的更新，如果这种情况持续下去，我倾向于同意 Abhishek 的看法：



> 
> 最终，桌面 Linux 将被限制在 Windows 下，成为桌面应用程序……
> 
> 
> 


好吧，当然，原生的体验暂时还是比较好的。而且，很难看到现有的 Linux 桌面用户会使用 Windows 来将其替代。但是，这仍然值得担心。


你如何看待这一切？我不认为 WSL 对于被迫使用 Windows 的用户有什么好处 —— 但是，从长远来看，你认为微软在 WSL 方面的进展本质上是敌意还是对 Linux 有帮助？


在评论中让我知道你的想法！




---


via: <https://itsfoss.com/run-linux-apps-windows-wsl/>


作者：[Ankush Das](https://itsfoss.com/author/ankush/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[lnrCoder](https://github.com/lnrCoder) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
# Run Linux GUI Apps in Windows With WSL 2

The WSL 2 brings the ability to run GUI Linux apps inside Windows. Here's what you need to know and do to achieve that.

When Microsoft released WSL first, it was revolutionary as it allowed to run Linux commands on Windows.

A few years later, Microsoft took it to the next level by releasing WSL 2. The new version of WSL allowed running GUI Linux apps on Windows.

It's not that Windows has a dearth of GUI apps. But when working in the Linux environment inside WSL, using the GUI apps could come in handy.

For example, you have to edit a config file and are uncomfortable with the command line text editors like Nano. You use Gedit GUI text editor to make the changes. It simplifies the life of Windows users who have to use Linux for their work.

Wondering how to run Linux GUI apps on Windows? There are the main steps for that:

- Enable WSL 2 and install a Linux distribution with it
- Install appropriate graphics driver for WSL
- Install and use GUI Linux apps

Let's see about the steps in detail.

## Requirements

As stated above, running Linux GUI applications is not available for all Windows versions. To do this, your system should be:

- For x64 systems:
**Version 1903**or later, with**Build 18362**or later. - For ARM64 systems:
**Version 2004**or later, with**Build 19041**or later. - The installed Linux distribution should use WSL2

Remember that, the requirements above are solely for running Linux GUI apps. WSL is supported for some of the Windows 10 versions also. Please refer to the dedicated article detailing [how to install WSL in Windows](https://itsfoss.com/install-bash-on-windows/) for more about WSL and its uses.

## Step1: Installing Linux Distribution with WSL 2

This is a lot easier on Windows 11 which comes with built-in support for WSL 2.

### On Windows 11

You can use the Microsoft Store but I find it easier to use the command line.

You need to open PowerShell with admin privileges. For this, search for Powershell in the start menu, right-click on Powershell and select **Run as Administrator.**

![Run Powershell as an administrator](https://itsfoss.com/content/images/2023/01/run-powershell-as-an-administrator.webp)


*Run Powershell as an administrator*Enter the following command to install WSL.

`wsl --install`


**By default, Ubuntu will be installed as the Linux distribution**. If you want to install any other distribution, use the command below:

`wsl --list --online`


This will list all the available Linux distributions. Once you decide on the distribution, use the below command to install it.

`wsl --install <Distribution Name>`


Once finished downloading and installing, you need to reboot to apply the changes.

### On Windows 10

This is a bit complicated and takes some time and effort to run WSL version 2 on Windows 10.

Ensure that the Windows Subsystem for Linux feature is turned on. Execute the following command in Powershell with admin rights:

`dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart`


Reboot the device once the command is completed.

After this, you need to enable the **Virtual Machine Platform** feature. Open the Powershell with admin privileges and enter the following command:

`dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart`


Once again, restart the device to complete the WSL install and update to WSL 2.

Now, download the **Linux Kernel Update Package** for x64 machines from the [official website](https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi). If you are using ARM64 devices, use this link to [download the latest kernel update package](https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_arm64.msi).

If you are not sure about the device architecture, enter the command below in Powershell to get the type:

`systeminfo | find "System Type"`


When the file is downloaded, double-click on it and finish the installation of the Kernel update package. Now, open PowerShell and run this command to set WSL 2 as the default version when installing a new Linux distribution:

`wsl --set-default-version 2`


**Once** **WSL2 is set as the default version**, you can now install the Linux distribution of your choice.

**Go to Windows Store and install Ubuntu.**

![Install ubuntu 22.04 LTS version from Microsoft Store](https://itsfoss.com/content/images/2023/01/ubuntu-22-04-wsl-1.jpg)


*Install Ubuntu from Microsoft Store*### 🛠️ Configure the newly installed Ubuntu

**Whether you installed WSL and Ubuntu using the Microsoft Store or the command line, you need to configure it.**

Here's how it is done:

Once you rebooted after installing Ubuntu, search for Ubuntu in Start Menu and open it.

![Open the Installed Ubuntu from Windows Start Menu](https://itsfoss.com/content/images/2023/01/open-ubuntu-from-windows-11-start-menu.webp)


*Open Ubuntu from Start Menu*It will ask you to enter a **UNIX Username** and **Password**. Enter these details and press enter key.

![When asks for the new UNIX username and password for the newly installed Ubuntu system, enter both details](https://itsfoss.com/content/images/2023/01/enter-unix-username-and-password.webp)


*Enter Unix username and Password*You will now be inside the terminal window of Ubuntu.

![Logged into new Ubuntu 22.04 LTS in Windows 11 WSL](https://itsfoss.com/content/images/2023/01/logged-into-new-ubuntu-22.webp)


*Logged into new Ubuntu 22.04 LTS in Windows 11 WSL*Once logged in, you need to update the installed Ubuntu. For this, enter the following commands one by one:

```
sudo apt update
sudo apt full-upgrade
```


After completing the update, you are good to go with Ubuntu in WSL.

![Running Ubuntu in WSL](https://itsfoss.com/content/images/2023/01/running-ubuntu-in-wsl-1.webp)


*Running Ubuntu in WSL*## Step 2: Installing GUI Applications

Once you are all set with the Linux distribution inside WSL, now is the time to install the Linux GUI application. It is done in two parts as described below.

### Download and Install Graphics drivers

To run GUI apps, you need to install appropriate graphics drivers. You can use the following link to download the drivers according to your provider.

Once installed, you are all done.

### Install some GUI Apps

Now, go to your Ubuntu app and install any GUI app using the APT package manager. You should note that running apps from other sources like flatpak are problematic within WSL.

For this article, I installed the Gedit text editor using the following command:

`sudo apt install gedit -y`


This will install several MB of packages including required libraries. Once completed, you can run the following command to start the GUI Gedit app in Windows:

`gedit`


![Run Gedit text editor GUI in WSL Ubuntu](https://itsfoss.com/content/images/2023/01/run-gedit-text-editor-gui-in-wsl-ubuntu.webp)


*Run Gedit text editor GUI in WSL Ubuntu*Similarly, you can install all the popular applications available to Linux, including Nautilus file manager, GIMP, etc. You can [refer to the official documentation](https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps) for more about running GUI applications in WSL.

## Wrapping Up

With WSL, Microsoft has provided a comfortable way of using Linux within Windows. It keeps on improving with each major version. Running GUI Linux apps on Windows feature is proof of the same.

As you can see, it is rather simple to use WSL 2 on Windows 11. Running it on Windows 10 takes some effort.

I hope you find this tutorial helpful. Let me know if you face any difficulties.