DEV Community

Cover image for How to run GUI apps trough WSL?
Ivaylo Ivanov
Ivaylo Ivanov

Posted on

How to run GUI apps trough WSL?

Hi, guys today I will show you how to run GUI apps through WSL. As you know by default WSL 1 offers just a terminal of the selected Linux distro but in WSL 2 there are some changes and you are going to be able to run GUI applications through WLS 2 directly in windows. Without further due let's hop into the topic.

Note: If you have wsl 1 installed skip to step 2, otherwise follow the steps as it is.

1. Installing WSL.

In case to install the WSL (windows subsystem for Linux), you will need administrator permissions on your machine. After that, you will have to open the windows PowerShell as administrator and activate the wsl feature. To that just paste this command in ht PowerShell and hit enter.

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Enter fullscreen mode Exit fullscreen mode

If the command has been executed successfully restart your machine and continue to step 2.

2. Enabling Virtual Machine Feature and installing WSL 2 version.

After everyone has WSL installed, in case to switch to WSL 2 you will need to enable A special built-in virtual machine for wsl 2. To do that just paste this into your PowerShell (opened as administrator)

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Enter fullscreen mode Exit fullscreen mode

After you have enabled the virtual machine feature, it is time to install the WSL version 2. To do that, download the latest kernel update here. It is an official Microsoft executable, that you can run just by double-clicking after you install it. It is time for the final step - Running GUI apps through WSL on windows.

3. Running GUI apps through WSL.

We are almost finished this is the last step to do, I promise. To be able to run any graphical app through WSL you will need a graphics card driver in addition. You can download the special driver for either GeForce or Quadro series graphics cards. Wait for it to download, then install it by double-clicking. After it is installed it is good to practice rebooting your machine. After you have it rebooted you can install any application on your WSL Linux Distro, for example, "Firefox".

sudo apt install firefox
Enter fullscreen mode Exit fullscreen mode

After the installation is completed you can simply run the application, in our case, it is firefox so we are going to run it by typing in the command line firefox. Wait for it for some time because it is the first launch and if everything has been set up as it should, you should be prompted with the firefox application directly on your windows screen, running through WSL.
Congratulations you have successfully set up WSL 2 and enabled GUI on trough WSL. ๐ŸŽ‰๐ŸŽบ๐ŸŽ‰

If you have any questions, just leave a comment, I will answer as soon as possible.

Top comments (3)

Collapse
 
anonyco profile image
Jack Giffin • Edited

If you have any self-respect, please never use WSL. It is pure evil.

Always run Linux for real on bare metal. There is literally no reason whatsoever why anyone could be running any operating system other than a Linux distro nowadays. The standard stock repo on most distros comes with most of the software you'll ever use. And, for that one or tools you need on occasion, you can enable extra repos, use a language-specific package manager (e.x. cargo, rust, gem, pip3, yarn, etc.), or git clone and build from source. If software fails to build from source, then no big deal! Just take 3 seconds to install docker and build from source in the recommended environment and use the software from within a docker container. If you absolutely NEED to run windows software, then no big deal! You can just WINE it and sometimes the software even runs a lot better in WINE thanks to a lack of anti-privacy malware.

Collapse
 
ivayloiv profile image
Ivaylo Ivanov

I agree 100% with, you but for people that are just starting to study Linux and are used to windows, but do not have any other machine to install Linux on, it is great opportunity to get used to it.

Collapse
 
anonyco profile image
Jack Giffin • Edited

I take a different approach in this matter. I've seen far too many people who use Linux through WSL or a VM and have only a "meh" or awful experience with Linux. How little do they realize that Linux in a VM/WSL just can't compare to the real deal? That's why it's my habit to never let people run Linux in a VM/WSL for their first experience. They either should try Linux for real or not try it at all. At the very least, if they don't try it, then there's still hope for them that they'll try the real deal in the future.

Also, you do not need a second machine to run Linux. That's crazy and insane. You just need to repartition your harddrive in order to dual boot Windows and Linux and configure Windows to comply by disabling bitlocker and such.