# A Step-by-Step Guide to Adding Ubuntu (WSL) in VS Code Terminal

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:

1. **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.
        
2. **Visual Studio Code**
    
    * Download and install VS Code from [code.visualstudio.com](https://code.visualstudio.com/).
        

---

## **Step 1: Install WSL on Windows**

### 1.1 Enable WSL

1. Open PowerShell as Administrator.
    
2. Run the following command to enable WSL:
    
    ```powershell
    wsl --install
    ```
    
3. Restart your computer if prompted.
    

### 1.2 Verify Installation

After the restart, verify that WSL is installed by running:

```powershell
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:
    
    ```powershell
    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).
    

```powershell
wsl
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735145101229/f78b8016-2762-4089-93d5-dd9a505b221a.png align="center")

---

## **Step 2: Install VS Code Extensions**

To integrate WSL with VS Code, install the following extensions:

1. **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`

1. Open VS Code.
    
2. Press `Ctrl+Shift+P` and type “Preferences: Open Settings (JSON).”
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735144462062/af6ba3f6-53b0-45c0-aa4e-307fdaa0e06e.png align="center")
    
3. Select it to open the `settings.json` file.
    

### 3.2 Add Terminal Profiles

Add the following configuration for Ubuntu (WSL):

```json
{
    "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

1. Save the changes to `settings.json`.
    
2. Reload VS Code by pressing `Ctrl+Shift+P` and typing **Reload Window**.
    

---

## **Step 4: Test the Configuration**

1. Open the terminal in VS Code by pressing `` Ctrl+` `` (backtick).
    
2. Click the dropdown menu in the terminal tab.
    
3. Select **Ubuntu (WSL)**.
    
4. You should see a terminal that looks like this:
    
    ```bash
    amitabh@Amitabh-Laptop:~$
    ```
    

---

## **Troubleshooting Tips**

1. **WSL Not Recognized**
    
    * Ensure WSL is installed and Ubuntu is set up. Run `wsl --install -d Ubuntu` if needed.
        
2. **Ubuntu Not Listed in Terminal Dropdown**
    
    * Double-check the `settings.json` file for typos.
        
    * Restart VS Code after saving changes.
        
3. **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!

---
