Windows and Linux are the most widely used operating systems in the world. Yet the two could not be more different. Windows is a com­mer­cial product from Microsoft, one of the largest software companies in the world. In contrast, Linux, as ‘Free and Open Source Software’ (FOSS), is a joint effort by thousands of vo­lun­teers.

Windows is mainly used in private and business en­vir­on­ments. Linux runs on the servers and computers of pro­fes­sion­als and private in­di­vidu­als. Many de­velopers use Linux. In addition, the open operating system is the basis for the Android mobile operating system.

The Windows Subsystem for Linux (WSL) gives Windows users access to thousands of software packages and open source tools which are available free of charge. Pre­vi­ously, this required setting up a virtual machine or rebooting the computer in a dedicated dual-boot Linux en­vir­on­ment. However, with WSL, all it takes is a few clicks.

What is the Windows Subsystem for Linux?

The Windows Subsystem for Linux is a com­pat­ib­il­ity layer that allows native Linux programs to be executed directly from the Windows command line. Spe­cific­ally, the WSL allows 64-bit Linux binaries to be executed in the standard Ex­ecut­able and Linkable Format (ELF).

The Windows Subsystem for Linux is available starting with Windows 10. But Microsoft’s interest in making it easier for Windows users to work with Linux tools from their familiar desktop en­vir­on­ment goes back further. For example, WSL emerged from the ‘Microsoft Windows Services for UNIX’ (SFU/Interix) project, which in turn was a further de­vel­op­ment of the ‘POSIX subsystem’ already in­teg­rated in Windows NT. With the Windows Subsystem for Linux 2 (WSL2) this de­vel­op­ment continues.

Before the release of WSL, users had to try to combine the best aspects of the Windows and Linux universes. In principle, there were two ways to make Linux programs run under Windows:

  1. Use of a virtual machine. A complete Linux in­stall­a­tion is used as a virtual computer under Windows. The approach is user-friendly and allows the full use of any Linux ap­plic­a­tions, but requires some hardware resources. Fur­ther­more, there is limited in­ter­change­ab­il­ity between running programs on the two operating systems.
  2. Use of the Linux runtime en­vir­on­ment Cygwin. This is installed under Windows and allows the use of many popular Linux programs. The exchange between Windows and Linux programs is possible with Cygwin, but to a limited extent.

Fur­ther­more, users could set up Linux parallel to the existing Windows in­stall­a­tion. However, this setup, known as dual boot, requires re­start­ing the computer to switch to the re­spect­ive operating system. An exchange between running programs from Windows and Linux is therefore not possible with this option.

The Windows Subsystem for Linux does not need a virtual machine and is therefore per­form­ant. However, there is no complete Linux Kernel on board, so not all ap­plic­a­tions are supported. In par­tic­u­lar, the WSL alone does not allow the execution of Linux programs with a graphical user interface (GUI). Ap­proaches exist for this as well, but they require ad­di­tion­al steps for in­stall­a­tion and con­fig­ur­a­tion.

What are the re­quire­ments for using WSL?

You don’t need any special system re­quire­ments to use the Windows Subsystem for Linux. Your computer only needs to have an x64 or ARM processor, which is the case with almost all modern systems. Fur­ther­more, you need a 64-bit Windows 10 version 1709 or later. If you are not sure which Windows edition and version you are using, you can check it with the following steps:

  • Press the Windows logo key + [R], type ‘winver’ in the text box that appears, and press [Enter].
  • Al­tern­at­ively, click Start > Settings > System > About > Windows Spe­cific­a­tion and read the values there.

How do you activate/install Windows Subsystem for Linux?

The process of ac­tiv­at­ing the Windows Subsystem for Linux on your system is simple. We’ll show the process here for home users. Proceed as follows:

  1. Click Start > Control Panel > Programs > Programs and Features > Enable or Disable Windows Features.
  2. Place a check mark next to ‘Windows Subsystem for Linux’.
  3. Restart your computer.
  4. Open the Microsoft Store and search for ‘Linux’. You will be presented with a selection of available Linux dis­tri­bu­tions.
  5. Click the Linux dis­tri­bu­tion you want, and then click Install. If you are not sure which dis­tri­bu­tion is right for you, we recommend in­stalling ‘Ubuntu Linux’.
  6. After the in­stall­a­tion is complete, click on ‘Start’.
  7. In the appearing window, packages are down­loaded and unpacked at the first start. This may take a few minutes. Finally, you will be prompted to set a username and password for the new Linux in­stall­a­tion.
Note

You can run multiple Linux dis­tri­bu­tions in parallel with WSL. In this case, create a separate user account for each dis­tri­bu­tion.

As an al­tern­at­ive to the first two steps, you can also use the following Power­Shell command to enable Windows Subsystem for Linux. Please note that you have to execute the command as ad­min­is­trat­or. After execution, restart your computer and follow our in­struc­tions from step 4.

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

What are the first steps with the Windows Subsystem for Linux?

Which are the first steps after ac­tiv­at­ing the Windows Subsystem for Linux and in­stalling a Linux dis­tri­bu­tion? This depends on the purpose of the WSL. A web developer usually needs a different ap­plic­a­tion profile than an app developer. We’ll summarise a few fre­quently needed first steps here.

Show and control installed WSL

The Windows wsl.exe tool is used on the command line to control the installed Linux dis­tri­bu­tions. Open a command line and enter the following command to display the available options of the wsl command:

wsl --help
Tip

Use the official Windows subsystem for Linux command reference from Microsoft to dig deeper.

Using the Windows Subsystem for Linux to show the Linux dis­tri­bu­tion

You can use the Windows Subsystem for Linux to install and use multiple Linux dis­tri­bu­tions. Run the following command on the command line to get an overview of the installed dis­tri­bu­tions:

wsl --list --verbose

Using the Windows Subsystem for Linux to start the default Linux dis­tri­bu­tion

To start the Linux dis­tri­bu­tion as default, it is enough to execute the wsl command without any other para­met­ers:

wsl

Af­ter­wards, you’ll be logged in as a Linux user and can directly access the known Linux commands.

Using WSL to update the Linux dis­tri­bu­tion

As soon as you have logged into your Linux dis­tri­bu­tion for the first time, update the installed software packages, using the following command:

sudo apt update && sudo apt upgrade

Since this is an operation that has system-wide influence at the Linux level, the command begins with ‘sudo’. You will then have to enter the password set during the in­stall­a­tion of the Linux dis­tri­bu­tion.

Using Windows Subsystem for Linux to install Git

Git is the most widely used tool for ver­sion­ing code projects. To install Git within the Linux dis­tri­bu­tion, use the following command:

sudo apt install git

Using Windows Subsystem for Linux to use Linux tools from Windows

You have already seen how you can log into the Linux dis­tri­bu­tion using the wsl tool and then use Linux commands. Besides that, there is an al­tern­at­ive method. You can run Linux commands directly from the Windows shell. This can be useful, for example, to use Linux commands in Power­Shell scripts. Simply add the Linux command to the call of the wsl tool:

# use Linux-Command `ls` to output contents of the current directory
wsl ls -la

Using Windows Subsystem for Linux to use Windows tools from the Linux command prompt

As you have seen, you can use the WSL Linux command to run scripts directly from the Windows command line or from Power­Shell. This also works the other way around: you can use Windows command line tools at the Linux command prompt or in Linux scripts. The command line tools can be combined like regular Linux commands.

Here we’ll use the Windows tool ipconfig.exe to display network in­form­a­tion in com­bin­a­tion with the Linux tools grep to filter the IPv4 results and cut to remove the column fields:

ipconfig.exe | grep IPv4 | cut -d: -f2

Where to use the Windows Subsystem for Linux

Primarily, the WSL serves to use Linux commands on the command line and in scripts. It can also be used to link Windows and Linux tools. This makes the WSL highly relevant for de­velopers. For web de­vel­op­ment and open source pro­gram­ming in par­tic­u­lar, it’ll be is easier with WSL enabled. With Windows Subsystem for Linux enabled, you can, for example:

  • Install one or more Linux dis­tri­bu­tions from the Microsoft Store.
  • Use popular command line tools such as ‘grep’, ‘sed’ and ‘awk’.
  • Run other ELF-64 binaries.
  • Run scripts for the Bash shell and other shell en­vir­on­ments.
  • Use terminal-based ap­plic­a­tions such as ‘vim’, ‘emacs’, and ‘tmux’.
  • Use pro­gram­ming languages and as­so­ci­ated tools, e.g., NodeJS, Javas­cript, Python, Ruby, C/C++, C# & F#, Rust, Go, etc.
  • Run Linux services on your machine, e.g., SSHD, MySQL, Apache, lighttpd, MongoDB, Post­gr­eSQL etc.
  • Install ad­di­tion­al software using the package manager of your Linux dis­tri­bu­tion.
  • Invoke Windows ap­plic­a­tions using a Unix-like command line.
  • Run Linux ap­plic­a­tions on Windows.
VPS Hosting
VPS hosting at un­beat­able prices on Dell En­ter­prise Servers
  • 1 Gbit/s bandwidth & unlimited traffic
  • Minimum 99.99% uptime & ISO-certified data centres
  • 24/7 premium support with a personal con­sult­ant
Go to Main Menu