Windows 2022
Sponsored Link

Windows Subsystem for Linux2022/12/27

Enable Windows Subsystem for Linux (WSL) feature to use Linux on Windows Server.
[1] Run PowerShell with Admin Privilege and Configure.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

# enable VirtualMachinePlatform (needed by WSL 2)
PS C:\Users\Administrator> Enable-WindowsOptionalFeature -online -FeatureName VirtualMachinePlatform 
Do you want to restart the computer to complete this operation now?
[Y] Yes  [N] No  [?] Help (default is "Y"): N

Path          :
Online        : True
RestartNeeded : True

# install WSL (for question, answer [Y] to restart computer)
PS C:\Users\Administrator> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux 

Do you want to restart the computer to complete this operation now?
[Y] Yes  [N] No  [?] Help (default is "Y"): Y

Path          :
Online        : True
RestartNeeded : True

PS C:\Users\Administrator> curl.exe -L -o Microsoft.VCLibs.x64.14.00.Desktop.appx 
PS C:\Users\Administrator> Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx 
PS C:\Users\Administrator> wsl --update 
PS C:\Users\Administrator> wsl --status 
Default Version: 2

PS C:\Users\Administrator> wsl -l -o 
The following is a list of valid distributions that can be installed.
Install using 'wsl.exe --install <Distro>'.

NAME               FRIENDLY NAME
Ubuntu             Ubuntu
Debian             Debian GNU/Linux
kali-linux         Kali Linux Rolling
SLES-12            SUSE Linux Enterprise Server v12
SLES-15            SUSE Linux Enterprise Server v15
Ubuntu-18.04       Ubuntu 18.04 LTS
Ubuntu-20.04       Ubuntu 20.04 LTS
OracleLinux_8_5    Oracle Linux 8.5
OracleLinux_7_9    Oracle Linux 7.9

# for example, install Ubuntu 20.04
PS C:\Users\Administrator> wsl --install -d Ubuntu-20.04 
Downloading: Ubuntu 20.04 LTS
Installing: Ubuntu 20.04 LTS
Ubuntu 20.04 LTS has been installed.
Launching Ubuntu 20.04 LTS...

# start another terminal
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit:
Enter new UNIX username: ubuntu     # set default user account (any name you like)
New password:                       # set default user password
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 20.04 LTS (GNU/Linux x86_64)

 * Documentation:
 * Management:
 * Support:

  System information as of Tue Dec 27 02:14:28 PST 2022

  System load:  0.1                 Processes:             9
  Usage of /:   0.1% of 1006.85GB   Users logged in:       0
  Memory usage: 4%                  IPv4 address for eth0:
  Swap usage:   0%

0 updates can be installed immediately.
0 of these updates are security updates.

The list of available updates is more than a week old.
To check for new updates run: sudo apt update

This message is shown once once a day. To disable it please create the
/home/ubuntu/.hushlogin file.

# for Windows resource, it is mounted on [/mnt/c], possible to access
ubuntu@rx-7:~$ df -h 
Filesystem      Size  Used Avail Use% Mounted on
none            3.9G  4.0K  3.9G   1% /mnt/wsl
drivers         120G   21G  100G  18% /usr/lib/wsl/drivers
none            3.9G     0  3.9G   0% /usr/lib/wsl/lib
/dev/sdc       1007G  1.1G  955G   1% /
none            3.9G   72K  3.9G   1% /mnt/wslg
rootfs          3.9G  1.9M  3.9G   1% /init
none            3.9G     0  3.9G   0% /dev
none            3.9G     0  3.9G   0% /run
none            3.9G     0  3.9G   0% /run/lock
none            3.9G     0  3.9G   0% /run/shm
none            3.9G     0  3.9G   0% /run/user
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
none            3.9G   72K  3.9G   1% /mnt/wslg/versions.txt
none            3.9G   72K  3.9G   1% /mnt/wslg/doc
drvfsa          120G   21G  100G  18% /mnt/c
drvfsa           80G  5.4G   75G   7% /mnt/d

# to access Linux resource with root priviledge, use [$ sudo (command)] with a user you added on initial use
ubuntu@rx-7:~$ sudo ls -la /root 
[sudo] password for ubuntu:
total 16
drwx------  2 root root 4096 Apr 22  2020 .
drwxr-xr-x 19 root root 4096 Dec 27 02:14 ..
-rw-r--r--  1 root root 3106 Dec  5  2019 .bashrc
-rw-r--r--  1 root root  161 Dec  5  2019 .profile
Matched Content