DEV Community

Cover image for Quick-Start Guide: Setting Up an Ubuntu Development Environment with WSL and VSCode
Meg Rehn
Meg Rehn

Posted on

Quick-Start Guide: Setting Up an Ubuntu Development Environment with WSL and VSCode

Why WSL?

Windows Subsystem for Linux (WSL) makes it easy to run Linux tools on Windows. I've personally used this setup for the last 5 years. The integration between Windows <-> Windows Terminal <-> Linux FS <-> VS Code is seamless and quite enjoyable to use.

Why Ubuntu?

Ubuntu is the default Linux distro for WSL and since the beginning, I have found it to have the best support in the WSL ecosystem. You'll also find good support for Ubuntu/Debian based systems in general. There are other distros in the Microsoft store, and you don't have to pick just one. Multiple can be installed and run concurrently.

What's covered in this guide?

  • Ubuntu 22.04 on WSL
  • Windows Terminal
  • oh-my-zsh git-ready terminal
  • VS Code integration
  • Docker Desktop integration

Install WSL and Configure Ubuntu as Default

On most Windows systems the use this command to enable all Windows dependencies and install a default Ubuntu Linux distribution (PowerShell):

wsl --install
Enter fullscreen mode Exit fullscreen mode

If your system requires additional configuration, refer to the docs: https://learn.microsoft.com/en-us/windows/wsl/install

You may need to upgrade to a newer Ubuntu version if the default installed was out of date. Get the latest Ubuntu from MS Store (we'll use 22.04 LTS): https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-10#1-overview

List installed distros:

wsl -l
Enter fullscreen mode Exit fullscreen mode

Set an installed distro as the wsl default:

wsl -d Ubuntu-22.04
Enter fullscreen mode Exit fullscreen mode

Windows Terminal

Windows Terminal is the polar opposite of the traditional windows shell experience; with native tabbing, split terminals, appearance customization, support for powershell, cmd, and all linux distros all in one place. 👌

Learn more and install: https://learn.microsoft.com/en-us/windows/terminal/

Set Ubuntu 22.04 as your default shell in Windows Terminal

Enter the setting on Windows Terminal by clicking the down arrow at the top or pressing ctl+,

Set your default profile:
windows terminal default setting

Configure Ubuntu

⚠ When you start up Ubuntu for the first time you'll need to configure your root user. Do so and set a password.

Add /snap/bin to path

#Add /snap/bin to the path
sudo sed -i \
     "s#^PATH=.*#PATH=\"/snap/bin:$(echo $PATH)\"#" \
     /etc/environment
#Load new path
source /etc/environment
Enter fullscreen mode Exit fullscreen mode

Set up git-ready terminal

Cruise control into a rich terminal experience using oh-my-zsh (powerlevel10k), setup guide here: https://github.com/romkatv/powerlevel10k#installation

Almost there, I promise 😉 - Your terminal should look something like this now:
Ubuntu in WSL

Set up VS Code

VS Code is great IDE, it's also the perfect compliment for developing on WSL. Download it here: https://code.visualstudio.com/

Microsoft publishes a WSL extension for VS Code, it allows you to run work and build directly on your Linux filesystem from the VS Code process.

Get it from the marketplace here: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl

Once you've set up your IDE and cloned a git repository into your Linux system you can open any repo in VS Code by using code , to open the current directory code .

Open WSL git directory in VS Code

Top comments (0)