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.
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.
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:
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.
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.
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.
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.
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.
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
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.
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.
2. Stop Win-Kex active server session:- If you want to stop the running Win-Kex server pass the simple command.
$ kex --stop
3. Check Win-Kex server session status:- When you want to check session status type the below command.
$ kex --status $ sudo kex --status
If the service is not running then you get the output beneath screen.
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
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
$ 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
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.