01 — WSL and Ubuntu on Windows

Setup
Windows
Linux
Install WSL 2 and Ubuntu and learn the basic workflow for using Linux on a Windows computer.

What is WSL?

Windows Subsystem for Linux (WSL) allows you to run a Linux environment directly on Windows. For this course, it provides a convenient way for Windows users to work with Ubuntu, Bash, Git, Python, Conda, and other tools commonly used in computer vision and robotics.

WSL avoids the need for dual booting or maintaining a separate Linux computer.

Note

This tutorial is only needed if you use Windows. macOS and Linux users can skip it.

1. Install WSL

Open PowerShell as Administrator and run:

wsl --install

Restart Windows if prompted.

The default installation uses WSL 2 and installs Ubuntu. If you want to explicitly install Ubuntu 24.04 LTS, first check the available distribution names:

wsl --list --online

Then install Ubuntu 24.04:

wsl --install -d Ubuntu-24.04

When Ubuntu launches for the first time, create a Linux username and password.

Tip

Your Linux username and password do not need to match your Windows credentials. Remember the Linux password because you will need it when using sudo.

Official documentation:
https://learn.microsoft.com/windows/wsl/install

2. Verify that WSL 2 is being used

In PowerShell:

wsl --list --verbose

You should see your Ubuntu distribution with version 2.

Example:

  NAME            STATE           VERSION
* Ubuntu-24.04    Running         2

If an existing distribution is still using WSL 1, it can be converted with:

wsl --set-version Ubuntu-24.04 2

Use the exact distribution name shown by wsl --list --verbose.

3. Update WSL

From PowerShell:

wsl --update

You can check WSL information with:

wsl --version

4. Install Windows Terminal

Windows Terminal is optional but recommended because it provides a convenient interface for PowerShell, Command Prompt, and WSL terminals.

https://aka.ms/terminal

After installation, open Windows Terminal and choose Ubuntu from the dropdown menu.

5. Update Ubuntu

Inside the Ubuntu terminal, run:

sudo apt update
sudo apt upgrade -y

The first command updates the package list. The second installs available updates.

You can verify the Ubuntu version with:

lsb_release -a

6. Create a course workspace

For best performance with Linux tools, keep your Linux projects inside the WSL filesystem rather than under /mnt/c/.

Create a folder for course projects:

mkdir -p ~/cv_projects
cd ~/cv_projects

Check your current location:

pwd

You should see something similar to:

/home/your_username/cv_projects
Important

Avoid creating separate copies of the same Conda environment in both Windows and WSL. If you are using the WSL workflow, install Conda and the course cv environment inside WSL.

7. Access files across Windows and Ubuntu

Windows files from Ubuntu

Windows drives are mounted under /mnt/.

For example, your Windows C: drive is available at:

/mnt/c/

Your Windows Downloads folder is usually:

cd /mnt/c/Users/YOUR_WINDOWS_USERNAME/Downloads

Ubuntu files from Windows

Open File Explorer and enter:

\\wsl$

You can browse the Ubuntu filesystem from there.

You can also open the current Ubuntu directory in File Explorer by running:

explorer.exe .

8. Useful WSL commands

These commands are run from PowerShell, not from inside Ubuntu.

List installed distributions:

wsl --list --verbose

Stop all running WSL instances:

wsl --shutdown

Start your default Linux distribution:

wsl

Run a specific distribution:

wsl -d Ubuntu-24.04

9. Basic Linux commands

You will use these frequently:

Command Purpose
pwd Show the current directory
ls List files
ls -la List files, including hidden files
cd folder Enter a directory
cd .. Move up one directory
cd ~ Go to your Linux home directory
mkdir folder Create a directory
cp source destination Copy a file
mv source destination Move or rename a file
rm file Delete a file
clear Clear the terminal
history Show recent commands
Warning

Linux commands such as rm normally do not move files to a recycle bin. Double-check paths before deleting files.

10. Troubleshooting

A command was installed but is not recognized

Close all Ubuntu terminals, then run this from PowerShell:

wsl --shutdown

Open Ubuntu again and retry.

WSL installation is stuck

Microsoft documents an alternate download option:

wsl --install --web-download -d Ubuntu-24.04

Check that virtualization is available

WSL 2 requires hardware virtualization. On most modern computers it is already enabled. If WSL reports a virtualization error, check Windows Task Manager → Performance → CPU → Virtualization.

Next steps

Once Ubuntu is working, you can install Git and the course Python/Conda environment inside WSL.