Linux subsystem for windows download

WSL is a tool that enables users to run Bash and core Linux command-line tools on Windows. Ain’t that awesome?!

Introduction

WSL has two different versions namely WSL and WSL 2 where the later one has better overall performance and usability.

In this tutorial we aim to install WSL 2 instead of WSL.

Installation

Enable the Windows Subsystem for Linux

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Check system requriements

There are specific system requirements that need to be fulfilled in order to run WSL 2. A detailed description can be found here.

To check your version and build number, select Windows logo key + R, type winver, select OK.

Enable Virtual Machine feature

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Download and run the Linux kernel update package

Download the latest package from WSL2 Linux kernal update package for x64 machines and run it.

Set WSL 2 as your default version

wsl --set-default-version 2

Install Linux distribution

Install your favourite Linux distro from Microsoft Store.

Setting up new distribution

On launching the new Linux distribution, a console window will open and perform some setup operations under the hood for the first time. Subsequent launches should be faster.

Conclusion

Yay!! You’re good to go. Developers can further can setup Visual Studio Code Remote to edit files and develop applications on WSL from Windows.

Reference

  1. Windows Subsystem for Linux Installation Guide for Windows 10

Windows Subsystem for Linux (WSL) — подсистема ОС Windows 10, позволяющая разработчикам, тестировщикам запускать нативные приложения Linux, писать скрипты, выполнять команды непосредственно из Windows. В обновлённой Windows 10 (2004) появилась 2я версия WSL, в которой используется полноценное ядро Linux с возможностью запуска приложений и контейнеров Docker, реализована высокая скорость загрузки, небольшой объем потребляемых ресурсов, управление в фоновом режиме, обновление ядра. Таким образом вы сможете запускать ELF64 программы, которые могут получать доступ к файловой системе Windows без использования сторонних порто (таких как Cygwin).

Образ ядра Linux (версия ядра 4.19) в Windows 10 представляет собой легкую виртуальную машину, для запуска которой не нужно ставить полноценную роль Hyper-V. Системные вызовы Linux транслируются на лету в вызовы Windows без использования эмулятора (в отличии от WSL1).

Изначально компонент WSL отключен. Чтобы его включить, вам необходимо зайти в Пуск -> Панель управления -> Программы и компоненты -> Включение и отключение компонентов Windows (Control Panel\All Control Panel Items\Programs and Features\Turn Windows features on or off), активировать галочку Подсистема Windows для Linux (Windows Subsystem for Linux), нажать кнопку ОК, и перезагрузить компьютер.

установка Windows Subsystem for LInux 2 версия в windows 10

Вы можете включить компоненты WSL в Windows 10 с помощью dism:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

или PowerShell

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

В Windows Server 2004 Semi-Annual Channel (SAC) для установки компонента WSL используется командлет Install-WindowsFeature:

Install-WindowsFeature -Name Microsoft-Windows-Subsystem-Linux

После этого также необходимо перезагрузить компьютер.

В настройка BIOS/UEFI компьютера должна быть включена поддержка аппаратной виртуализации: Intel VT (Intel Virtualization Technology) или AMD-V.

Теперь вам нужно выполнить обновление WSL до версии 2. Для этого требуется зайти на сайт https://docs.microsoft.com/ru-ru/windows/wsl/wsl2-kernel, скачать файл wsl_update_x64.msi, установить его. По завершении увидите картинку

windows subsyste for linux update setup

Чтобы сделать WSL2 архитектурой по умолчанию для новых дистрибутивов, в PowerShell выполните команду:

wsl --set-default-version 2

Далее вам необходимо открыть Microsoft Store, в поиске ввести слово “Linux”. В появившемся списке выберите нужный дистрибутив. Доступные Ubuntu, Debian, Kali Linux, Linux Cheatsheet, SUSE Linux Enterprise Server15, openSUSE Leap 15-1, Pengwin Enterprise, Fedora Remix for WSL или другие. В нашем примере мы будем использовать Ubuntu 20.04 LTS, нажмите кнопку Получить.

образы linux для wsl в microsoft store

Если у вас отключен Windows Store или вы хотите установить дистрибутив WSL в Core редакции Windows Server, вы можете скачать дистрибутив Ubuntu с помощью PowerShell командлета Invoke-WebRequest:

Invoke-WebRequest https://aka.ms/wslubuntu2004 -OutFile ubuntu-2004.zip –UseBasicParsing

Распакуйте архив:

Expand-Archive -Path .\ubuntu-2004.zip

Запустите установку образа Linux с помощью файла Ubuntu.exe.

Также вы можете скачать образ в виде appx файла и установить его с помощью командлета Add-AppxPackage.

После установки можно проверить используемую версию WSL с помощью команды

wsl --list –-verbose

wsl --list –-verbose список доступных образов linux

Если у вашей среды Linux указана версия 1, нужно изменить ее на WSL2 командой:

wsl --set-version Ubuntu-20.04 2

Файл жёсткого диска с образом виртуальной машины ОС Linux Ubuntu 20.04 будет располагаться в профиле пользователя: C:\Users\234\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState.

После установки дистрибутива в стартовом меню появляется ярлык на него. Для запуска Ubuntu зайдите в меню Пуск, нажмите на соответствующем ярлыке и получите в отдельном окне полноценную командную оболочку Bash. Запускать WSL можно и с помощью команды wsl. При первом запуске образа в командной строке Bash вам будет предложено создать пользователя и пароль (которые не должны совпадать с учётной записью Windows). Чтобы выполнять команды с правами root, необходимо использовать дополнительный ключ (префикс) sudo. В WSL есть общие команды для Bash и CMD, и тут нужно не забывать, что система Linux чувствительна к регистру.

Вы можете выполнить Linux-команды из CMD. Для этого необходимо вначале указать “WSL”. Например, для просмотра списка файлов и папок в каталоге Windows, выполните:

wsl
ls /mnt
ls/mnt/c

запуск команд linux в windows
dir | wsl grep Sa
wsl ls ‑la > 123.txt
wsl ls ‑la /proc/cpuinfo
wsl ls ‑la “/mnt/c/Program Files”

команды linux

Также вы можете открыть проводник командой explorer.exe, калькулятор – calc.exe, блокнот – notepad.exe, paint – mspaint.exe, календарь – cal, погоду – curl wttr.in

запуск команд linux в windows 10 subsystem for linux

Ещё один пример взаимосвязи 2х систем – вы можете открыть в Windows файл из WSL-дистрибутива по сетевому пути. Для этого в CMD наберите путь к файлу:

notepad \\wsl$\Ubuntu-20.04\home\1122.txt

Из окна консоли вы можете обновить список пакетов в Ubuntu с помощью команд:

sudo apt-get update
sudo apt-get upgrade

После обновления Ubuntu папка …/LocalState будет занимать 1.5 Гб.

Из командной строки Linux можно не только просмотреть Windows-файлы и каталоги, но и получить к ним доступ. Чтобы удобнее копировать файлы, просматривать директории и их содержимое, установите файловый менеджер Midnight Commander с помощью команды

sudo apt-get install mc

Вы можете запустить Midnight Commander как в командной оболочке Bash, так и внутри CMD. На скриншоте ниже показано, что в двух панелях MC показывается список файлов с обеих ОС.

Midnight Commander в windows 10 wsl2

Можно отобрахить сетевые настройки (IP адрес) IP-адрес Linux-системы:

ip addr | grep eth0

запуск команд linux из windows

В WSL не предусмотрена работа приложений с графическим интерфейсом. Тем не менее вы можете попробовать их установить и использовать. Чтобы запускать графические приложения в Linux, нужно скачать и установить в Windows программу VcXsrv Windows X Server (https://sourceforge.net/projects/vcxsrv/).

VcXsrv Windows X Server

С помощью пакетного менеджера apt-get установим несколько графических программ: например, браузер, текстовый редактор или что-то ещё:

sudo apt-get install gedit
sudo apt-get install firefox
sudo apt-get install x11-app

Затем создайте файл в директории root:

cd /~
vim .bash_login

впишите строку

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0

сохраните запись

Esc -> :wr -> :q

Теперь можете запустить графические программы Linux через WSL командами:

firefox

или

gedit

запуск браузера firefox через WSL 2 в Windows 10

запуск графического редактора gedit в WSL

Вы можете установить в Windows 10 несколько дистрибутивов Linux и запускать одновременно в разных окнах WSL. Вывести весь перечень установленных дистрибутивов можете с помощью команды:

wsl --list –all

чтобы завершить работу всех запущенных дистрибутивов и ядра WSL 2, выполните команду:

wsl --shutdown

2.0.4

  • Resolve potential crash in wslservice.exe
  • Implement /usr/bin/wslinfo binary for querying various state, added --networking-mode argument
wslinfo usage:
    --networking-mode
        Display current networking mode.

    -n
        Do not print a newline.

2.0.3

  • Fix issue when upgrading from 2.0.1 (solves #10560)
  • Continue if unable to reclaim memory. (solves #10534)

2.0.2

  • Create a specialized error code when WSL is called from LocalSystem
  • Fix same version installs and downgrade (solves #10527)
  • Fix upgrade issue caused by setting REINSTALLMODE (solves #10539)
  • Fix race condition causing WslInstaller crash

2.0.1

  • Mount cgroupv2 at /sys/fs/cgroup if cgroupv1 is disabled (solves #10497)
  • Conditionally write the explorer extensions registry keys (solves #9231)
  • Don’t try to inherit the same handle twice (solves #10488)
  • Fix parsing of ‘0GB’ memory strings (solves #10503)
  • Update WSLg to 1.0.58

2.0.0

  • Added support for new opt-in experimental features to %USERPROFILE%\.wslconfig. For full info see the WSL docs update: https://aka.ms/wslsep2023updatedocspage
    • experimental.autoMemoryReclaim — Makes the WSL VM shrink in memory as you use it by reclaiming cached memory
    • experimental.networkingMode — A new networking mode for WSL that adds new features and improves network compatibility
    • experimental.dnsTunneling- Changes how WSL resolves DNS requests to improve network compatibility
    • experimental.firewall- Applies Windows firewall rules to WSL, and allows for advanced firewall controls for the WSL VM
    • experimental.autoProxy- Makes WSL automatically use the proxy information from Windows to improve network compatibility
[experimental]
autoMemoryReclaim=gradual | dropcache | disabled
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true
  • Store WSL is now accessible from Session 0 (solves #9231)
  • All binaries shipped in the WSL package are now signed
  • Introduce experimental.autoMemoryReclaim setting to %USERPROFILE%\.wslconfig
  • Prompt the user to enable VMP if HNS isn’t available on the machine
  • Fix localhost relay failing if ipv6 is disabled
  • Improve error message for WSL1 disabled policy to provide upgrade instructions
  • Fix microk8s scenario for mirrored networking
  • Create shared mounts when init sets up the distro namespace (solves #10410)
  • Detach user block devices before terminating the VM
  • Protect ‘.wslconfig’ from being incorrectly translated
  • Add logic to generate a systemd unit to protect the binfmt interpreter (solves #8843)
  • Fix potential wslservice.exe crash.
  • Retry plan9 mounts on IO error
  • Update Microsoft.WSL.Kernel version 5.15.123.1-1
  • Display a notification prompting the user to install missing optional components
  • Add --manage <distro_name> --set-sparse to wsl.exe
  • Fix various issues with the ‘Update available’ notification logic
  • Update WSLg to 1.0.57
    • WSL GUI apps now have Windows snapping with the keyboard (Press WIN + an arrow key to snap to the side)
  • Update MSRDC to 1.2.4485

1.3.17

  • Update MSRDC to version 1.2.4485
  • Update WSLg to 1.0.57

1.3.15

  • Update Microsoft.WSL.Kernel to version 5.15.90.4-1

1.3.14

  • Update Microsoft.WSL.Kernel to version 5.15.90.3-1
  • Update MSRDC to 1.2.4419
  • Update Microsoft.WSLg to version 1.0.55
  • Fix /run/user/ being hidden when a new login session is created by symli… (solves #10205)
  • Implement a —no-distribution option in wsl —install

1.3.11

  • Switch back to previous version of lxutil.dll while an issue is being debugged

1.3.10

  • Mount /usr/lib/wsl/lib as rw
  • Set a timeout when force terminating instances
  • Allow created vhdx to have sparse flag set
  • Make /run/user/{user} writable
  • Memory reclamation idle detection, drop_caches. To use add the below to %userprofile%\.wslconfig
[experimental]
autoMemoryReclaim=true
  • Fix COM race condition when service is stopped
  • Install missing optional components if needed in wsl.exe --install
  • Fix potential wslservice crash in .wslconfig parsing
  • Use —numeric-owner when importing and exporting distros so the root namespace /etc/passwd is not used (solves #9982)
  • Update invalid wslconfig key warning to call out which key has the invalid value
  • Change localhost relay creation to be non-fatal (solves #9924)
  • Fix behavior of guiApplications=false in .wslconfig
  • Fix intermittent localhost forwarding issues (Solves #9921)
  • Use /mnt/wslg for /run/user (solves #9913)
  • Update Microsoft.WSL.Kernel to version 5.15.90.2-3
    • This new kernel includes a SCSI fix that allows WSL to boot faster
  • Update Microsoft.WSLg to version 1.0.54
  • Update MSRDC to 1.2.4240
  • Update Microsoft.DXCore.Linux to version 10.0.25880.1000-230602-1350.main

Install a complete Ubuntu terminal environment in minutes on Windows with Windows Subsystem for Linux (WSL).

Access the Linux terminal on Windows, develop cross-platform applications, and manage IT infrastructure without leaving Windows.

Download from the Microsoft Store

Install Ubuntu on WSL ›

Deploying WSL at your company?

We help companies achieve a seamless integration with their WSL deployments. Contact us to learn more about how we support enterprises on the Windows Subsystem for Linux.

Contact us

What you never thought was possible on Windows

  • Editors

    Run your choice of Linux text editors, including vim, emacs, and nano

  • Servers

    Spin up Node.js, install your dependencies with npm, and start testing your web app

  • Development

    Install compilers and libraries from the Ubuntu repository, maintained by Canonical

  • Systemd

    Develop and run service applications and use snap packages to run popular workflow tools

  • Containers

    Work with LXD and Docker containers on Windows

  • Scripting

    Automate Linux and Windows tasks with advanced bash scripting

  • Network hardening

    Leverage Linux security tools to test and harden your network

  • Data

    Crunch big numbers with tools for R and Python

  • Kubernetes

    Build, test, and deploy Kubernetes clusters on Windows

Why Ubuntu WSL?

Develop Graphical Applications

Develop and preview web and graphical applications on Linux using WSLg. Create multiplatform graphical applications using popular open source development frameworks like Flutter or React Native.

Learn how to run graphical apps with Ubuntu on WSL ›

Enterprise support

Ubuntu is certified on WSL through close collaboration with Microsoft. Enterprise support is provided for Ubuntu from Azure to Windows workstations creating a seamless operating environment.

Get in touch

Video Guides

An introduction to numerical computation applications using Ubuntu WSL

Tips for working with web services on Ubuntu WSL

Ubuntu on WSL: An FAQ for data scientists and developers

WSL: Partnering with Canonical to support systemd

Ubuntu Summit 2022 | The Windows Subsystem for Linux WSL Latest updates and future improvements

Latest Ubuntu WSL news from

our blog ›

Windows Subsystem for Linux (WSL) is a Windows feature that allows developers or testers to run native Linux apps, write scripts, and run bash commands directly from Windows. Starting with Windows 10 (2004) WSL 2 is available which uses a full-featured Linux kernel. It allows running apps or Docker containers, has a high load speed, consumes fewer resources, and supports background management, and kernel updates. Thus, you can run ELF64 apps able to access the Windows file system without using third-party ports (like Cygwin).

A Linux kernel (v4.19) image in Windows 10 is a lightweight virtual machine. To run it, you don’t need to install a full Hyper-V role. Linux system calls are translated into Windows calls on the fly without using any emulator (unlike WSL1).

By default, WSL is disabled. To enable it, open Start -> Control Panel -> All Control Panel Items -> Programs and Features -> Turn Windows features on or off, check Windows Subsystem for Linux, click OK, and restart your computer.

enable Windows Subsystem for Linux

You can enable WSL feature on Windows 10/11 using DISM:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

or PowerShell:

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

To install WSL in Windows Server 2022 or 2004+ Semi-Annual Channel (SAC), use the Install-WindowsFeature cmdlet:

Install-WindowsFeature -Name Microsoft-Windows-Subsystem-Linux

Then you need to restart your computer.

Intel VT (Intel Virtualization Technology) or AMD-V support must be enabled in the BIOS/UEFI settings of your computer.

Then update WSL to version 2. To do it, go to https://docs.microsoft.com/windows/wsl/wsl2-kernel, download wsl_update_x64.msi, and install it.

Install Windows Subsystem for Linux on Windows 10 and 11

To make WSL2 a default architecture for new Linux distros, run the following command:

wsl --set-default-version 2

Then open Microsoft Store and enter “Linux” in the search bar. Select the distro you need from the list. Ubuntu, Debian, Kali Linux, SUSE Linux Enterprise Server15, openSUSE Leap 15-1, Fedora Remix for WSL, and others are available. In our example, we will use Ubuntu 20.04 LTS. Then click Get.

Install WSL image from Microsoft Store

If you have Microsoft Store disabled or you want to install a WSL on the Windows Server Core edition, you can download an Ubuntu WSL image using the Invoke-WebRequest PowerShell cmdlet:

Invoke-WebRequest https://aka.ms/wslubuntu2004 -OutFile ubuntu-2004.zip –UseBasicParsing

Extract the archive with PowerShell:

Expand-Archive -Path .\ubuntu-2004.zip

Run the installation of the Linux image using the Ubuntu.exe file.

You can also download the image as an appx file and install it using Add-AppxPackage cmdlet.

After the installation, you can view the installed WSL version using this command:

wsl --list –-verbose

wsl get version

If your Linux environment has version 1, you need to change it to WSL2:

wsl --set-version Ubuntu-20.04 2

A virtual hard disk file with the OS Linux Ubuntu 20.04 is located in the user profile: C:\Users\username\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState.

After the distribution has been installed, its icon appears in the Start menu. To start Ubuntu, open the Start menu, click its icon and the Bash shell will open. You can also start WSL using the wsl command. The first time you run the image, you will be prompted to create a user and password. To run commands as root, use an additional key (prefix): sudo. WSL has common commands for Bash and CMD, and you should remember that Linux is case-sensitive.

You can run Linux commands in CMD. To do it, you must first specify WSL. For example, to view the list of files and folders in your Windows directory, run the following commands:

wsl
ls /mnt
ls/mnt/c

access windows file system from wsl

wsl ls ‑la /proc/cpuinfo
wsl ls ‑la “/mnt/c/Program Files”

run bash commands in wsl

You can also open Windows Explorer using explorer.exe, Calculator (calc.exe), Notepad (notepad.exe), Paint (mspaint.exe), Calendar (cal), and Weather (curl wttr.in).

run apps in WSL2

Another useful feature: you can open a WSL file from Windows using its system path. To do it, enter the file path in CMD:

notepad \\wsl$\Ubuntu-20.04\home\1122.txt

You can update the list of Ubuntu packages from the console using the following commands:

sudo apt-get update
sudo apt-get upgrade

After the update, the …/LocalState folder will take up 1.5 GB.

From the Linux command prompt, you can view Windows files and folders, and access them. To make it more convenient to copy files, view directories and their contents, install Midnight Commander using the following command:

sudo apt-get install mc

You can run Midnight Commander both in Bash and in CMD. The screenshot below shows that both MC panels display the list of files from both OSs.

Midnight Commander on WSL

You can display network settings (an IP address) of your WSL subsystem:

ip addr | grep eth0

Apps with graphic interfaces don’t work in WSL. However, you can try to install and use them. To run graphic apps in Linux, download and install VcXsrv Windows X Server (https://sourceforge.net/projects/vcxsrv/) on Windows.

install VcXsrv Windows X Server

Use the apt-get package manager to install graphic apps. For example, a browser, a text editor, or anything else:

sudo apt-get install gedit
sudo apt-get install firefox
sudo apt-get install x11-app

Then create a file in the root directory:

cd /~
vim .bash_login

Add the following line:

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0

and save the file:

Esc -> :wr -> :q

Then you can run graphic Linux apps in WSL using the commands:

firefox

or

gedit

You can install multiple Linux distros on Windows 10/11 and run them simultaneously in different WSL spaces. You can display the list of all installed WSL distros in Windows with the command:

wsl --list –all

To stop all running Linux distributions and the WSL2 kernel, run the following command:

wsl --shutdown

  • Linux shell for windows 10
  • Linux встроенный в windows 10
  • Linux включить в домен windows
  • Linux server на windows виртуализация
  • Linux scp from linux to windows