avatarM&E Technical Solutions Ltd.

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2387

Abstract

n> LTS OracleLinux_8_5 Oracle Linux <span class="hljs-number">8.5</span> OracleLinux_7_9 Oracle Linux <span class="hljs-number">7.9</span> SUSE-Linux-Enterprise-Server-<span class="hljs-number">15</span>-SP4 SUSE Linux Enterprise Server <span class="hljs-number">15</span> SP4 openSUSE-Leap-<span class="hljs-number">15.4</span> openSUSE Leap <span class="hljs-number">15.4</span> openSUSE-Tumbleweed openSUSE Tumbleweed

<span class="hljs-symbol">C:</span>\LocalFolder></pre></div><p id="1afa">Then, use <i>wsl — install -d <Distro></i> to install your preferred distribution. For example:</p><div id="1191"><pre>wsl <span class="hljs-attr">--install</span> -d Ubuntu wsl <span class="hljs-attr">--install</span> -d openSUSE-Leap-<span class="hljs-number">15.4</span></pre></div><p id="3b76">Depending on different Linux distribution, a installation window will be popped up for initial setup (like Linux user and password).</p><figure id="c03f"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*XX742kgKcverqKu6Hn-EhQ.png"><figcaption></figcaption></figure><p id="52c2">You could install multiple Linux distributions. To find installed distributions, use below command:</p><div id="f9cf"><pre><span class="hljs-symbol">C:</span>\LocalFolder>wsl --list --running Windows Subsystem <span class="hljs-keyword">for</span> Linux Distributions: Ubuntu (<span class="hljs-keyword">Default</span>)

<span class="hljs-symbol">C:</span>\LocalFolder></pre></div><h1 id="3af6">WSL Interactive Mode</h1><p id="d7a6">WSL allows you to explore Linux installation in two modes: Interactive mode and command line mode. To use interactive mode, use below command without any parameters:</p><div id="e350"><pre>wsl</pre></div><figure id="74f5"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*222rFMlkQcquPQeVpoD5TQ.png"><figcaption></figcaption></figure><p id="2591">In interactive mode, the default directory after connect to WSL, is the Linux equivalent directory from where WSL is launched.</p><h1 id="d0df">WSL Command Line Mode</h1><p id="43a4">The command line mode is executed from a DOS or Powershell command Window. It could be also included into DOS BAT/CMD script, or Powershell PS script. Use option <b><i>command</i></b><i> </i>after WSL to run command:</

Options

p><figure id="18f6"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*9FhHX6r5-aVziNlYY25l9w.png"><figcaption></figcaption></figure><h1 id="e18a">File Shares between WSL and Windows Host</h1><p id="66e9">When a Linux distribution is installed, Windows will allocate a directory as file system for the Linux (Note, this is different from how Virtual Machine works on Windows). In the installed Linux, it normally provides mount directories to Windows drivers (C:, D:, etc.). Different Linux distribution might have different directory name and mount directory name. Since we installed Ubuntu from above, the Windows directory to allocate Ubuntu file system is located at <b><i>%LocalAppData%\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState</i></b>.</p><figure id="085a"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*MJy7Bylqozfbulhxu9S7Iw.png"><figcaption></figcaption></figure><p id="39cb">From Ubuntu, you could access Window drives from <i>/mnt.</i></p><figure id="3be6"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*ZmcY1MpbBVUPp1Rt5ZaX-A.png"><figcaption></figcaption></figure><h1 id="5c58">WSL Network</h1><p id="a380">By default, the WSL network is a subnet to host’s network configuration. So, if you don’t do anything, the WSL Linux will just work with the network where the host sits in. For example:</p><figure id="f153"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*7FCLgfYuopyhjEf6_Xgidw.png"><figcaption></figcaption></figure><h1 id="c87a">Further Tips</h1><p id="52de">First of all, WSL is not meant to host heavy application. Instead, use it for convenience reason or local development / test tasks.</p><p id="3c18">If you want to setup automated configurations during WSL startup, take a look <b><i>wsl.conf </i></b>file. It could help you to:</p><ul><li>Automatically mount other network drives</li><li>Setup Network settings from default, and generate <b><i>resolv.conf</i></b> and <b><i>hosts</i></b> file.</li><li>Enable or disable Interop</li></ul><p id="4107">If you need a quick Linux Desktop, you could install xface and xRDP for example. The installation is exactly same as regular Linux environment.</p><p id="70e3">Last, always check <a href="https://learn.microsoft.com/en-us/windows/wsl/">Microsoft official websites</a> for WSL on latest updates.</p></article></body>

Windows WSL Introduction

What is WSL?

WSL stands for Windows Subsystem for Linux. It is a Linux virtual container that enables a Linux distribution, like Ubuntu, Debian, etc. to be installed and integrated with Windows. WSL is introduced since Windows 10 build 1904+. Since then, there is manual options provided for older build as well.

There are two versions of WSL: WSL and WSL2. At time of writing, WSL2 is the default version.

Install WSL

WSL is not installed by default. To install WSL, open a Windows Command Window(or Powershell command window) in administrator mode. To do so, right click on the Window Command Prompt and select “Run as administrator”.

By default, the installation command will install WSL and Ubuntu using below command:

wsl --update
WSL --install

If you want to install different Linux distribution, use below command to check all valid distributions:

C:\LocalFolder>wsl --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl --install -d <Distro>'.

NAME                                   FRIENDLY NAME
Ubuntu                                 Ubuntu
Debian                                 Debian GNU/Linux
kali-linux                             Kali Linux Rolling
Ubuntu-18.04                           Ubuntu 18.04 LTS
Ubuntu-20.04                           Ubuntu 20.04 LTS
Ubuntu-22.04                           Ubuntu 22.04 LTS
OracleLinux_8_5                        Oracle Linux 8.5
OracleLinux_7_9                        Oracle Linux 7.9
SUSE-Linux-Enterprise-Server-15-SP4    SUSE Linux Enterprise Server 15 SP4
openSUSE-Leap-15.4                     openSUSE Leap 15.4
openSUSE-Tumbleweed                    openSUSE Tumbleweed

C:\LocalFolder>

Then, use wsl — install -d <Distro> to install your preferred distribution. For example:

wsl --install -d Ubuntu
wsl --install -d openSUSE-Leap-15.4

Depending on different Linux distribution, a installation window will be popped up for initial setup (like Linux user and password).

You could install multiple Linux distributions. To find installed distributions, use below command:

C:\LocalFolder>wsl --list --running
Windows Subsystem for Linux Distributions:
Ubuntu (Default)

C:\LocalFolder>

WSL Interactive Mode

WSL allows you to explore Linux installation in two modes: Interactive mode and command line mode. To use interactive mode, use below command without any parameters:

wsl

In interactive mode, the default directory after connect to WSL, is the Linux equivalent directory from where WSL is launched.

WSL Command Line Mode

The command line mode is executed from a DOS or Powershell command Window. It could be also included into DOS BAT/CMD script, or Powershell PS script. Use option command after WSL to run command:

File Shares between WSL and Windows Host

When a Linux distribution is installed, Windows will allocate a directory as file system for the Linux (Note, this is different from how Virtual Machine works on Windows). In the installed Linux, it normally provides mount directories to Windows drivers (C:, D:, etc.). Different Linux distribution might have different directory name and mount directory name. Since we installed Ubuntu from above, the Windows directory to allocate Ubuntu file system is located at %LocalAppData%\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState.

From Ubuntu, you could access Window drives from /mnt.

WSL Network

By default, the WSL network is a subnet to host’s network configuration. So, if you don’t do anything, the WSL Linux will just work with the network where the host sits in. For example:

Further Tips

First of all, WSL is not meant to host heavy application. Instead, use it for convenience reason or local development / test tasks.

If you want to setup automated configurations during WSL startup, take a look wsl.conf file. It could help you to:

  • Automatically mount other network drives
  • Setup Network settings from default, and generate resolv.conf and hosts file.
  • Enable or disable Interop

If you need a quick Linux Desktop, you could install xface and xRDP for example. The installation is exactly same as regular Linux environment.

Last, always check Microsoft official websites for WSL on latest updates.

Wsl
Windows
Linux
Recommended from ReadMedium