Linux
#
Linux on Windows MachinesStep 1 - Enable Windows Subsystems for Linux
Open cmd and run Powershell and enter, then run:
start-process PowerShell -verb runas
It will brings you to admin Window Powershell and copy paste command:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Step 2 - Check requirements for running WSL 2
Press Windows logo key + R, type winver, select OK
- For x64 systems: Version 1903 or higher, with Build 18362 or higher.
- For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.
- Builds lower than 18362 do not support WSL 2. Use the Windows Update Assistant to update your version of Windows
Step 3 - Enable Virtual Machine feature
Open powershell as admin again and run:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Make sure you Restart your machine to complete the WSL install and update to WSL 2 now
Step 4 - Download the Linux kernel update package
Download the latest package:
WSL2 Linux kernel update package for x64 machines Once the installation is complete, move on to the next step - setting WSL 2 as your default version when installing new Linux distributions. (Skip this step if you want your new Linux installs to be set to WSL 1).
Step 5 - Install Windows Terminal and Set WSL 2 as your default version
After you reboot, install the “Windows Terminal” app from the Microsoft Store
Open Windows terminal and run this command to set WSL 2 as the default version:
wsl --set-default-version 2
Getting a message:
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
or similar? then you can proceed further.
Step 5 - Install the Ubuntu app from the Windows Store
Create a user account for new Linux distribution. Username has no bearing on your Windows user name account. This account will be considered the Linux administrator, with the ability to run sudo.
Each Linux distribution running on the Windows Subsystem for Linux has its own Linux user accounts and passwords. You will have to configure a Linux user account every time you add a distribution, reinstall, or reset.
Finally, the prompt will change and you will be on a command line. Type pwd to see where you currently are in the FS, you should be at /home/<your username>
. This is the root level of your Ubuntu user.
Reset and forgot your Linux password:
To change your password, open your Linux distribution (Ubuntu for example) and enter the command: passwd
- Open PowerShell and enter the root of your default WSL distribution using the command:
wsl -u root
If you need to update the forgotten password on a distribution that is not your default, use the command:wsl -d Debian -u root
, replacing Debian with the name of your targeted distribution. - Once your WSL distribution has been opened at the root level inside PowerShell, you can use this command to update your password:
passwd <WSLUsername>
where<WSLUsername>
is the username of the account in the DISTRO whose password you've forgotten. You will be prompted to enter a new UNIX password and then confirm that password. Once you're told that the password has updated successfully, close WSL inside of PowerShell using the command:exit
Step 6 - Install Java on Ubuntu
First, update the apt package index with:
sudo apt update
Once the package index is updated install the default Java OpenJDK package with:
sudo apt install default-jdk
Verify the installation, by running the following command which will print the Java version:
java -version
Step 7 - Verifications
Verify that you are running WSL Version 2:
Open Windows Terminal
Run the following command:
wsl -l -v
You should see a report such as this, which should confirm your WSL Version:
NAME STATE VERSIONUbuntu-20.04 RUNNING 2
If your version states version 1, you might need to take an additional step to update Ubuntu. Enter the following command (replace Ubuntu-20.04 with the actual version you installed):
wsl --set-version Ubuntu-20.04 2
Re-Run the command above to verify your version
Verify Ubuntu is available in Windows Terminal:
Simply start windows terminal and launch Ubuntu from drop down menu
CONGRATULATIONS! You've successfully installed and set up a Linux distribution that is completely integrated with your Windows operating system!