Back to Setup

Windows Wsl

_partials/windows_wsl.md

latest4.6 KB
Original Source

Windows Subsystem for Linux (WSL)

WSL is the development environment we are using to run Ubuntu. You can learn more about WSL here.

We will install WSL 2 and Ubuntu in one command through the Windows Command Prompt.

:warning: In the following instruction, please be aware of the Ctrl + Shift + Enter key stroke to execute Windows Command Prompt with administrator privileges instead of just clicking on Okor pressing Enter.

  • Press Windows + R
  • Type cmd
  • Press Ctrl + Shift + Enter

:warning: You may have to accept the UAC confirmation about the privilege elevation.

A black terminal window will appear:

  • Copy the following command (Ctrl + C)
  • Paste it into the terminal window (Ctrl + V or by right-clicking in the window)
  • Run it by pressing Enter
powershell
wsl --install

:heavy_check_mark: If the command ran without any error, please restart your computer and continue below :+1:

:x: If you encounter an error message (or if you see some text in red in the window), please contact a teacher.

<details> <summary>Troubleshooting for Windows 10 (only if needed, check with a TA) </summary>

For Windows 10 < 2004: install WSL 1 first

:warning: In the following instruction, please be aware of the Ctrl + Shift + Enter key stroke to execute Windows PowerShell with administrator privileges instead of just clicking on Okor pressing Enter.

  • Press Windows + R
  • Type powershell
  • Press Ctrl + Shift + Enter

:warning: You may have to accept the UAC confirmation about the privilege elevation.

A blue terminal window will appear:

  • Copy the following commands one by one (Ctrl + C)
  • Paste them into the PowerShell window (Ctrl + V or by right-clicking in the window)
  • Run them by pressing Enter
powershell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
powershell
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
powershell
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

:heavy_check_mark: If all three commands ran without any error, please restart your computer and continue below :+1:

:x: If you encounter an error message (or if you see some text in red in the window), please contact a teacher

For Windows 10 users running WSL 1: Upgrade to WSL 2

If you are running Windows 10, we will then upgrade WSL to version 2.

Once your computer has restarted, we need to download the WSL2 installer.

  • Go to the download page
  • Download "WSL2 Linux kernel update package"
  • Open the file you've just downloaded
  • Click Next
  • Click Finish

:heavy_check_mark: If didn't encounter any error message, you're good to go :+1:

:x: If you encounter the error "This update only applies to machines with the Windows Subsystem for Linux", right click on the program and select uninstall; you shall be able to install it normally this time.

For Windows 10 users running WSL 1: Make WSL 2 the default Windows Subsystem for Linux

If you are running Windows 10, we will set WSL default version to 2.

Now that WSL 2 is installed, let's make it the default version:

  • Press Windows + R
  • Type cmd
  • Press Enter

In the window which appears, type:

bash
wsl --set-default-version 2

:heavy_check_mark: If you see "The operation completed successfully", you can close this terminal and continue to follow the instructions below :+1:

:x: If the message you get is about Virtualization, please contact a teacher

<details> <summary>Enable Virtual Machine Platform Windows feature</summary>

Follow the steps described here until you enable <strong>Virtual Machine Platform</strong> and <strong>Windows Subsystem for Linux</strong>

</details> <details> <summary>Enable Hyper-V Windows feature</summary>

Follow the steps described here until you enable the group <strong>Hyper-V</strong>

:information_source: If you are running Windows 10 Home edition, Hyper-V feature is not available for your operating system. It's non-blocking and you can still continue to follow the instructions below :ok_hand:

</details> </details>