How to install the Windows Subsystem for Linux (WSL) in Windows

Overview #

The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a virtual machine.

You can:

  1. Choose your favorite GNU/Linux distributions from the Microsoft Store.
  2. Run common command-line free software such as grep, sed, awk, or other ELF-64 binaries.
  3. Run Bash shell scripts and GNU/Linux command-line applications including:
    • Tools: vim, emacs, tmux
    • Languages: Javascript/node.js, Ruby, Python, C/C++, C# & F#, Rust, Go, etc.
    • Services: sshd, MySQL, Apache, lighttpd
  4. Install additional software using own GNU/Linux distribution package manager.
  5. Invoke Windows applications using a Unix-like command-line shell.
  6. Invoke GNU/Linux applications on Windows.

Installation how-to #

Before installing any Linux distros for WSL, you must ensure that the "Windows Subsystem for Linux" optional feature is enabled:

  1. Open PowerShell as Administrator and run: PowerShell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Restart your computer when prompted.

To download and install your preferred distro(s), you have three choices:

Download and install from the Microsoft Store #

  1. Open the Microsoft Store and choose your favorite Linux distribution. View of Linux distros in the Microsoft Store The following links will open the Microsoft store page for each distribution:
  2. From the distro's page, select "Get" View of Linux distros in the Microsoft store

Now that your Linux distro is installed, you must initialize your new distro instance once, before it can be used.

Download and install from the Command-Line/Script (read the manual installation instructions) #

The basic commands to run in Windows CLI for WSL installation are the following.

#Show a list of available Linux distributions for WSL
wsl --list --online
#Install your preferred Linux distro, e.g. Ubuntu
wsl --install -d Ubuntu
#Access the Windows C drive from the Linux terminal inside WSL
explorer.exe .
cd /mnt/c
#Run apt install or your Linux distro package manager to install and run apps
sudo apt install [appname]
chmod +x 

Download and manually unpack and install (for Windows Server - instructions here) #

Source #

Powered by BetterDocs