Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
December 29, 2020 05:00 am GMT

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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"      }    ]  }}
Enter fullscreen mode Exit fullscreen mode

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

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To