Linux and Windows together?
Are you a programmer, engineer, or student who wants to run Linux tools, but you're stuck with a Windows Computer? Back in the old days, you would have to set up a dual boot to run both. This is slow and bulky. The modern solution to this dilemma is WSL!
WSL stands for Windows Subsystem for Linux. WSL is a compatibility layer for running Linux binaries in the ELF 64 format like grep
, sed
, and awk
.
Using this you can run tools such as Vim, tux, emacs, along with programming languages such as NodeJS, Python, C/C++, and more. It also allows you to invoke Linux software on Windows, and vice-versa.
You might have also heard of WSL 2. This is simply an updated version of WSL 1. One of the reasons to update to WSL 2 is that it increases file system performance and support for full system calls.
If you have the Insiders Version of Windows, there is no need to follow this process. Linked here is a guide that will help you if you have a Windows insiders account. This guide is for those, like me, who haven’t signed up for the Windows Insiders Program or don't wish to.
So now that you know a little bit about WSL, let’s get it set up!
Step 1: Enable WSL
The first step is enabling the “Windows Subsystem for Linux” feature using Powershell. There is a way to do this in the settings but Powershell will be faster than digging through the convoluted Windows 10 settings.
Go ahead and open Powershell. Make sure to do this as an admin or else it won’t work. For future reference, every time this guide says to open Powershell, do it as an administrator.
It should look something like this
Once inside Powershell, enter this
dism.exe/online/enable-feature/featurename:Microsoft-Windows-Subsystem-Linux/all/norestart
From here I would suggest moving to step 2 and beginning the process of upgrading to WSL 2 for the speed boost, but if you’re sure that you only need WSL 1 you can restart your PC now and move to step 6.
Step 2: Check your requirements!
WSL 2 is relatively new and is only available for certain build versions of Windows 10. The build versions will differ depending on if you have an x64 or an ARM64 system.
If you aren’t sure what system you have, you can check easily in Powershell by entering
systeminfo | find "System Type"
If you have an x64 system, you will need version 1903 or higher with build 18362 or higher. ARM64 systems require version 2004 or higher and build 19041 or higher.
To check your Windows version and build open the settings using “Windows key+I”, navigate to System>About. Scroll down a bit and you’ll find the right information. The system type will also be here.
Step 3: Enable the Virtual machine feature
Now that you verified that your computer can facilitate WSL 2, you must enable the Virtual Machine Platform optional feature before installing the update. Open Powershell once again and run
dism.exe/online/enable-feature/featurename:VirtualMachinePlatform/all/norestart
After that restart your PC to complete the install of WSL and the update to WSL 2, then come back to this tutorial. We aren’t done yet.
Step 4: Download the Linux kernel update package
You will need to download the latest package for updating Linux. Here is the latest package for x64 systems.
If you have an ARM64 system use this package instead.
Once the installation is complete, run the new package. You will be prompted for elevated positions. Select “yes”.
Step 5: Set WSL 2 as the default version
From here things are getting easier. Open Powershell again and enter
wsl --set-default-versin 2
You can check the assigned WSL version for each Linux distribution in Powershell by typing wsl -l -v
.
If you need to change the version of WSL for a specific Linux distro, you can do so by entering wsl --set-version<distribution name><version number>
where <distribution name> is the actual name of the distribution and <version number> with 1 or 2 depending on which version of WSL you wish to use.
With WSL 2 set as the default, it is time to install your favorite Linux version.
Step 6: Install your favorite Linux Distro
You have made it to the last step! Your computer is ready for a Linux distro. Go ahead and open the Microsoft store and search for “Linux”. There are tons of options to choose from. I use Ubuntu 20.04 LTS as it is the most popular version and I don’t need the features from the others shells. Feel free to choose one that works best for you and your work or studies.
Once you download and install a Linux distribution, a console window will open and you will be asked to wait a few minutes. The wait is for the computer to decompress files and store them properly. This will only happen once and future boot-ups will only take a couple of seconds.
It will prompt you to create a user name and password. This is required and will be needed if you execute any sudo
commands.
Congratulations! You now have Windows Subsystem for Linux fully installed and working. You can end here or continue to make your Linux experience faster and more user-friendly.
Step 7: Installing the Windows Terminal (optional)
After installing a Linux version from the Windows store you will probably see a list of apps under “people also liked”. In there will be an app called Windows Terminal. If you don't see it, it will look like this.
It enables a multiple tab system, all with different command-line screens. I can have Powershell in one tab, Ubuntu in another, and multiple command prompt tabs all in one window.
You can create custom keybindings and use the search feature for faster workflows, along with being able to customize the theme fully.
Uninstalling Linux and WSL
If you ever need to uninstall Linux navigate to settings>apps>apps & features. Under “Apps & features” select the distribution you want to uninstall and then click the uninstall button.
To disable WSL from your system open settings>apps>apps & features. Under the “Related settings” section on the top right, click “Programs and features”. Next click the “Turn Windows features on or off” option on the left side of the screen. Scroll down to the “Windows Subsystem for Linux” option and deselect it. Click Ok and restart the PC.
Wrapping up
You now know how to set up WSL 1 & 2 on your Windows 10 pc! From here you can customize Ubuntu more using oh-my-zsh which is an open-source framework. Now you can use Linux for all kinds of projects and applications, such as managing a server, make a HTTP request, or run a EMACS.
If you are new to Linux and Bash I suggest learning some commands. Here is a handy cheat sheet of Linux commands to get you started. Now get out there and enjoy Linux!