How to run graphical Linux applications on Windows 10 using the Windows Subsystem for Linux (WSL)

The Windows Subsystem for Linux (WSL) was introduced by Microsoft in the Windows 10 Anniversary Update. It allows users to run a full Linux user space in Windows. It is a much nicer approach for most applications than Cygwin, or using a Linux VM. It is not an emulator either. Think of it as GNU/Linux/Windows (apologies to Richard Stallman). This guide starts off with Microsoft’s instructions for installing the WSL, and then goes a few steps further by describing how to run graphical Linux applications.


Your PC must be running (at a minimum) a 64-bit version of Windows 10 with the Anniversary Update. The Creator’s Update is recommended.

To find your PC’s CPU architecture and Windows version/build number, open Settings>System>About. Look for the System Type and Version fields respectively, as shown in the screenshot below.

Acreenshot of the About section of the Windows 10 Settings app

If your build is below 14393, try checking for updates.

Enable the Windows Subsystem for Linux feature

You can enable the feature using a GUI or command-line interface.

GUI Method

  1. From the Start Menu, search for “Turn Windows features on or off” (type ‘turn’)
  2. Select Windows Subsystem for Linux
    The Windows features dialog box in Windows 10
  3. Click OK

Command-line Method

Open a PowerShell prompt as administrator and run:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

After enabling Windows Subsystem for Linux

Restart your computer when prompted.

It is important that you DO restart when prompted as some of the infrastructure which the Windows Subsystem for Linux requires can only be loaded during Windows’ boot-up sequence.

Install your Linux distribution of choice

Linux distributions can be installed using a script, or by using the Microsoft Store links below:

After installation your Linux distribution will be located at: %localappdata%\lxss\ This directory is marked as a hidden system folder for a very good reason:

Avoid creating and/or modifying files in this location using Windows tools and apps! If you do, it is likely that your Linux files will be corrupted and data loss may occur. Please read this blog post for more information.

Create a UNIX user

The first time you launch a Linux distribution in Windows, you will be prompted to create a UNIX username and password.

A screenshot of a new UNIX user being created for Bash on Ubuntu on Windows

This UNIX username and password has no relationship to your Windows username and password, and it can be different. 

Use the same username that you use on remote Linux/UNIX systems, so you won’t need to specify it in individual configuration files, or every time you run commands like sshRead more.

Update the Linux distribution

After you have set up your user, update the OS.

To do this on Debian/Ubuntu based distributions, run:

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y

Install common tools

The Debian distribution for WSL is minimal, so many packages that you might expect to be installed, such as ca-certificates, are not installed. To fix this, run:

sudo apt install -y ca-certificates findutils command-not-found vim nano curl openssh-client less screen apt-utils top htop whois git python3-pip

Accessing the Windows filesystem from WSL

Windows drives are mounted by their drive letters under /mnt. For example, your Windows C: drive is accessible via /mnt/c.

To make it easier to access your Windows user directory, consider adding a symbolic link, such as:

ln -s /mnt/c/Users/Sean/ ~/winhome

On Amazon WorkSpaces, this your Windows user directory is located in /mnt/d/Users.

That way, your Windows user directory is accessible from ~/winhome.

Graphical Applications

In order to run Linux GUI applications using WSL, you must:

  1. Install a X server for Windows
  2. Configure bash to tell GUIs to use the local X server

Install VcXsrv

In order to run graphical Linux applications, you’ll need an X server.

VcXsrv is the only fully open source and up-do-date native X server for Windows. Download and run the latest installer, then locate the XLaunch shortcut in the Start Menu, and click it.

You will be greeted with a setup wizard. Accept the default options. On the last page of the wizard, click on the Save configuration button, and save the configuration file in %appdata%\Microsoft\Windows\Start Menu\Programs\Startup, so vcXsrv will launch at startup without asking about these options, then click on the Finish button.

You may receive a prompt to allow it through your firewall. Cancel/deny this request! Otherwise, other computers on your network could access the server.

A X icon will appear in your system tray.

Configure bash to use the local X server

  1. In bash run:
    echo "export DISPLAY=localhost:0.0" >> ~/.bashrc
  2. To have the configuration changes take effect, restart bash, or run:
    . ~/.bashrc

Instructions for fish shell users

If you use fish instead of bash:

  1. echo "set -x DISPLAY localhost:0.0" >> ~/.config/fish/
  2. To have the configuration changes take effect, restart fish, or run:
    . ~/.config/fish/

Test a graphical application

  1. Install x11-apps
    sudo apt-get install x11-apps
  2. Run xeyes

A new window will open, containing a pair of eyes that will follow your mouse movements.

Running remote GUI applications over SSH

To use a GUI application from a server, simply use the -X switch with the ssh command, for example:

ssh -X [email protected]

And run the GUI application from the shell prompt.

Using Visual Studio Code

Instead on installing the Linux version on Visual Studio Code on your WSL Linux distribution, install Visual Studio Code in Windows, and add the Remote Development extension pack.

After reloading Visual Studio Code, click on the green arrows at the bottom right corner of the window, and select Remote-WSL: New window action.

A new window will open with a Linux shell and editor. You will be able to edit files on the Linux file system.

Any Visual Studio Code extensions need to be installed in your Windows instance of Visual Studio Code first, and then on the WSL instance.

Recommended extensions for information security professionals include:


65 thoughts on “How to run graphical Linux applications on Windows 10 using the Windows Subsystem for Linux (WSL)”

  1. I followed all the steps, but when I start VcXsrv, it finish suddenly
    A fatal error has occurred and VcXsrv will now exit

    Cannot move old log file…

    Please open xxxxx\VCXsrv.0.log for more information

    This is the content of that log

    Welcome to the VcXsrv X Server
    Vendor: The VcXsrv Project

    OS: Windows NT 6.2 build 9200 (64-bit)
    Contact: [email protected]

    LoadPreferences: C:\Users\Sergio\AppData\Roaming\.XWinrc not found
    LoadPreferences: Loading C:\Program Files\VcXsrv\system.XWinrc
    Warning: Locale not supported by X, falling back to ‘C’ locale.
    (II) AIGLX: enabled GLX_MESA_copy_sub_buffer
    (II) AIGLX: enabled GLX_SGI_swap_control
    (II) 103 pixel formats reported by wglGetPixelFormatAttribivARB
    (II) GLX: Initialized Win32 native WGL GL provider for screen 0
    winClipboardThreadProc – DISPLAY=
    OS maintains clipboard viewer chain: yes

  2. Great article. I was actually looking for way to plot octave graphs in nice separate windows instead of the terminal. This solution is much more general that what I was searching for.

  3. when I entered gedit command it’s shoes this please help to find the solution

    Failed to connect to Mir: Failed to connect to server socket: No such file or directory
    Unable to init server: Could not connect: Connection refused

  4. Hi I am trying to open graphical softwares over SSH. It works locally however when I try to connect to another server I get “Error: can’t open display: localhost:0.0”. Is there ant way to solve that?

  5. Hi when I am trying to open gedit it is showing Unable to init server: could not connect: Connection refused.
    Gtk- Warning: can’t open display
    Please give me solution for this.

  6. This works well up to displaying X based Apps under Windows 10 Ubuntu.

    But I cannot see my mouse pointer within the X Windows graphics. How do I make my Mouse visible ?

  7. New to Windows 10 Pro and Ubuntu 18.04 LTS (but not to *nix, via MacOSX). Reinstalled Win10 and Ubuntu a couple of times trying to get a GUI working in WSL. Turns out, what one needs is this list of steps. Had Ubuntu installed, WSL set, VcXsrv installed, even the DISPLAY command added, but still no GUI. It really helps to set Developer mode. Also, the strings added by some other “how to” step-by-each guides aren’t necessary (yet). Appreciated greatly.

  8. This works great, thank you. On the newer Win 10 versions (as of Feb 2019) you download Ubantu from the Store rather than typing “bash” in at the command line. Otherwise everything else works.

  9. I followed all the steps but for installing bash it prompted the message that to visit Microsoft store that install it from there.

  10. estoy usando VcXsrv sin problemas
    export DISPLAY=:0
    echo “export DISPLAY=localhost:0.0” >> bashrc
    apt-get install xfce4
    carpeta linux

    apt-get install x11-apps
    xbiff, xcalc, xconsole, xedit y xman

    recuerdo que ya es posible usar desde conexion remota windows

  11. when i use gedit it generate lots of error but it runs completely fine?
    this are the errors.

    (gedit:24): GLib-GIO-CRITICAL **: 09:32:35.375: g_dbus_proxy_new_sync: assertion ‘G_IS_DBUS_CONNECTION (connection)’ failed

    (gedit:24): dconf-WARNING **: 09:32:35.448: failed to commit changes to dconf: Failed to execute child process “dbus-launch” (No such file or directory)

    (gedit:24): dconf-WARNING **: 09:32:35.460: failed to commit changes to dconf: Failed to execute child process “dbus-launch” (No such file or directory)

    (gedit:24): dconf-WARNING **: 09:32:35.992: failed to commit changes to dconf: Failed to execute child process “dbus-launch” (No such file or directory)

    (gedit:24): dconf-WARNING **: 09:32:35.993: failed to commit changes to dconf: Failed to execute child process “dbus-launch” (No such file or directory)

    (gedit:24): dconf-WARNING **: 09:32:35.994: failed to commit changes to dconf: Failed to execute child process “dbus-launch” (No such file or directory)

    ** (gedit:24): WARNING **: 09:32:38.623: Set document metadata failed: Setting attribute metadata::gedit-position not supported

    (gedit:24): dconf-WARNING **: 09:32:38.656: failed to commit changes to dconf: Failed to execute child process “dbus-launch” (No such file or directory)

  12. Thanks for this write-up. I was wondering if there is a way to launch Windows 10 applications from the Ubuntu bash terminal window, like starting the default Windows 10 browser. I understand it would involve some kind of bridge to launch the *.exe files from within the Linux environment. Perhaps the Windows 10 developers have integrated this “bridge”, but I haven’t been able to find any documentation for it.

  13. Paste where? I’ve got little experience with Windows10 so I don’t understand what this is about.

    Paste the shortcut in %appdata%\Microsoft\Windows\Start Menu\Programs\Startup

    ———————————————————–..and I had no success at all:
    ed@od-win10:~$ echo “export DISPLAY=localhost:0.0” >> ~/.bashrc
    ed@od-win10:~$ xterm
    xterm: Xt error: Can’t open display:
    xterm: DISPLAY is not set

    • Hi Ed,

      echo “export DISPLAY=localhost:0.0” >> ~/.bashrc

      Just creates the configuration file. You need to close bash and reopen it for the bashrc file to apply.

      • Hi I also get a “can’t open display ” error trying to launch VcXsrv. I have moved my “root” directory to a different folder for easy acces. Using these commands the configuration file is within said folder. Should I move .bashrc to where my WLS files are or is something else going wrong?
        Thank you for this guide.

  14. Dear Ed

    The ‘xterm’ command does not work unless it is preceded by the first line of code below:

    export DISPLAY=localhost:0.0

    The fancy line that begins with ‘echo’ is a convenient way to add the ‘export’ command to the configuration file named ‘bashrc’ in the user home directory. The “.” before the file name is only needed if this file is hidden.

    echo “export DISPLAY=localhost:0.0” >> ~/.bashrc


  15. Worked first time for me. Pretty nifty.

    Tested with this Python code:

    from tkinter import *
    myGui = Tk()
    ss = Tk()

    def hello():
    b = a.get()
    myLabel3 = Label(text=b, fg='red', bg='yellow', font=10).pack()
    def dele():
    myLabel1 = Label(text='deleted',fg='red',bg='yellow',font=10).pack()

    a = StringVar()

    ss.title("Second Window")

    myLabel1 = Label(myGui,text='label one',fg='red',bg='yellow',font=10).pack()
    myButton1 = Button(text='enter',fg='black',bg='green',command = hello,font=10).pack()
    myButton2 = Button(text='delete',fg='black',bg='red',command = dele,font=10).pack()
    text = Entry(textvariable=a).pack()


  16. hi, i´m doing every step but when i run the xeyes comand in bash it says: Error: Can’t open display: localhost:0.0 maybe i missed somethig, please help

  17. After I open this program for a while, and try to exit, it informs me that certain number (4 to 8) clients connected.
    What are these clients?
    I am not using SSH to connect anywhere.

    • The clients are the windows of your GUI application. They are connecting to vcXsrv over localhost to be displayed.

  18. Hi Sean! Just a question/feedback about the last part of your article. You said that we could use VSC on Windows, *instead* of installing it on WSL. But then, you proceed to say that:

    “Any Visual Studio Code extensions need to be installed in your Windows instance of Visual Studio Code first, and then on the WSL instance.”

    What did you mean by install the extension on WSL instance? Should we know the path that a WSL installation of the VSC would take for the extensions?

    Or should we still install VSC on the WSL (just choose to use the Windows instance, instead)?


  19. Nice explanation.

    Small correction proposal:

    It seem there is a duplicate of “sudo apt-get upgrade -y” in

    sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y

    Thank you

  20. Hi, thanks. While vcxsrv is downloading, I thought it would be great if you have some blog to work gui systems on WSL2.
    I am hoping the same above should work, but it will be good if you mention in your blog what needs to be done for WSL2.

    Thanks a ton!

  21. I had trouble doing all this and uxing Xming. I thought VcXsrv would help. I still have the issue:

    Error: Can’t open display: localhost:0.0


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.