How to set up WSL2 on Windows 10 and create a study environment for Linux commands

Introduction

Based on the information linked below, I set up to use WSL2 on Windows 10 and installed Ubuntu to create an environment where I can type Linux commands. [WSL2 Installation Guide for Win10] (https://docs.microsoft.com/en-us/windows/wsl/install-win10)

Unlike WSL1, WSL2 seems to have an architecture that runs the Linux kernel, and I thought it could be used as an environment for studying Linux on Windows. See the link below for the differences between WLS1 and WSL2. Differences between WSL1 and WSL2

Windows 10 environment where this procedure was performed
Edition version OS build Processor
Windows 10 Pro 2004 19041.508 x64 (AMD Ryzen7 3700X)

Update Windows 10 version

  1. Press the "Win" + "R" keys, enter "winver" and click the "OK" button.
  2. If the OS build is "18361" or less, WSL2 cannot be used, so please upgrade.
  3. To upgrade, press "Win" + "R" keys, enter "ms-settings: windows update" and click the "OK" button to upgrade.

Enable "Windows Subsystem for Linux" and "Virtual Machine Platform"

  1. Press the "Win" + "R" keys, enter "Optional Features" and click the "OK" button.
  2. Check "Windows subsystem for Linux".
  3. Check "Virtual Machine Platform".
  4. Reboot.

Set WSL2 to default version

  1. Enter "PowerShell" in "Enter here to search" on the right side of the start menu and select "Run as administrator".
  2. Execute the following command.
>wsl --set-default-version 2

I got the following error in my environment.

>wsl --set-default-version 2
error: 0x1bc
For the main differences from WSL 2, https://aka.ms/See wsl2

After updating the WSL2 kernel based on the information linked below, when I execute the command again, the error disappears. Kernel update

Install Ubuntu 20.04 LTS

  1. Install Ubuntu from the MicroSoft Store linked below.

Ubuntu 20.04 LTS

Start WSL

  1. Press "Win" + "R" keys, enter "wsl" and click the "OK" button, or select "Ubuntu 20.04 LTS" from the Start menu.
  2. The command prompt is displayed and the command can be executed. (The following is the execution result of the cal command that displays the calendar)
$ cal
   September 2020
Su Mo Tu We Th Fr Sa
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

Finally

Now you have an environment where you can type Linux commands on Windows 10. I thought that it would be easier to create a Linux environment than creating an environment by preparing a virtual environment (Virtual BOX or Hyper-V) and installing Linux from scratch. In the future, I would like to introduce Docker in this environment and prepare the program development environment.

Reference information

Windows Subsystem for Linux Documentation

Recommended Posts

How to set up WSL2 on Windows 10 and create a study environment for Linux commands
How to set up Ubuntu for Windows Subsystem for Linux 2 (WSL2)
Create a Linux environment on Windows 10
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
How to create a shortcut command for LINUX
Build Linux on a Windows environment. Steps to install Laradock and migrate
How to set up a Python environment using pyenv
How to create a local repository for Linux OS
Install and set Jupyter Notebook to create a study note creation environment [Mac]
Create a decent shell and python environment on Windows
How to set up and compile your Cython environment
How to build a Python environment on amazon linux 2
A memo on how to easily prepare a Linux exercise environment
Create a Python environment for professionals in VS Code on Windows
I tried to create a server environment that runs on Windows 10
Create a Python execution environment for Windows with VScode + Remote WSL
How to set up and use OMC Log Analytics --Linux version -
How to set up the development environment of ev3dev [Windows version]
Install wsl2 and master linux on windows
How to install Windows Subsystem For Linux
Create a Linux virtual machine on Windows
A story about trying to run JavaScripthon on Windows and giving up.
Create a Python development environment on Windows (Visual Studio Code remote WSL).
Steps to create a Python virtual environment with VS Code on Windows
How to set up a jupyter notebook on ssh destination (AWS EC2)
Try to set up a Vim test environment quite seriously (for Python)
[Development environment] How to create a data set close to the production DB
Verification of how to periodically execute a script on a Linux server on Windows
Reasons and work notes for the tool / environment kitchen to switch the main PC from Linux to Windows + WSL2
How to create a Python virtual environment (venv)
Try to create a new command on linux
How to live a decent life on 2017 Windows
[Note] How to create a Ruby development environment
How to set up a local development server
Set up a Python development environment on Marvericks
Set up an Objective-C 2.0 development environment on Linux
How to build Java environment on Ubuntu (Linux)
Create a Python virtual development environment on Windows
[Note] How to create a Mac development environment
Useful for changing permissions on Linux! How to count up to 31 with one hand.
How to quickly create a morphological analysis environment using Elasticsearch on macOS Sierra
How to run a Django application on a Docker container (development and production environment)
On Linux (Ubuntu), tune the Trackpad and set the function to a three-finger swipe
[Python] How to create a local web server environment with SimpleHTTPServer and CGIHTTPServer
How to prepare an environment with different python version and package for each project with pyenv-virtualenv on Amazon Linux
Linux (WSL) on Windows
Set up a development environment for natural language processing
Beginners! Basic Linux commands and how to use them!
Create a QR code for the URL on Linux
How to install Linux on a 32bit UEFI PC
[Go] How to create a custom error for Sentry
Create a comfortable Python 3 (Anaconda) development environment on windows
How to build a Django (python) environment on docker
Create an environment for MkDocs on Amazon Linux (attempted)
[Part 1] Let's set up a Minecraft server on Linux
Procedure for building a CDK environment on Windows (Python)
How to build a development environment for TensorFlow (1.0.0) (Mac)
How to run Django on IIS on a Windows server
Cross development environment (developing programs for windows on linux)
How to set up a Google Colab environment with Coursera's advanced machine learning courses
How to pass args or environment variables with Makefile and make command on #Linux