Backup your windows machine first -- just in case something goes wrong.
Here is a YouTube video that runs through a similar process for installing WSL to that described here. Note however, that the video will not go through the exact same instructions as seen below. For example, the instructions below do not address graphics-based linux programs like the video does, but they do address the installation of java. Still, you may wish to view this video before proceeding to get a feel for approximately what you will see.
In search bar, type PowerShell
Right-click "Windows Powershell" (probably identified as the "best match" and at the top of the search results) and select "Run as Administrator" (you might have to type your user name and password to allow this -- and your account must of course be an administrator account)
In PowerShell, run the following command (i.e., type it at the PowerShell prompt and hit enter). This will enable WSL, install the latest Linux kernel, and set the default distribution to "Ubuntu":
wsl --install
After the installation has completed successfully, you will get a message that the changes will not be effective until the system is rebooted. Type the following and hit enter at the next PowerShell prompt to accomplish this:
restart-computer
After reboot, WSL will launch Ubuntu in the Terminal application (wait for this to happen). You will then be prompted to enter a new UNIX username and new password for your Linux environment (REMEMBER THESE!)
You can at that time update your linux distribution by typing the following at the prompt (you'll be asked for the password you just set)
sudo apt update && sudo apt upgrade -y
When the text finally settles down and you see your prompt again, you should have a Ubuntu linux distribution installed.
Note however, at this point Terminal will still open PowerShell by default the next time you launch it. You can change this by clicking the small down arrow (v) in the top tab bar and select Settings > Startup. Then, under "Default Profile", change the selection to "Ubuntu" (the one with the square-shaped icon). Save the changes.
Note, you will still be able to launch a PowerShell window (among other types of windows) by clicking the small down arrow (v) in the top tab bar at any time and selecting PowerShell. Optionally, you can launch PowerShell directly, like we did in step 1.
Try it out at this point. Close Terminal and re-open it. Note -- it may take 20 seconds or so for the terminal window to show you the Ubuntu prompt on its otherwise blank window -- WAIT FOR IT! To test things out, type "pwd" at the prompt. This should print your working directory, so you know where you are.
If when launching Terminal, your machine complains about a missing font (e.g., Ubuntu Mono), you can fix this by again clicking that small down arrow (v) in the top tab bar, then click "Settings", select the (square icon) for Ubuntu, then navigate to Appearance > Text > Font face, and select a different font -- just be sure to select a mono-spaced font (e.g., Cascadia Mono) otherwise things may look weird in the future.
Importantly, Java must be installed separately for WSL (even if you have already installed Java for Windows) To do this, first make sure your Ubuntu's internal list of available software packages and their versions from online repositories is up to date by typing the following in a Ubuntu (in Terminal) prompt
sudo apt update
Then, install the latest stable OpenJDK available for Ubuntu with
sudo apt install default-jdk -yFinally, verify the installation by typing
java -versionYou should see something like:
openjdk version 21.0.9 ...