What is the Windows Subsystem for Linux?
The Windows Subsystem for Linux (WSL) is a feature in Windows that allows users to run a Linux environment directly on Windows, without the need for a virtual machine.
WSL utilizes the Linux kernel, allowing Linux binaries to run natively on Windows. This provides full Linux compatibility with faster performance compared to traditional virtualization.
Some key highlights of WSL:
- Directly runs GNU/Linux environments on Windows
- Provides Linux kernel compatibility layer
- Allow running Linux command-line tools and applications
- Integrates with Windows File Explorer
- Supports Linux distros like Ubuntu, SUSE, etc.
Overall, WSL brings the power and flexibility of Linux to Windows users. It enables using Linux tools and apps without leaving the Windows environment.
Installing WSL
To use WSL, you need to be running Windows 10 version 2004 and higher or Windows 11. WSL is not supported on earlier Windows versions.
The steps to install WSL are:
-
Enable the optional Windows subsystem for Linux feature:
- Open PowerShell as Administrator and run:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
- Open PowerShell as Administrator and run:
-
Check requirements for running WSL:
- For x64 systems: Version 1903 or higher with Build 18362 or higher
- For ARM64 systems: Version 2004 or higher with Build 19041 or higher
-
Install your Linux distribution of choice from the Microsoft Store. Some options are:
- Ubuntu
- Debian
- Kali Linux
- SUSE Linux Enterprise Server
-
Set the distro as your default WSL distribution.
- Open PowerShell and enter:
wsl --set-default-version <distro name>
- Open PowerShell and enter:
-
Restart your machine when prompted.
That’s it! The Linux distro will be installed and ready to use through the Windows Subsystem for Linux.
Using WSL
Once installed, you can launch a Linux terminal on Windows by running the distro name from the Start menu. For example, Ubuntu
.
This will open a Bash shell for your WSL distro. You can now run Linux commands just like on a Linux OS:
user@hostname:~$ ls
user@hostname:~$ cd /home
user@hostname:/home$ pwd
/home
user@hostname:/home$ sudo apt update
You can install additional Linux software using the native package managers like apt
or yum
.
Some ways you can use WSL:
- Run Linux-based development environments like Node.js, Python, Ruby etc.
- Manage Linux-based web servers like Apache or Nginx.
- Use the Linux terminal and shell commands on Windows.
- Automation and scripting using Bash, Perl, sed, awk etc.
Key benefits:
- Usage of native Linux tools, apps, and terminal.
- Fully integrated with Windows – access Windows files/drives from within WSL.
- Improved Linux performance compared to virtual machines.
- Quick installation and setup.
WSL Tips and Tricks
Here are some tips to help use WSL more effectively:
- Access Windows drives like
C:
in WSL using/mnt/c
- Transfer files between Windows and WSL using
/mnt
path - Launch Windows apps from Linux terminal using
explorer.exe
- Modify Linux distro resources and capabilities in
/etc/wsl.conf
- Change between distro versions using
wsl --list
andwsl --set-version
- Set a distro as default with
wsl --set-default <distro>
- WSL grants access to all hardware resources – use them just like a VM.
Overall, WSL opens up Linux functionality directly within Windows. With simplified setup and better integration, it provides an efficient way to use Linux tools and software on Windows machines.