Windows Subsystem for Linux ( wsl2 )

Windows Subsystem for Linux ( wsl2 )

 

Installing wsl2


Open Powershell as an Administrator account

Show all options

    wsl --help

Verify that wsl Default Version is 2


    wsl --status

Show all Linux distributions available for installation

    wsl --list --online

This will report something like this:

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_7_9 Oracle Linux 7.9 OracleLinux_8_7 Oracle Linux 8.7 OracleLinux_9_1 Oracle Linux 9.1

 

Change default linux install

# Oracle Linux is recommended because its the most similar to the Linux we use on our servers
# the default install of Linux under wsl is Ubuntu, if you want to change the default use this command:

    wsl --set-default OracleLinux_9_1

Install Oracle Linux 9.1

   wsl --install --distribution OracleLinux_9_1


When the install is complete, it will ask for a password. An account may not be necessary for the windows administrator account


Using wsl2

From a standard user account start the Oracle Linux app

Setting account and password

 

When starting the shell for first time you'll be asked to supply an account and password. This appears to primarily be used to get sudo privledges to do things like install additional pacakges.

 

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: https://aka.ms/wslusers Enter new UNIX username: user Changing password for user New password: Retype new password: passwd: all authentication tokens updated successfully. Installation successful!

 

Within the Oracle Linux 8.7 shell do the following:

confirm installed version

 

cat /etc/os-release NAME="Oracle Linux Server" VERSION="8.7" ID="ol" ID_LIKE="fedora" VARIANT="Server" VARIANT_ID="server" VERSION_ID="8.7" PLATFORM_ID="platform:el8" PRETTY_NAME="Oracle Linux Server 8.7" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:oracle:linux:8:7:server" HOME_URL="https://linux.oracle.com/" BUG_REPORT_URL="https://bugzilla.oracle.com/" ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8" ORACLE_BUGZILLA_PRODUCT_VERSION=8.7 ORACLE_SUPPORT_PRODUCT="Oracle Linux" ORACLE_SUPPORT_PRODUCT_VERSION=8.7

 

Update packages to latest version

sudo dnf clean all sudo dnf list updates sudo dnf update

# after updating, look at os-release again, it should report 8.7 or higher


Using wsl2

 

You should be able to search for and run "Oracle Linux 8.7"

It will present a bash shell for you to use.

 

To have admin privileges and install additional packages you'll need to have root access within the wsl shell.

Type "sudo -i" and it will ask you to set a password. This password will be needed any time you need admin privledges.

Adding additional package repositories

 

# the following will give your installation access to additional packages

sudo dnf install oracle-epel-release-el9

sudo dnf config-manager --enable ol9_codeready_builder

 

Installing rsync

rsync is a very useful utility for transferring files.

sudo dnf install rsync


C: drive on windows will appear as /mnt/c under wsl

 

 

 

 

Supporting X11 applications

 

X11 is the primary api used to display graphic applications for linux and unix. Windows does not support this by default, but WSL can do this.

Additional packages will need to be installed:

dnf install  xterm xorg-x11-fonts-ISO8859* glx-utils

 

Running X11 applications remotely


# within the wsl bash shell, ssh to a server with X11 tunnelling enabled

ssh -X compile.vcu.edu

# from within this server shell run xterm to verify that X11 support is working

xterm

You should be able to run any graphical linux application remotely now

X11 is usually very slow when used from off campus networks.

 

 

Troubleshooting Issues

 

When trying to install a package with dnf, I got this error:

 

    RPM: error: db5 error(-30969) from dbenv->open: BDB0091 DB_VERSION_MISMATCH: Database environment version mismatch

 

It was fixed by doing the following:

    sudo  rm /var/lib/rpm/.rpm.lock

or

    sudo  rpm --rebuilddb

followed by 

    rpm -qa

to rebuild the rpm databases

 

 

References

https://learn.microsoft.com/en-us/windows/wsl/setup/environment

 

https://learn.microsoft.com/en-us/windows/wsl/basic-commands#install

 

https://www.how2shout.com/how-to/how-to-install-oracle-linux-on-windows-10-or-11-wsl-subsystem.html

 

https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps