"Portable Wi-Fi" Review
25/03/2022
This article is limited to members.You can see everything by registering (free).
WSLを始めようLinux環境「WSL」をこれから始める読者のための、インストール方法やバックアップ方法などをまとめて解説する。"Windows Subsystem for Linux (WSL)", which allows you to build a Linux execution environment on "Windows 10" and "Windows 11", is steadily updated.In the WSL, the official version is available from the Windows 10 Fall Creators Update (version 1709), and then May 2020 Update (version 2004) provides "WSL 2", which is compatible with Linux (WSL 2 "(WSL 2).For the Windows 10 The Latest, "Search for the new Linux environment" WSL 2 ", which has greatly improved its performance from the previous version).
Initially, in the [Control Panel] of Windows 10, run the Linux subsystem on the [Enable or disable Windows function] on the [Programs and Functions] screen, then Microsoft Microsoft for Linux Distribution.A slightly troublesome procedure, such as installing from Store, was required.
Windows 10 May 2020 Update (Version 2004) allows the Linux subsystem and Linux distribution to be installed on the command line, making it easier to install.
Therefore, in this article, we will explain how to back up from WSL installation to readers who are starting the WSL in the future.
WSL is a Linux environment executed on the Windows OS.Here, it is used as a term that refers to the general WSL technology installed on the Windows OS.The following is a brief explanation of the basic things related to the WSL.
The WSL can be roughly divided into the first version released (here is "WSL 1" for distinction) and the "WSL 2", which is the first released.WSL 2 is a method that uses Linux kernels and virtual machines, and is more compatible with Linux than WSL 1.For example, Docker did not work in WSL 1, but in WSL 2, Linux native Docker can operate as it is.
WSL 2 operates on a dedicated virtual machine, and when using it, the PC has a virtual machine support function and must be enabled in the BIOS.However, since the procedure varies depending on the PC model, it is not explained here.Please refer to the PC manual.
Microsoft calls this dedicated virtual machine as "lightweight utility VM".This is different from the "Hyper-V" virtual machine environment supported by Windows OS, and unlike Hyper-V, it can be operated in the Home edition of Windows 10/11.
The difference in use of WSL 1 and WSL 2 will be explained later.
The Linux distribution used in this WSL is especially described as "WSL distribution".Basically, the WSL distribution is the same as the Linux distribution, but is customized to operate within the WSL 1 / WSL 2, and is distributed via Microsoft Store.
The WSL distribution has its own "distribution name".This is for handling multiple distributions in the WSL.The name of the distribution is close to the name of the WSL distribution distributed on the Microsoft Store, but not at all.
It is enabled that the blanks do not enter so that they can be easily set as arguments during the command line, so that they can be described relatively short.For example, "Ubuntu 18 in the Microsoft Store.04 LTS "Ubuntu-18.The distribution name "04" is given.
When using the WSL, the internal Linux environment is often described as "WSL" and "WSL", and the Windows OS environment that is outside the WSL is "Win32" or "Win32 side".For example, the function of launching a Windows OS command from the WSL is called "Win32 interaction".
Here, in accordance with this notation, two environments are called as necessary.In this case, to clarify that it is a command on the Win32 side, "CMD.Be sure to specify the executable file name such as "EXE".On the Windows OS side, "CURL.There is a command derived from Linux such as "EXE", and if it is simply "CURL" on the WSL side, the CURL command on the Linux side will be executed.This is "CURL.If you say "EXE", a command with the same name on Win32 will be executed.
In order to start the command on the Win32 side only with the executable file name as described later, it is necessary to set the PATH environment variable.Standards, since all the paths set in the PATH environment variable on the Win32 side are copied to the WSL side, the command can be executed in the same way as Win32 (how to configure PATH environment variables, Tech Tips "[Windows" [Windows "[Windows).11 compatible] See / edit Path environment variables to enable their own command.).
For the behavior of WSL, etc., "%userprofile%\ \" on the Win32 side.WSLCONFIG "file and"/etc/WSL on the WSL side.Use Conf ".Also, installation of WSL itself and WSL distribution is "WSL.Do it with the command "EXE".
Because there is an environmental setting, here is the premise of performing all commands on Windows Terminal.If you are using other terminal emulators, be aware of the settings.
Here, as a WSL distribution, Ubuntu-18.I'm using 04.In other distributions, some differences in the commands on the WSL side may be partial.In that case, please read it as appropriate according to the installed WSL distribution.
Please note that Linux is basically distinguished by uppercase / lowercase letters.In the execution example shown in the sentence, the difference between the behavior of the optional uppercase / lowercase character occurs, so it is necessary to accurately enter uppercase / lowercase letters on the WSL side.
In the current Windows 10/11, WSL distribution can be set as "WSL 1" or "WSL 2".The installation is the same, and it is possible to convert WSL 1 and WSL 2 later.
Basically, there are many software that WSL 2 can be used, and it is closer to real Linux.However, WSL 1 has the advantage of using the same IP address on the Win32 side and using the same IP address on the Win32 side.In addition, there is a relationship that does not use virtual machines, flexibility in memory allocation and low system load.
Therefore, there is still the advantage of choosing WSL 1 depending on the usage.If you don't use it in earnest and want to learn Linux first, you may choose a flexible WSL 1 for resource allocation.
Or a CMD that mainly wants to use Linux Bash on the command line.If it is a substitute for EXE or PowerShell, there is no reason to use WSL 2.In addition, it is often better to select WSL 1 even if there is no system performance, such as tablets and old hardware.
Conversely, if you really want to use container software or Linux GUI app (only compatible with Windows 11), you need to choose WSL 2.In the current WSL, the standard version at the time of distribution installation is "2", and if not specified, WSL 2 is selected.This can be changed with the following command.
WSL.EXE --Set-Default-version
Since the standard is "2", if "1" is specified in
Windows 10 May 2020 Update(バージョン2004)から、WSL 2の設定は「WSL.You can now use the "--install" option of the "EXE" command.For this reason, basically, there is no need to use the conventional PowerShell command or [Control Panel] (excluding Windows 10 November 2019 Update Enterprise / Education Edition).The installation is performed with the following command.
First, check the installed WSL distribution name with the following command.You can select a WSL distribution according to your preference and application.
WSL.EXE -L -online
インストール可能なWSLディストリビューション名を調べるコマンドNext, the installation of the WSL distribution is executed at the same time as the WSL installation.If you do not specify a WSL distribution in the "-d" option, "Ubuntu" will be automatically installed.In order to clarify what you installed, it would be better to specify a WSL distribution when installing the WSL.
WSL.EXE-Install [-d
Enter the above command and restart the system when the WSL is installed.After restarting, installation of the specified WSL distribution is started.
The WSL distribution can be searched and installed on the Microsoft Store app on "Linux" or "WSL".
Microsoft StoreからWSLディストリビューションをインストールするMicrosoft Storeアプリを起動し、「Linux」や「WSL」で検索を行うと、WSLディストリビューションが見つかる。ここからインストールしたいものをクリックして、[入手]ボタンをクリックすればよい。The table below shows the WSL distribution available from Microsoft Store.These can be used for free for personal use.Check out the Microsoft Store information page for detailed license conditions.
WSLでの名称 | バージョン | 標準シェル | パッケージ管理 | man | --online | |
---|---|---|---|---|---|---|
Alpine Linux | Alpine | 3.13.4 | /bin/ash | apk | オプション | × |
Debian GNU/Linux | Debian | 11 | /bin/bash | apt/dpkg | オプション | ○ |
Kali Linux | kali-linux | 2021.3 | /bin/bash | apt/dpkg | オプション | ○ |
openSUSE Leap 42 | openSUSE-42 | 15.2 | /bin/bash | zypper,yast/rpm | オプション | ○ |
Ubuntu | Ubuntu | 20.04 | /bin/bash | apt/dpkg | 導入済み | ○ |
Ubuntu 16.04 LTS | Ubuntu-16.04 | 16.04 | /bin/bash | apt/dpkg | 導入済み | ○ |
Ubuntu 18.04 LTS | Ubuntu-18.04 | 18.04 | /bin/bash | apt/dpkg | 導入済み | ○ |
Ubuntu 20.04 LTS | Ubuntu-20.04 | 20.04 | /bin/bash | apt/dpkg | 導入済み | ○ |
Microsoft Storeから入手可能な主なWSLディストリビューション |
When the WSL distribution is installed, you need to specify the Linux user name and password.Please note that there are small differences depending on the WSL distribution (there is no strict definition as Linux, but follow the specifications of the user program adopted by a distribution such as "Adduser").
In general, the characters that can be used for the user name are half-width alphabets (ASCII characters) lowercase and numbers, "_ (under bar)" and "-(hyphen)".The leading user name can be "_ (under bar)", but it cannot be a number or "-(hyphen)".There is no need to match the Windows OS side, and you can decide the username appropriately.
However, the user name (such as root / bin / sys) registered in the initial state cannot be used.The only way to check is to start Linux and check the "/etc/passwd" file.In the initial setting, the user name that cannot be allowed as a WSL distribution will be an error even if specified, so if you get an error, you can change the username and register again.
Also, in the case of the WSL, the login is unnecessary, so the password is only needed in the "SUDO" command to execute the command with administrator privileges.For this reason, there is no need to consider security strongly, and it is easy to hit.Installing the WSL distribution is completed by entering the password twice following the username.
WSLディストリビューション上でユーザー名とパスワードを設定するWSLディストリビューションのインストールが完了すると、ユーザー名とパスワードの設定が求められる。どちらもWindows OSとは異なるものでよい。WSLの場合、ログインは不要なため、パスワードは管理者権限でコマンドを実行するための「sudo」コマンドなどで必要になるだけだ。このため、セキュリティを強く考える必要はなく、打ちやすいものにしておいて構わない。Once the WSL distribution is installed, perform the initial settings.To do so, first select the WSL distribution name in the [Start] menu or run the WSL distribution by executing the following command.
WSL.EXE -D
終了時には、必ずコマンドラインなどから「exit」コマンドを使って抜けるようにすること。WSL自体がLinuxというOSを実行しており、WSLを実行中のコンソールウィンドウを閉じたり、WSL.EXE's "--terminate" or "-Shutdown" options to end the running WSL is because in the Windows OS, it is equivalent to suddenly removing the outlet and turning off the power.
Bash is to do various processes at the time of logout, such as recording the execution history of the command in the file, so it is better to try to finish the WSL after logging out in the correct way from the WSL command line.。Although it can be easily started on the Windows OS, it is necessary to understand that the WSL is an ordinary operating system called Linux.
2. WSL.exeコマンドの概要1|2|3次のページへCopyright © Digital Advantage Corp.All Rights Reserved.