Sunday, August 18, 2024

WSL Windows 10 & 11

Win 10 latest version and 11
Powershell as admin:
The following 3 commands worked after, on one PC, I checked the feature boxes, rebooted and couldn't get wsl.exe to do anything.
Usually just checking the features boxes and rebooting works.

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart
*I assume a reboot is required

Then:

wsl --update (will install wsl if not installed)
wsl --install Ubuntu-22.04 (or get from MS Store)
Start from the start menu to finish setup.
wsl -l -v
If version 1
wsl --set-default-version 2
wsl --set-version Ubuntu-22.04

You will end with enter user and password. If cursor not blinking move window slightly to activate the cursor.

Close Powershell and reopen

wsl -l -v
NAME            STATE           VERSION
* Ubuntu-22.04    Running         2 

Start Menu Ubuntu (If running Windows Terminal open from there)

sudo apt update && sudo apt full-upgrade

sudo apt install neofetch (or whatever)
Linux gui apps will run and shortcuts will be created in the start menu

**Before you install Ubuntu desktop go to bottom of this post. Install Kali desktop instead unless you really want the Ubuntu desktop. You can run everthing without desktop. The gui apps work fine.

To install Ubuntu desktop:
 (I'm not sure why I even want it. Linux gui apps work anyway)

Power Shell admin and boot "wsl -u root"
 (This leaves your wsl user logon free for the RDP logon)
sudo apt install tasksel
sudo tasksel
 choose desktop
 select xfce or unselect to remove) move with arrows, select with space bar. Tab to OK
sudo apt install xrdp
 cp /etc/xrdp.startwm.sh /etc/xrdp.startwm.sh.bak
 sudo nano /etc/xrdp/startwm.sh
 disable all the entries with #
 add startxfce4
 ctl+o enter then ctl+escape
ip a (for ip address)
Don't close Power Shell (wsl -u root). WSL needs to be running.
start windows remote desktop client (if it is not installed reinstall it)
enter ip of linux machine
enter user name and password

In the root terminal:
XFCE terminal won't work to go to wsl terminal and do this:
sudo apt-get install xfce4-terminal
sudo update-alternatives --config x-terminal-emulator (choose 2 xfce)

Add Whisker Menu to the Panel:
sudo apt install xfce4-whiskermenu-plugin
 Right-click on the Xfce panel and select Panel > Panel Preferences.
 Go to the Items tab and click Add.
 In the Add New Items window, select Whisker Menu and click Add.
 Once added, you can move it to the desired position using the Arrow Up button and remove the default Applications Menu if desired.

Problems I had before figuring it out:
I think I'm giving up on this . . . Linux gui apps work anyway so who needs it.
( Windows 10 I have not connected successfully. I get to providing credentials and get kicked out)
Same thing on Windows 11
WSL needs to be running but you can't log on RDP with the same credentials.
You could add a user and rdp with that user.
Or you could start wsl as root from Power Shell wsl -u root.
Edit the startwm.sh file and only allowed startxfce4. If using xfce of course.
Thank you Perplexity
I'm on a Dell XPS 13 so no human could read the high resolution :) but yep, it's xfce desktop.
OK, you don't need a second user. Log on to wsl as root from Power Shell
wsl -u root
Start RDP and use your user crdentials

Firefox not work: (haven't found fix)
Install Chrome

Firefox won't work so install Google Chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt install --fix-broken -y
which google-chrome
google-chrome --version
to test launch
google-chrome
If works add above to wisker menu

WSL will run Linux GUI apps from terminal without desktop but the terminal must remain open. Multiple termenals can be open.


More exciting is Kali desktop

Win key
Microsft Store "store"
Kali Linux install & open
user name & password - password
sudo apt update && sudo apt install kali-win-kex -y
*Wow, that took awhile*
kex (to start)
passwords again but must ve 6 digets
some other question "n"
OK >That's crazy simple
Yes Kali is in the Windows terminal. Start it and type kex.
The basic pentesting stuff is not installed so you would need to install it.
sudo apt update && sudo apt full-upgrade -y
apt install kali-linux-all (You can't access local network without changing the distro settings. I personally wouldn't bother)

Uninstalling
wsl --unregister <distroName>
Then remove the distro app like any Windows Store app.
After reinstall close Windows terminal and reopen and open distro from the Win start menu.

 "guid": "{46ca431a-3a87-5fb3-83cd-11ececc031d2}",
                "hidden": false,
                "name": "kali-linux",
                "source": "Windows.Terminal.Wsl"

C:\Windows\system32\wsl.exe -d kali-linux
ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png

Things to do and try after install
sudo apt install nala -y
sudo nala fetch

Installing deb packages
1. open terminal in the folder containing package.deb
2. sudo dpkg -i package-name.deb

try inter font
system settings has transparent panel option

sudo apt install ttf-mscorefonts-installer

Let AI Help Blog Posting

I've only done this once and yep, it worked. Create the blog post. Copy the text to clipboard. Go to Claude and paste it in.  Claude wil...