Skip to content

Seamless Development on Windows 11 with WSL 2.3 and Ubuntu 24.04.1 LTS

Seamless Development on Windows 11 with WSL 2.3 and Ubuntu 24.04.1 LTS

Developers and tech enthusiasts often find themselves navigating between the robust development tools of Linux and the user-friendly ecosystem of Windows. This is where Windows Subsystem for Linux (WSL) becomes a real game-changer With WSL 2.3 on Windows 11 and vscode, you can seamlessly run a full Linux environment like Ubuntu 24.04.1 LTS without needing a dual boot or virtual machine.

Setting Up WSL 2.3 on Windows 11

Enable WSL

  1. Open Command Prompt, Terminal or PowerShell with administrator privileges.
  2. Run the following command to enable WSL:
wsl --install
  • This will install the latest version of WSL, including the Linux kernel.

Ensure You're Using WSL 2.3

  1. Check the version of WSL in use:
wsl --version
  1. If you're not using WSL 2.3, update WSL:
wsl --update

Install Ubuntu 24.04.1 LTS

  1. Download Ubuntu from the Microsoft Store Ubuntu 24.04.1 LTS
  2. Open Ubuntu and follow the instructions to set up your user and password.

By default, WSL can use as much memory as it needs, potentially consuming significant resources, especially during intensive tasks like compiling code or running multiple processes, to ensure balanced resource allocation between your Windows host system and the Linux environment running in WSL we need to limit WSL memory in .wslconfig

  1. Create or edit the .wslconfig file in C:\Users\<username>\.wslconfig.
  2. Create new files in notepad and add the following configuration to limit resources:
[wsl]
memory=4GB
processors=2
  1. Restart WSL for the changes to take effect:
wsl --shutdown

Setting Up Ubuntu 24.04.1 on WSL

Update and Upgrade Packages

sudo apt update && sudo apt upgrade -y

Install Tools and Dependencies

sudo apt install build-essential git curl wget dns-utils vim nano -y

Integrating VS Code with WSL

VScode Connected To WSL

Install VS Code in Windows 11

  1. Download and install Visual Studio Code.

Install WSL Extension

  1. Open VS Code, then install Remote Development extension.

Connect to Ubuntu

  1. Open the Command Palette (Ctrl+Shift+P), type Remote-WSL: New Window, and select the Ubuntu distribution.

Install Extensions (Optional)

  • Code Editor Tools: Prettier, ESLint, GitLens.
  • Docker Extension: For managing containers.

Conclusion

Integrating Windows 11 with WSL 2.3 and Ubuntu 24.04.1 LTS bridges the gap between the flexibility of Linux and the convenience of Windows, The integration offers the best of both such as

  • A powerful development environment without the overhead of virtual machines.
  • Direct access to Linux tools and utilities within the Windows ecosystem.
  • Seamless workflows using tools like VS Code and Docker.

While the setup might require some initial configuration, the benefits far outweigh the effort. WSL provides a lightweight yet robust platform for coding, testing, and deploying applications efficiently.

Reference