An Interest In:
Web News this Week
- April 2, 2024
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
A Guide to Installing the Windows Subsystem for Linux (WSL) and Windows Terminal
As a developer that typically works on Mac or Linux, you will be disappointed with the out-of-the-box terminal in Windows. Lucky for us, Windows supports a fairly smooth Linux integration called the Windows Subsystem for Linux (or WSL for short). If you are unfamiliar with it, Microsoft has a pretty concise explanation:
The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual-boot setup.
This guide is meant to serve as a quick reference for setting it up yourself (as I recently had to do).
Overview
This guide is not a comprehensive resource for all available options. Instead, I have made some assumptions to help you get it set up quickly.
- You do not want to join the Windows Insider Program and install a preview build of Windows.
- You do want to upgrade to WSL 2.
- You do want to use Ubuntu 20.04 LTS as your Linux distribution.
- You do want to use the Windows Terminal app.
Installation
Let's get started!
Enable WSL 1
We have to first enable WSL 1 before we can upgrade to WSL 2. In PowerShell (as an administrator), run the following command.
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Enable the Virtual Machine Platform feature
To enable the Virtual Machine Platform feature (required for WSL 2), run the following command in PowerShell (as an administrator).
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart your machine
In order to continue the installation of WSL 1 and 2, you will need to restart your machine. This can be done by running the following in PowerShell (as an administrator).
Restart-Computer
Update the Linux kernel
The Linux kernel update package is required to upgrade to WSL 2. To download and run the update, I recommend moving into a different directory since the administrator PowerShell dumps you into the system32
directory. You can accomplish this with the following command in PowerShell (as an administrator).
cd ~ ; wget https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi -outfile update.msi ; .\update.msi
You will be prompted to finish the WSL update.
Set WSL 2 as the default
In PowerShell (as an administrator), run the following command to set WSL 2 as the default.
wsl --set-default-version 2
Install Ubuntu 20.04 LTS
Get Ubuntu 20.04 LTS from Microsoft. You will need to click the "Get" link to open the Microsoft Store. From there, you can click "Install" to download and install the Ubuntu distribution.
Launch Ubuntu
The Ubuntu 20.04 LTS app should now be easily searchable in your list of Windows apps. Launch the app to finish setup. You will need to provide a username and password.
Note: If you encounter an error related to virtualization when launching the app, you may need to enable virtualization at the BIOS level.
Install Windows Terminal
Get Windows Terminal from Microsoft. You will need to click the "Get" link to open the Microsoft Store. From there, you can click "Install" to download and install the app. For more information on Windows Terminal, head over to Microsoft Docs.
Set Ubuntu as the default
To set Ubuntu as the default terminal in Windows Terminal, you will need to edit the settings.json
file. To open this, click the dropdown arrow next to the new tab button and click on "Settings" near the bottom of the menu that pops up. The file will look something like this (unnecessary info has been removed).
{ "defaultProfile": "{a-random-uuid-for-powershell}", "profiles": { "list": [ { "guid": "{a-random-uuid-for-powershell}", "name": "Windows PowerShell" }, { "guid": "{a-random-uuid-for-ubuntu}", "name": "Ubuntu-20.04" } ] }}
You just need to update the defaultProfile
property with the UUID for Ubuntu and save the file. That's it!
Closing
While this isn't necessarily a short article, I believe it is pretty concise. It aggregates information from a few sources to hopefully get you up and running with WSL 2 and Windows Terminal as quickly as possible.
Original Link: https://dev.to/voraciousdev/a-guide-to-installing-the-windows-subsystem-for-linux-wsl-and-windows-terminal-4dd4
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To