How to Set Up WSL (Windows Subsystem for Linux) or WSL 2 on Windows
WSL (Windows Subsystem for Linux) is a feature in Windows that enables you to run a Linux distribution alongside your Windows environment. This allows developers and system administrators to enjoy the benefits of both operating systems without the need for dual-booting. In this article, we will guide you through setting up WSL and WSL 2 on your Windows machine, enabling you to seamlessly run Linux commands and applications right from your Windows command prompt.
Prerequisites
Before proceeding with the installation, ensure that your system meets the following requirements:
- Windows 10 version 1903 or higher (64-bit)
- Windows Build with WSL support (You can check this by running
wsl --list
in PowerShell or Command Prompt. If WSL is not installed, proceed with the installation.)
Step 1: Enable Windows Subsystem for Linux (WSL)
- Open PowerShell as Administrator by right-clicking the Start button, selecting “Windows PowerShell (Admin).”
- Run the following command to enable the Windows Subsystem for Linux feature:
wsl --install
- Restart your computer when prompted.
Step 2: Choose a Linux Distribution
- Open the Microsoft Store on your Windows machine.
- Search for your preferred Linux distribution, such as Ubuntu, Debian, or Fedora.
- Select the distribution you want to install and click the “Install” button.
- Wait for the installation to complete. This may take a few minutes.
Step 3: Initialize the Linux Distribution
- Once the installation is finished, launch the Linux distribution from the Start menu.
- The first time you launch the distribution, it will take some time to set up the environment. You’ll be prompted to create a username and password for your Linux environment.
- After setting up the username and password, you’ll have access to a fully functional Linux terminal.
Step 4 (Optional): Upgrade to WSL 2
WSL 2 offers significant improvements over the initial WSL version, such as faster performance and full system call compatibility. If your Windows build supports WSL 2, you can upgrade using the following steps:
- Open PowerShell as Administrator.
- Run the following command to set WSL 2 as your default version:
wsl --set-default-version 2
- Once the default version is set, you can convert your existing WSL installation to WSL 2. For example, if you have Ubuntu installed:
wsl --set-version Ubuntu 2
- Wait for the conversion process to complete. This might take a few minutes, depending on the size of your distribution.
Step 5: Enjoy WSL or WSL 2
Congratulations! You have successfully set up WSL or WSL 2 on your Windows machine. You can now run Linux commands and use Linux applications from your Windows command prompt or terminal. The integration between Windows and Linux will provide a seamless development environment, allowing you to take advantage of the best of both worlds.
Conclusion
WSL and WSL 2 are powerful features that bring the benefits of Linux to Windows users. With a few simple steps, you can set up and enjoy a Linux terminal right on your Windows machine. Whether you are a developer or system administrator, having WSL or WSL 2 at your disposal will undoubtedly enhance your productivity and provide a smooth development experience on the Windows platform. So go ahead, explore the Linux world from your Windows environment, and leverage the full potential of both operating systems. Happy coding!