If you’re working on Windows and want to harness the power of Linux alongside your development environment, integrating Ubuntu (WSL) into the VS Code terminal is a seamless way to do so. In this blog, we’ll walk you through the entire process—from setting up prerequisites to configuring Ubuntu in your VS Code terminal.
Prerequisites
Before we start, ensure the following:
Windows 10/11 Installed
You need a Windows machine running at least version 1903 or higher for WSL 2.
To check your version, run
winver
in the Start Menu.
Visual Studio Code
- Download and install VS Code from code.visualstudio.com.
Step 1: Install WSL on Windows
1.1 Enable WSL
Open PowerShell as Administrator.
Run the following command to enable WSL:
wsl --install
Restart your computer if prompted.
1.2 Verify Installation
After the restart, verify that WSL is installed by running:
wsl --list --verbose
You should see a list of installed distributions with their states.
1.3 Set WSL as Default (Optional):
To ensure WSL is the default shell for your terminal, you can use:
wsl --set-default Ubuntu
This ensures that running the
wsl
command will always open your Ubuntu distribution.
1.4 Varify working of WSL
- Run below command in your local terminal (CMD,PowerShell).
wsl
Step 2: Install VS Code Extensions
To integrate WSL with VS Code, install the following extensions:
WSL
Open VS Code.
Go to the Extensions view by clicking the Extensions icon on the left sidebar (or press
Ctrl+Shift+X
).Search for “WSL” and click Install.
Step 3: Configure Ubuntu (WSL) in VS Code Terminal
To set up Ubuntu (WSL) in the VS Code terminal:
3.1 Open settings.json
Open VS Code.
Press
Ctrl+Shift+P
and type “Preferences: Open Settings (JSON).”Select it to open the
settings.json
file.
3.2 Add Terminal Profiles
Add the following configuration for Ubuntu (WSL):
{
"workbench.iconTheme": "vscode-icons",
"editor.mouseWheelZoom": true,
"terminal.integrated.fontSize": 15,
"explorer.confirmDelete": false,
"files.autoSave": "afterDelay",
"terminal.integrated.profiles.windows": {
"Ubuntu (WSL)": {
"path": "C:\\WINDOWS\\System32\\wsl.exe"
}
},
"terminal.integrated.defaultProfile.windows": "Ubuntu (WSL)"
}
3.3 Save and Reload VS Code
Save the changes to
settings.json
.Reload VS Code by pressing
Ctrl+Shift+P
and typing Reload Window.
Step 4: Test the Configuration
Open the terminal in VS Code by pressing
Ctrl+`
(backtick).Click the dropdown menu in the terminal tab.
Select Ubuntu (WSL).
You should see a terminal that looks like this:
amitabh@Amitabh-Laptop:~$
Troubleshooting Tips
WSL Not Recognized
- Ensure WSL is installed and Ubuntu is set up. Run
wsl --install -d Ubuntu
if needed.
- Ensure WSL is installed and Ubuntu is set up. Run
Ubuntu Not Listed in Terminal Dropdown
Double-check the
settings.json
file for typos.Restart VS Code after saving changes.
Extensions Not Working
- Ensure the “WSL” extension is installed and enabled.
Conclusion
With Ubuntu (WSL) configured in VS Code, you can now work seamlessly in a Linux environment directly from your Windows machine. Whether you’re developing web apps, testing scripts, or running Docker containers, this setup will make your workflow more efficient. Happy coding!