And I just got myself a new laptop with Windows 11 Home Edition. Enabling WSL on Windows 10 will be done a bit differently.
This layer also provides an environment that includes the Linux kernel, command-line tools and software packages enabling you to run Linux utilities on Windows.
Think of it similarly to Oracle VM Virtualbox. This something I'm use to particularly which allows me to setup a sandbox environment.
To start, open PowerShell as an administrator (you can do this by right clicking the PowerShell and selecting "Run as Administrator"), and enter the command wsl --install.
PS C:\Users\shahmatd> wsl --install
And you will be prompted to restart your machine. After restart, set the default WSL to version 2.
PS C:\Users\shahmatd> wsl --set-default-version 2
For this instance, I will setup the latest fedora version 37. Fedora 37 or any version isn't readily made available on WSL. How do I know this? The following command lists the linux distribution that are made readily available on WSL.
PS C:\Windows\system32> wsl --list -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
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
Fire up a web browser and open the following link. Pick the x86_64 architecture, download the respective .tar.xz. Extract using 7zip. Extract the downloaded .tar.xz and you will get another tar file, which you will need to extract a file called layer.tar.
From the PowerShell prompt, create a directory under the home directory of the account you're currently logged on as:
PS C:\Users\shahmatd> mkdir $HOME\wsl\fedora
Import the layer.tar file using the wsl command line by running:
PS C:\Users\shahmatd> wsl --import fedora $HOME\wsl\fedora 'C:\Users\shahmatd\Downloads\New folder\65462375a5e75e333a8988a5c08ede73131b0ce6eef5f249c5893d1d41394ed7\layer.tar'
Import in progress, this may take a few minutes.
The operation completed successfully.
Once import is successful, list the installed distribution as follows:
PS C:\Users\shahmatd> wsl --list -v
NAME STATE VERSION
* fedora Stopped 2
To start the fedora distribution, run:
PS C:\Users\shahmatd> wsl -d fedora
[root@Marsupalami85 ~]#
Press Ctrl+D to exit to the PowerShell prompt
To confirm the fedora distribution has started properly
PS C:\Windows\system32> wsl --list -v
NAME STATE VERSION
* fedora Running 2
Post Installation Steps
Launch the recently installed fedora installation.
Try updating the fedora OS with the latest packages. You will notice that you will be logged as root as denoted by the shell prompt:
[root@Marsupalami85 ~]# dnf update
Fedora 37 - x86_64 3.4 MB/s | 82 MB 00:23
Fedora 37 openh264 (From Cisco) - x86_64 993 B/s | 2.5 kB 00:02
Fedora Modular 37 - x86_64 1.6 MB/s | 3.8 MB 00:02
Fedora 37 - x86_64 - Updates 3.1 MB/s | 28 MB 00:09
Fedora Modular 37 - x86_64 - Updates 645 kB/s | 2.9 MB 00:04
Dependencies resolved.
Nothing to do.
Complete!
The next thing to do would be to create a non-privilege user, but before you can do that install the following packages:
[root@Marsupalami85 ~]# dnf install -y util-linux passwd cracklib-dicts
Last metadata expiration check: 0:03:46 ago on Mon Apr 17 23:10:17 2023.
Dependencies resolved.
========================================================================================================================
Package Architecture Version Repository Size
========================================================================================================================
Installing:
cracklib-dicts x86_64 2.9.7-30.fc37 fedora 3.6 M
passwd x86_64 0.80-13.fc37 fedora 121 k
util-linux x86_64 2.38.1-1.fc37 fedora 2.3 M
Installing dependencies:
libfdisk x86_64 2.38.1-1.fc37 fedora 160 k
libuser x86_64 0.63-13.fc37 fedora 399 k
libutempter x86_64 1.2.1-7.fc37 fedora 26 k
Transaction Summary
========================================================================================================================
Install 6 Packages
Total download size: 6.7 M
Installed size: 23 M
Downloading Packages:
(1/6): libfdisk-2.38.1-1.fc37.x86_64.rpm 150 kB/s | 160 kB 00:01
(2/6): libutempter-1.2.1-7.fc37.x86_64.rpm 157 kB/s | 26 kB 00:00
(3/6): passwd-0.80-13.fc37.x86_64.rpm 577 kB/s | 121 kB 00:00
(4/6): libuser-0.63-13.fc37.x86_64.rpm 274 kB/s | 399 kB 00:01
(5/6): cracklib-dicts-2.9.7-30.fc37.x86_64.rpm 1.5 MB/s | 3.6 MB 00:02
(6/6): util-linux-2.38.1-1.fc37.x86_64.rpm 1.3 MB/s | 2.3 MB 00:01
------------------------------------------------------------------------------------------------------------------------
Total 1.5 MB/s | 6.7 MB 00:04
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: libutempter-1.2.1-7.fc37.x86_64 1/6
Installing : libutempter-1.2.1-7.fc37.x86_64 1/6
Installing : libuser-0.63-13.fc37.x86_64 2/6
Installing : libfdisk-2.38.1-1.fc37.x86_64 3/6
Installing : util-linux-2.38.1-1.fc37.x86_64 4/6
warning: /etc/adjtime created as /etc/adjtime.rpmnew
Installing : passwd-0.80-13.fc37.x86_64 5/6
Installing : cracklib-dicts-2.9.7-30.fc37.x86_64 6/6
Running scriptlet: cracklib-dicts-2.9.7-30.fc37.x86_64 6/6
/usr/sbin/ldconfig: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link
Verifying : cracklib-dicts-2.9.7-30.fc37.x86_64 1/6
Verifying : libfdisk-2.38.1-1.fc37.x86_64 2/6
Verifying : libuser-0.63-13.fc37.x86_64 3/6
Verifying : libutempter-1.2.1-7.fc37.x86_64 4/6
Verifying : passwd-0.80-13.fc37.x86_64 5/6
Verifying : util-linux-2.38.1-1.fc37.x86_64 6/6
Installed:
cracklib-dicts-2.9.7-30.fc37.x86_64 libfdisk-2.38.1-1.fc37.x86_64 libuser-0.63-13.fc37.x86_64
libutempter-1.2.1-7.fc37.x86_64 passwd-0.80-13.fc37.x86_64 util-linux-2.38.1-1.fc37.x86_64
Complete!
Once those packages has been installed create your first user account. In this case, let's call it shahmatd. Set an appropriate password for the newly created user account and assign a secondary group called 'wheel' to it.
[root@Marsupalami85 ~]# useradd shahmatd
[root@Marsupalami85 ~]# passwd shahmatd
Changing password for user shahmatd.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@Marsupalami85 system32]# usermod -G wheel shahmatd
Log yourself out and back in but instead of logging on as root, log on as the non-privileged user you had just created.
PS C:\Windows\system32> wsl -d fedora -u shahmatd
[shahmatd@Marsupalami85 ~]$
To make logging on via WSL as the user shahmatd as the default behavior:
[shahmatd@Marsupalami85 ~]# printf "\n[user]\ndefault = username\n" | sudo tee -a /etc/wsl.conf
Once this is done, log out and log yourself back in but this time, you won't be supplying the username you'll be logging on as, only issue:
PS C:\Windows\system32> wsl -d fedora
[shahmatd@Marsupalami85 system32]$
Next, we will revisit this fedora distribution, and enabled systemd, and ssh server.