How to Install and Set Up WSL 2 with Debian on Windows
Coming from a Linux - sometimes Arch, sometimes Debian or Ubuntu background.. I was interested to try the WSL setup on Windows
26th Jan 2023
Problems
I had many years developing on Windows at my place of work. None of which I have particularly happy memories of, the struggles with visual studio and the like or worse. Home was always a happy place tinkering with Linux distros. Docker enabled me to take a lot of my windows only work and transition my dev to Linux fulltime. I thrived there but working in a windows shop.. there was always a challenge here and there.. vpn issues with ipsec tunnels.. phone system setups.. none of if ever worked perfectly. So when wsl came along I thought I would give it a try.
Here’s a quick guide on setting up WSL 2 with Debian on Windows:
Step 1: Enable WSL and Install WSL 2
- Open PowerShell as Administrator.
- Run this command to enable WSL:
This installs WSL with the latest version, WSL 2, as the default. Windows will prompt you to restart.
wsl --install
Step 2: Install Debian
Once WSL is enabled:
- Open Microsoft Store and search for "Debian."
- Select Debian from the list and click Get to install.
- Launch Debian from the Start Menu, which will prompt you to set up a new Linux user and password.
Step 3: Update and Upgrade Debian
Once Debian is running:
- Run the following commands to update and upgrade your packages:
sudo apt update && sudo apt upgrade -y
Step 4: Set WSL 2 as the Default Version
If you have multiple versions of WSL installed, make sure WSL 2 is the default by running:
wsl --set-default-version 2
Step 5: Install Essential Packages (Optional)
Depending on your needs, you may want to install some additional packages. Here’s a quick setup for some essentials:
sudo apt install build-essential curl git -y
Step 6: Access Files from Windows and Debian
Your Windows drives are automatically mounted under /mnt
(e.g., /mnt/c
for C: drive). To access files, navigate to this directory in Debian:
cd /mnt/c/Users/YourUsername/Documents
Now you have WSL 2 with Debian fully installed and ready to use on Windows! You can install other development tools and set up your environment just like on a native Linux system.