End-to-end WSL Installation Guide

Want to install a Linux distribution but have important files on your computer? Do you want to familiarize yourself with the Linux environment before installing a distribution on your host? Whatever the reason, the transition to Linux is now much more effortless thanks to WSL (Windows Subsystem for Linux). So much so that now graphical interface applications run smoothly in WSL.

WSL is a layer that translates Linux system calls to Windows system calls. Thus, there is not much difference between software running on WSL and software running on Windows. In addition, only the “userland” part of Linux, which is the user layer, can be translated by the layer. So it is not possible to run Linux drivers under Windows yet.

Background processes that we call “daemon” can also work in WSL because they run in the “userland” part. If you are dealing with web servers, WSL also offers a solution for you.

Software such as Cygwin already offered such a solution to users, but WSL is more popular than Cygwin because it is more integrated with Windows.

The activation process of WSL is different in Windows 10 and 11. In Windows 11, you can download WSL from the Microsoft Store. In Windows 10, to activate WSL, let’s enter the dialog where we manage the extra features of Windows by typing “Turn Windows features on or off” in the search bar.

windows ozellikleri

Then, in the dialog that comes up, let’s find the “Windows Subsystem for Linux” option and tick it.

wsl

After clicking the “OK” button, our operating system will contact the Microsoft server and start the installation of WSL.

wsl kuruyor
Loading!

After completion, a message will appear saying that the desired changes are finished and our device needs to be restarted.

wsl yeniden baslat

How can I run WSL?

We will run WSL via PowerShell or Command Prompt, but naturally it will not work as we do not have any Linux distribution installed at the moment.

Linux distributions that can work with WSL are officially “not on a finger”. For now:

  • Debian GNU/Linux,
  • ubuntu,
  • KaliLinux,
  • OpenSuse Leap 42 and
  • SUSE Linux Enterprise Server 12

distributions can run under WSL. We will use our preference for Ubuntu for this article.

wsl ubuntu
We are installing the latest version of Ubuntu, 22.04… Let’s not forget that it will receive updates for 5 years since it is in the LTS program.

After Ubuntu downloads, we press the “Open” button and it extracts the files and starts the installation.

ubuntu wsl

It then asks us to enter a UNIX username. UNIX usernames are usernames that are all lowercase and contain ASCII characters. Let’s also mention that it doesn’t have to match our Windows username.

ubuntu wsl3

Since the GNU/Linux operating system is designed to replace UNIX systems in institutions, login with a password is mandatory. Although it is very simple, you need to set a password.

ubuntu wsl basarili

And we successfully installed it! The error message related to the “motd” (“message of the day” – message of the day) you see above is not so important if you are not going to use this system with more than one user. By creating a file named “.hushlogin” in our user folder, we can ensure that “motd” is not displayed once a day.

ubuntu wsl guncelleme

After creating our “.hushlogin” file by saying touch ~/.hushlogin, we can check for updates by typing sudo apt update && sudo apt upgrade, and update if any.

The process of using applications with X11-based GUI (graphical interface) in WSL is also separated in Windows 11 and Windows 10. In Windows 10, you need to install the third-party X11 server, VcXSrv, for this, while in Windows 11, X11 calls are routed directly to the Windows 11 desktop. Therefore, Windows 11 users can skip to the next subtitle.

How does VcXSrv work?

In our article about the X11 protocol, we mentioned that the protocol was originally network-based. The VcXSrv application will also communicate with the applications we run in WSL over our local network.

VcXSrv installation

After downloading and installing VcXSrv, the following screen will appear:

vcxsrv client tur

You can make it look like a Windows application by selecting the “Multiple windows” option on this screen. If you wish, you can also run desktop environments by choosing other options. Since we will not run X server directly in Windows 11, desktop environments will not work. You can also change the “Display number” part here to “0”.

vcxsrv client 2

On this screen, I say “Start no client” and say that I do not want any client application to start.

vcxsrv client 3

By selecting the “Disable access control” option at the bottom, we eliminate the possibility of “Access denied” type errors by enabling any X11 client application to connect to our server.

vcxsrv client 4

And our configuration process is complete. You can ensure that these settings are not lost by saying “Save configuration”.

vcxsrv client firewall

After going through Windows Firewall, we can integrate our X11 server with WSL. First, let’s type ipconfig in Command Prompt and get the local IP address of our active network adapter. Since the local IP address on this machine is 192.168.1.107, we will use this address.

Let’s set our environment variable called DISPLAY in our WSL system as 192.168.1.107:screen_number.

wsl export
You can set environment variables with the “export” command!

That too!

That’s it! Now that our X11 server is running in the background and our WSL is set to our X11 server, we can run our favorite apps! Let’s try running Gedit right away:

wsl x11
Finally!

And happy ending! It was worth the effort!

If you are a Windows 11 user, all you have to do is download the vGPU driver for your video card for WSL. So you can run X11 applications with hardware acceleration not available in VcXSrv.

  • Intel vGPU driver
  • AMD vGPU driver
  • NVIDIA vGPU driver
wsl gui screenshot
That’s it!

Summary

In this guide, we set up the WSL subsystem with you. From now on, it will depend on your UNIX shell experiences. If you need any help with UNIX or Linux you can opt for the GNU/Linux subsection on Technopat Social.

Related Posts

Leave a Reply

Your email address will not be published.