How to Install Windows Subsystem for Linux

Windows Subsystem for Linux with new features for Windows 11 and Windows 10

Microsoft previously shipped Windows Subsystem for Linux (WSL) with Windows 10, but with Windows 11 it is also available as a preview via the Store. This version is now officially available, also for Windows 10. WSL offers new interesting features such as the integrated support for graphical desktop apps or the Init-system – systemd.

WSL can be installed from the store, the Cumulative Update November 2022 must be installed in Windows 10 from 21H1, and in Windows 11 KB5020030 or KB5019157 and in Windows Server 2022 KB5020030. WSL from the Store is also available for Windows Server 2022, although the Store app isn’t available here.

The latest WSL release can be downloaded from GitHub.

C:> wsl.exe --install --web-download
Install WSL from the Store

Confirm the Windows Account Control with Yes, now WSL is installed from the store. The prompt to create a Linux user appears. This user can be arbitrary and does not have to match the Windows logon.

After rebooting, the installation continues. The installation ends with information about the version and link notes for documentation and support.

the installation ends with information

WSL can also be obtained from the store.

Store App, Windows Subsystem for Linux

According to Microsoft, the store version will become the standard in the future. This is also reflected in the fact that only this version gets new features, which is also revealed by the fact that the update option is only available here.

C:\> wsl.exe --update

The recently released WSL 1.0 integrates support for WSLg, for graphical desktop applications under Linux into Windows, so that a separate installation of the MSI packages for WSL is no longer necessary, and it is no longer limited to Windows 11, but also available for Windows 10. In addition, there is the possibility to activate systemd.

The installed WSL version with the different WSL components shows the following command.

C:\> wsl --version
wsl --version
WSL-Version: 1.0.0.0
Kernelversion: 5.15.74.2
WSLg-Version: 1.0.47
MSRDC-Version: 1.2.3575
Direct3D-Version: 1.606.4
DXCore-Version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows Version: 10.0.22621.819

Now you can install a Linux distribution, the much used Ubuntu can also be obtained from the store.

Ubuntu is sourced from the store

Alternatively, WSL can be installed completely along with Ubuntu, from a command prompt with Administrator privilege.

C:\> wsl --install -d Ubuntu

After rebooting, the installation continues. You will be asked to enter a username and password to log in Linux. This user can be arbitrary and does not have to match the Windows logon.

To upgrade an existing WSL installation without WSLg to the latest version of WSL that includes WSLg, run the wsl --update command from an elevated command prompt.

  Note that WSLg is only compatible with WSL 2 and does not work for the WSL distribution configured for WSL in mode 1. Make sure the Linux distribution is configured to run in WSL 2 mode, if not, switch to WSL 2.

Windows Subsystem for Linux GUI Apps

WSLg is the abbreviation for Windows Subsystem for Linux GUI. The purpose of the project is to enable support for running Linux GUI applications (X11 and Wayland) on Windows in a fully integrated desktop experience.

Linux Nautilus in Windows 11

WSLg allows Linux GUI applications to fit natively and naturally on Windows. From integration into the Start menu to display in the taskbar, with Alt-Tab functionality, to applying copy and paste in Windows and Linux applications, WSLg enables seamless desktop integration with cross-workflow using Windows and Linux applications.

WSLg requires WSL in version 2 mode, which is what this tutorial does. The currently installed distribution and the configured WSL version can be listed with the following command, in an elevated command prompt.

C:\> wsl --list -v
  NAME          STATE           VERSION
* Ubuntu        Running         2
  kali-linux    Stopped         2

If you are running version 1 mode, switch to version 2 as follows, which may take a while.

C:\> wsl --set-version ubuntu 2

After that, the computer must be restarted.

Now you only need some GUI apps, via the start menu you will find the Ubuntu icon, or you open the Windows Terminal (wt.exe) in which you will also find the entry Ubuntu in the menu. Desired GUI apps can now be obtained from the Linux terminal.

$ sudo apt update
$ sudo apt install nautilus -y
$ sudo apt install gedit -y
$ sudo apt install x11-apps -y
$ sudo apt install vlc -y
$ sudo apt install nemo -y
$ sudo apt install mc -y
$ sudo apt install geary -y

If the browser is selected on Google Chrome, it can be installed with the following lines.

cd /tmp
sudo wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb 
sudo apt install --fix-broken -y
sudo dpkg -i google-chrome-stable_current_amd64.deb

Once these applications are installed, you can find the apps in the Start menu under All apps with the name of the distribution.

the apps in the Start menu under the name of the distribution

The GUI apps can also be launched using the commands in the terminal window.

  • nautilus
  • xclock
  • gedit
  • geary
  • google-chrome
  • nemo
  • mc

GitHub Sources Link: github.com/microsoft/wslg

WSLg, Windows Subsystem for Linux GUI Desktop
Windows Subsystem for Linux GUI Apps

How to Check and Set Linux Runlevels

Runlevel today implemented on systemd, previously most Linux distributions were equipped with the init system, Sys-V style. Sys-V used seven different runlevels to determine which processes can be started on the system. For example, runlevel 3 was usually reserved for the command line and associated programs, while runlevel 5 launched a GUI and all the processes required to do so. Results may vary by distribution.

The vast majority of Linux distributions have adopted systemd as their init system. Some distributions still use Sys-V where the traditional implementation of runlevels still exists. The systemd implementation adopted the concept of runlevels, converting them to systemd “targets”.

On some systems there are still scraps of Sys-V, on which commands such as runlevel can still be found. But some modern systemd distributions have completely eradicated this support. In this tutorial we show how to check the current runlevel on Linux.

How to check current runlevel?

Below are two commands to determine the current runlevel.

$ runlevel
N 5
$ who -r
  run-level 5 2022-11-07 14:52

As you can see, runlevel 5 has started here. Alternatively, the command who -r can be ran. The runlevel command is only available on some systemd distributions, but should work on any sys-V system.

The different runlevels were assigned to corresponding systemd targets.The following command can be used to check the targets.

$ ls -l /lib/systemd/system/runlevel*

Below is the output of the runlevels at a Linux Mint, which is based on Ubuntu/Debian.

$ lrwxrwxrwx 1 root root 15 Aug 31 17:27 /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx 1 root root 13 Aug 31 17:27 /lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx 1 root root 17 Aug 31 17:27 /lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx 1 root root 17 Aug 31 17:27 /lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx 1 root root 17 Aug 31 17:27 /lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx 1 root root 16 Aug 31 17:27 /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx 1 root root 13 Aug 31 17:27 /lib/systemd/system/runlevel6.target -> reboot.target

/lib/systemd/system/runlevel1.target.wants:
Total 0

/lib/systemd/system/runlevel2.target.wants:
Total 0

/lib/systemd/system/runlevel3.target.wants:
Total 0

/lib/systemd/system/runlevel4.target.wants:
Total 0

/lib/systemd/system/runlevel5.target.wants:
Total 0

Runlevels in Linux

0Halt shut down the system
1Single-user mode (Rescue and special administration)
2Multi-user mode not start network interfaces and daemons
3Multi-user mode with Networking starts system normally
4Not Used
5Multi-user mode as runlevel 3 + display manager X11 GUI
6Reboot the system

As with runlevels, there are 7 systemd targets by default. The two main targets are multi-user.target and graphical.target. The following command displays the default systemd targets.

$ systemctl get-default
graphical.target

In this example, graphical.target is started, which makes sense because we need a graphical desktop environment. On a server where often no GUI is running, multi-user.target is usually started.

$ systemctl get-default
multi-user.target

Use the command to see which services are associated with this target.

$ systemctl list-dependencies graphic.target
graphic.target

Try the following command to see which systemd target (or runlevel) a service needs to run.In this example, we check the SSH service.

$ systemctl show -p WantedBy sshd.service
WantedBy=multi-user.target

How to set runlevel?

The runlevel can be set with this command.

$ sudo systemctl set-default multi-user.target

The next time the system boots in multi-user mode (multi-user.target).