First, you have to make sure your computer runs Windows 10 64 bit, and updated to the latest version of Windows. Then you can enable WSL feature by going to Turn Windows features on or off from Programs and Features as marked below. You might need to restart your computer after that.
Then select Windows Subsystem for Linux.
Now open Microsoft Store and choose your favorite Linux Distro. For this tutorial I’m going to install Ubuntu 18.04.
Launch your Linux distros, you might need to enter username and password for the first time. Then, update it to the latest version :
$ sudo apt-get update
$ sudo apt-get upgrade
Now, you have installed WSL on your Windows successfully. You can do it by using Powershell. To know more: https://docs.microsoft.com/en-us/windows/wsl/install-win10
And now we’re going for the graphical part. To do this we need VcXsrv. VcXsrv is a Windows X-server based on the xorg git sources (like xming or cygwin’s xwin). You can download it from https://sourceforge.net/projects/vcxsrv/
After installing VcXsrv, let’s start XLaunch and do some setup. First you can choose whether you like One Large Window or Fullscreen option, then choose Start no client, and then check Disable access control. When finished, you will see big window blank screen appear.
Now let’s install Desktop Environment for your WSL. I’m going to use XFCE4 since it’s lightweight, but you may want to try the other such as KDE, GNOME, LXDE, Cinnamon, MATE, etc.
$ sudo apt-get install xfce4
After the installation finished, make sure you’re in your home directory. Edit .bashrc for some configuration.
$ cd ~
$ nano .bashrc
Go to the last line and write this :
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
Exit your WSL and run it again.
The format of this command is [host]:<display>.[screen]
where [host]
refers to a network host name. you can easily find this by looking at your /etc/resolv.conf file. This above command will give the appropriate result by combining all of these.
Now after we got everything we need, let’s start the session. It might not work without -ac argument.
$ startxfce4 -ac
Congratulations! Now you can use your WSL using Graphical User Interface.