How to Install GUI (Win-Kex) for Kali Linux in WSL2

In the last article, we have guided you on how to Install WSL2 with Kali Linux on Windows 10, and we have received immense requests for the GUI Installation guide.

So, Without taking any further delay, let start to Install GUI for Kali Linux on WSL2.

Prerequisite

To continue with this guide, first, you need to Install WSL2 on your Windows PC. We have already written an article on How to Install WSL2 and Kali Linux on Windows 10

First, refer to the above link then back to this GUI Installation article.

Installation of Win-Kex

To Install Win-Kex or to get GUI, you need to pass a couple of commands, First, update and upgrade the repository.

$ sudo apt update && sudo apt upgrade -y

If you’re getting a slow apt update, make sure to use the mirror link for a fast apt update. To change the mirror link, click on the below article.

slow apt update
slow apt update

Read this to Fix Kali Linux slow apt update process

After updating the repository now, we will Install Kex for GUI. To install kex, type or copy-paste the following command in your terminal

$ sudo apt install -y kali-win-kex

This process will take some time, mainly depend upon your internet connection, and the file size is nearly 600 MB.

When the download is complete, you will ask to select Language. We have selected “English,” you can choose as per your preference and wait for some time to get the process complete.

After waiting for minutes, Installation is successfully completed. Now, it’s time run and explores Kali-Linux in WSL2

To explore Kali-linux in wsl2 pass the following command:

$ kex
Set kex Password
Set kex Password

It will ask you to set a password, verify the password, and last, it will ask you to enter a view-only password, type n.

Win-Kex server start
Win-Kex server start

Now, wait for a second you will ask you to provide the kex password which you recently created. After that, you will able to see the screen in TigerVNC.

Kali Linux GUI(Win-Kex)
Kali Linux GUI(Win-Kex)

Note:- Whenever you want to exit from GUI of Kali-Linux, which runs on TigerVnc viewer, press the key “fn” with “f8” and click on Exit Viewer.

 Press fn + f8
Press fn + f8

After doing this, step back to the Kali-Linux app or already running terminal and stop the running Win-Wex server session.

To stop Win-Wex server session pass the following command

$ kex --stop

Make sure to follow this step to avoid unwanted issues to occur.

Troubleshoot

If you are not able to start kex in GUI and you’re getting an error on-screen “unable to contact settings server” with the message “Failed to execute child process dbus-launch Kali Linux (No such file or directory)” like the below image.

unable to contact settings server
unable to contact settings server

To resolve this issue, you need to follow a couple of steps, and your problem will be resolved.

Step 1. We need to stop the xrdp service. To stop, pass the following command in your wsl terminal.

$ sudo service xrdp stop

Step 2. Now we install the missing dependencies. Because of this missing library, we cannot start the screen.

To install dbus-x11 type command

$ sudo apt install dbus-x11

Step 3. We need to start xrdp service, type the below command.

$ sudo service xrdp start

Step 4. Before running kex, make sure to kill Win-KeX server sessions. To kill, type both commands with sudo and without sudo.

$ sudo kex kill
$ kex kill
To check Win-Kex status
To check Win-Kex status

You can see two different Win-KeX servers from the above output, One without the sudo command and the other with sudo.

So, make sure to pass both the command.

Step 5. Start Win KeX service

After completing the above step, we will start the Win-Kex server for the Kali GUI version. To start, pass the following command.

$ sudo kex

You will ask to provide a Win-Kex password, which you have created on the above steps.

Win-Kex Password
Win-Kex Password

That’s it to resolve the dbus-x11 error. If you are facing any while step up, please go through the above steps.

Useful Win-KeX commands

You should note the important command while accessing Win-Kex otherwise, bookmark this page for later access.

1. Start Win-Kex server session:- To start fresh Win-Kex, you need to pass single command and wait for TigerVnc to start.

$ kex
Start Win-Kex server session
Start Win-Kex server session

2. Stop Win-Kex active server session:- If you want to stop the running Win-Kex server pass the simple command.

$ kex --stop
Stop Win-Kex active server session
Stop Win-Kex active server session

3. Check Win-Kex server session status:- When you want to check session status type the below command.

$ kex --status
$ sudo kex --status
Check Win-Kex server session status
Check Win-Kex server session status

If the service is not running then you get the output beneath screen.

Win-Kex status
Win-Kex status

4. Kill Win-Kex server session:- To kill all the running Win-Kex service you can pass the following command.

$ kex --kill
$ sudo kex --kill

If you want to kill a specific Win-KeX server session for that, you should know the Process ID to get the process id type command in the terminal.

$ kex --status
$ kex --kill 407
Kill Win-Kex server session:
Kill Win-Kex server session:

5. Password change in Win-Kex:- In case you don’t remember the Win-Kex password, you can easily reset the password with the simple command.

$ kex --passwd
Password change in Win-Kex
Password change in Win-Kex
$ sudo apt install -y kali-linux-default

If you want to explore more handy commands for Win-Kex, you can refer to the help command.

$ kex --help
Win-Kex Help options
Win-Kex Help options

That’s all to Install GUI or Win-Kex on WSL2. If you are stuck somewhere or need any assistance from our side, feel free to comment.

If you want me to explore more command of Win-Kex and make a separate article for that, comment us.

This Post Has 3 Comments

  1. chris

    Hi

    i did all these steps, and they worked fine, but found a few issues, if i could mention them to you:
    1) After following instructions, i type kex and get the GUI over all my monitors, howver i have to keep pressing F8 to just make the system display on my primary monitor, it does’nt save the fact i only want my primary display for Kali. Even when you log off Kali it says save settings for future sessions, i wonder if you could help with this.
    2) Once i type kex gui starts without networking (my PC has a lan connection)
    3) Once i type kex gui starts without sound, and when i type kex -s, i get an error, i also get an error if i type kex –sl or kex –sl -s.
    Im new to WSL2 and linux, but i wanted to get involved with linux from tutorials on line, as i’m getting a bit bored of windows (but dont want to change just yet), so WSL2 seems a good way to investigate linux.

    I hope this makes sense and hope you may be able to help.

    Thanks

  2. Donovan

    Thank you from a pure linux and Kali Linux newb!

    Much appreciated

Leave a Reply