Windows uses the Linux subsystem to easily install multiple linux

Windows Subsystem for Linux

WSL

WSL for short, is a compatibility layer that can run native Linux binary executable files (ELF format) on Windows 10\11. It is jointly developed by Microsoft and Canonical, and its goal is to enable pure Ubuntu, Debian and other images to be downloaded and decompressed to the user's local computer, and the tools and utilities in the image can run natively on this subsystem. If you use Windows 10 2004 or above, you can run desktop applications in a window through WSL2, and you don't need to install other X servers. This subsystem cannot run all Linux software, but it is absolutely convenient to learn the use of most internal commands!

The difference between WSL1 and WSL2

Explain that 
both WSL1 and WSL2 can bring Linux operating experience in windows;
the startup speed is not slow; the memory consumption is relatively small;
WSL 1 does not use a VM, and WSL 2 uses an automatically maintained VM;
WSL 1 does not support, WSL2 supports running programs such as Docker;
WSL 2 supports complete linux kernel calls, but WSL 1 cannot;
because WSL 2 uses Hyper-V, it is not necessary to run WSL 2 and VMWare or VirtualBox at the same time due to compatibility, and WSL 1 does not exist This problem;
WSL 2 can not operate with Windows cross-operating system files (the way to access WSL2 on Windows is to enter the WSL2 environment, type "cd ~" to enter the main directory, and then type "explorer.exe ." to access WSL in the windows file manager 2 files, in addition, files can be communicated through virtual machines, such as network, file sharing, etc.), while WSL 1 and windows are in the same file system.

Choice
If you fancy the interoperability and interoperability between WSL and windows files, WSL 1 is more suitable;
if you often develop in VM, and the working environment is basically in Linux, then WSL 2 will bring a more perfect experience;
if you Requires kernel features, that can only be WSL 2.

Preparation

Check the Window10\11 version, the version with the internal version number lower than 18362 does not support WSL. The result of running winver: 

Or enter the ver command at the Windows command prompt:

C:\Users\hann>ver

Microsoft Windows [Version 10.0.23511.1000] 

Check if Windows Terminal is in the "Initially Installed" state:

Open Terminal, and press the shortcut key Ctrl , (Ctrl key and comma) to bring up the startup setting interface

Set as shown in the figure below, save and exit: 

Install the Linux subsystem

Open MicrosoftStore, search for Linux, and install your favorite distribution, I installed Ubuntu and Debian.

If you still can't install normally, you can try the following steps:

open subsystem function

Start PowerShell as an administrator and enter the following to enable the Windows Subsystem feature:

dism.exe/online/enable-feature/featurename:Microsoft-Windows-Subsystem-Linux/all/norestart

Then enter the following content to enable the virtual machine platform function:

dism.exe/online/enable-feature/featurename:VirtualMachinePlatform/all/norestart

Once complete, restart your computer.

Download the Linux kernel update package

Click this link to download the WSL2Linux kernel update package for x64 computers.

After the download is complete, install it.

Then run PowerShell as an administrator and enter the following to set WSL2 as the default version:

wsl--set-default-version2

Set Unix username and password

After the installation is successful, enter the user settings:

view help help

Ubuntu's help:

hann@HannYang:~$ help
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.

Debian help:

hann@HannYang:~$ help
GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list. 

The list of internal commands listed by both is basically the same:

 job_spec [&]                                   history [-c] [-d offset] [n] or history -an>
 (( expression ))                               if COMMANDS; then COMMANDS; [ elif COMMANDS>
 . filename [arguments]                         jobs [-lnprs] [jobspec ...] or jobs -x comm>
 :                                              kill [-s sigspec | -n signum | -sigspec] pi>
 [ arg... ]                                     let arg [arg ...]
 [[ expression ]]                               local [option] name[=value] ...
 alias [-p] [name[=value] ... ]                 logout [n]
 bg [job_spec ...]                              mapfile [-d delim] [-n count] [-O origin] [>
 bind [-lpsvPSVX] [-m keymap] [-f filename] [>  popd [-n] [+N | -N]
 break [n]                                      printf [-v var] format [arguments]
 builtin [shell-builtin [arg ...]]              pushd [-n] [+N | -N | dir]
 caller [expr]                                  pwd [-LP]
 case WORD in [PATTERN [| PATTERN]...) COMMAN>  read [-ers] [-a array] [-d delim] [-i text]>
 cd [-L|[-P [-e]] [-@]] [dir]                   readarray [-d delim] [-n count] [-O origin]>
 command [-pVv] command [arg ...]               readonly [-aAf] [name[=value] ...] or reado>
 compgen [-abcdefgjksuv] [-o option] [-A acti>  return [n]
 complete [-abcdefgjksuv] [-pr] [-DEI] [-o op>  select NAME [in WORDS ... ;] do COMMANDS; d>
 compopt [-o|+o option] [-DEI] [name ...]       set [-abefhkmnptuvxBCHP] [-o option-name] [>
 continue [n]                                   shift [n]
 coproc [NAME] command [redirections]           shopt [-pqsu] [-o] [optname ...]
 declare [-aAfFgilnrtux] [-p] [name[=value] .>  source filename [arguments]
 dirs [-clpv] [+N] [-N]                         suspend [-f]
 disown [-h] [-ar] [jobspec ... | pid ...]      test [expr]
 echo [-neE] [arg ...]                          time [-p] pipeline
 enable [-a] [-dnps] [-f filename] [name ...>   times
 eval [arg ...]                                 trap [-lp] [[arg] signal_spec ...]
 exec [-cl] [-a name] [command [arguments ...>  true
 exit [n]                                       type [-afptP] name [name ...]
 export [-fn] [name[=value] ...] or export ->   typeset [-aAfFgilnrtux] [-p] name[=value] .>
 false                                          ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
 fc [-e ename] [-lnr] [first] [last] or fc -s>  umask [-p] [-S] [mode]
 fg [job_spec]                                  unalias [-a] name [name ...]
 for NAME [in WORDS ... ] ; do COMMANDS; don>   unset [-f] [-v] [-n] [name ...]
 for (( exp1; exp2; exp3 )); do COMMANDS; don>  until COMMANDS; do COMMANDS; done
 function name { COMMANDS ; } or name () { CO>  variables - Names and meanings of some shel>
 getopts optstring name [arg]                   wait [-fn] [id ...]
 hash [-lr] [-p pathname] [-dt] [name ...]      while COMMANDS; do COMMANDS; done
 help [-dms] [pattern ...]                      { COMMANDS ; }

daily use

What it looks like after opening: 

Key a few linux commands to try:

At this point, the installation result can be used normally.


exit

Guess you like

Origin blog.csdn.net/boysoft2002/article/details/132034088