Manual installation steps for older versions of WSL
For simplicity, we generally recommend using the wsl --install to install Windows Subsystem for Linux, but if you’re running an older build of Windows, that may not be supported. We have included the manual installation steps below. If you run into an issue during the install process, check the installation section of the troubleshooting guide.
Step 1 – Enable the Windows Subsystem for Linux
You must first enable the “Windows Subsystem for Linux” optional feature before installing any Linux distributions on Windows.
online featurename:MicrosoftWindowsSubsystemLinux all norestart
We recommend now moving on to step #2, updating to WSL 2, but if you wish to only install WSL 1, you can now restart your machine and move on to Step 6 – Install your Linux distribution of choice. To update to WSL 2, wait to restart your machine and move on to the next step.
Step 2 – Check requirements for running WSL 2
For x64 systems: Version 1903 or later, with Build 18362.1049 or later.
For ARM64 systems: Version 2004 or later, with Build 19041 or later.
or Windows 11.
To check your version and build number, select Windows logo key + R, type winver, select OK. Update to the latest Windows version in the Settings menu.
Step 3 – Enable Virtual Machine feature
Before installing WSL 2, you must enable the Virtual Machine Platform optional feature. Your machine will require virtualization capabilities to use this feature.
online featurename:VirtualMachinePlatform all norestart
Restart your machine to complete the WSL install and update to WSL 2.
Step 4 – Download the Linux kernel update package
Download the latest package:
Run the update package downloaded in the previous step. (Double-click to run – you will be prompted for elevated permissions, select ‘yes’ to approve this installation.)
Once the installation is complete, move on to the next step – setting WSL 2 as your default version when installing new Linux distributions. (Skip this step if you want your new Linux installs to be set to WSL 1).
Step 5 – Set WSL 2 as your default version
Open PowerShell and run this command to set WSL 2 as the default version when installing a new Linux distribution:
wsl version
Step 6 – Install your Linux distribution of choice
Open the Microsoft Store and select your favorite Linux distribution.
From the distribution’s page, select “Get”.
The first time you launch a newly installed Linux distribution, a console window will open and you’ll be asked to wait for a minute or two for files to de-compress and be stored on your PC. All future launches should take less than a second.
CONGRATULATIONS! You’ve successfully installed and set up a Linux distribution that is completely integrated with your Windows operating system!
Troubleshooting installation
If you run into an issue during the install process, check the installation section of the troubleshooting guide.
Downloading distributions
If the Microsoft Store app is not available, you can download and manually install Linux distributions using these links:
This will cause the <distro>.appx packages to download to a folder of your choosing.
If you prefer, you can also download your preferred distribution(s) via the command line, you can use PowerShell with the Invoke-WebRequest cmdlet. For example, to download Ubuntu 20.04:
Uri https:aka.mswslubuntu2004 OutFile Ubuntu.appx UseBasicParsing
You also have the option to use the curl command-line utility for downloading. To download Ubuntu 20.04 with curl:
In this example, curl.exe is executed (not just curl) to ensure that, in PowerShell, the real curl executable is invoked, not the PowerShell curl alias for Invoke-WebRequest.
.\app_name.appx
Once the Appx package has finished downloading, you can start running the new distribution by double-clicking the appx file. (The command wsl -l will not show that the distribution is installed until this step is complete).
If you are using Windows server, or run into problems running the command above you can find the alternate install instructions on the Windows Server documentation page to install the .appx file by changing it to a zip file.
Install Windows Terminal (optional)
Install Windows Terminal.
Install Linux on Windows with WSL
Developers can access the power of both Windows and Linux at the same time on a Windows machine. The Windows Subsystem for Linux (WSL) lets developers install a Linux distribution (such as Ubuntu, OpenSUSE, Kali, Debian, Arch Linux, etc) and use Linux applications, utilities, and Bash command-line tools directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.
Prerequisites
You must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11 to use the commands below. If you are on earlier versions please see the manual install page.
Install WSL command
This command will enable the features necessary to run WSL and install the Ubuntu distribution of Linux. (This default distribution can be changed).
If you’re running an older build, or just prefer not to use the install command and would like step-by-step directions, see WSL manual installation steps for older versions.
The first time you launch a newly installed Linux distribution, a console window will open and you’ll be asked to wait for files to de-compress and be stored on your machine. All future launches should take less than a second.
Change the default Linux distribution installed
By default, the installed Linux distribution will be Ubuntu. This can be changed using the -d flag.
To change the distribution installed, enter: wsl --install -d <Distribution Name>. Replace <Distribution Name> with the name of the distribution you would like to install.
To see a list of available Linux distributions available for download through the online store, enter: wsl --list --online or wsl -l -o.
To install additional Linux distributions after the initial install, you may also use the command: wsl --install -d <Distribution Name>.
If you run into an issue during the install process, check the installation section of the troubleshooting guide.
To install a Linux distribution that is not listed as available, you can import any Linux distribution using a TAR file. Or in some cases, as with Arch Linux, you can install using an .appx file. You can also create your own custom Linux distribution to use with WSL.
Set up your Linux user info
Set up and best practices
Check which version of WSL you are running
You can list your installed Linux distributions and check the version of WSL each is set to by entering the command: wsl -l -v in PowerShell or Windows Command Prompt.
To set the default version to WSL 1 or WSL 2 when a new Linux distribution is installed, use the command: wsl --set-default-version <Version#>, replacing <Version#> with either 1 or 2.
To set the default Linux distribution used with the wsl command, enter: wsl -s <DistributionName> or wsl --setdefault <DistributionName>, replacing <DistributionName> with the name of the Linux distribution you would like to use. For example, from PowerShell/CMD, enter: wsl -s Debian to set the default distribution to Debian. Now running wsl npm init from Powershell will run the npm init command in Debian.
To run a specific wsl distribution from within PowerShell or Windows Command Prompt without changing your default distribution, use the command: wsl -d <DistributionName>, replacing <DistributionName> with the name of the distribution you want to use.
Upgrade version from WSL 1 to WSL 2
New Linux installations, installed using the wsl --install command, will be set to WSL 2 by default.
The wsl --set-version command can be used to downgrade from WSL 2 to WSL 1 or to update previously installed Linux distributions from WSL 1 to WSL 2.
To see whether your Linux distribution is set to WSL 1 or WSL 2, use the command: wsl -l -v.
To change versions, use the command: wsl --set-version <distro name> 2 replacing <distro name> with the name of the Linux distribution that you want to update. For example, wsl --set-version Ubuntu-20.04 2 will set your Ubuntu 20.04 distribution to use WSL 2.
If you manually installed WSL prior to the wsl --install command being available, you may also need to enable the virtual machine optional component used by WSL 2 and install the kernel package if you haven’t already done so.
Ways to run multiple Linux distributions with WSL
WSL supports running as many different Linux distributions as you would like to install. This can include choosing distributions from the Microsoft Store, importing a custom distribution, or building your own custom distribution.
There are several ways to run your Linux distributions once installed:
Install Windows Terminal(Recommended) Using Windows Terminal supports as many command lines as you would like to install and enables you to open them in multiple tabs or window panes and quickly switch between multiple Linux distributions or other command lines (PowerShell, Command Prompt, PowerShell, Azure CLI, etc). You can fully customize your terminal with unique color schemes, font styles, sizes, background images, and custom keyboard shortcuts. Learn more.
You can directly open your Linux distribution by visiting the Windows Start menu and typing the name of your installed distributions. For example: “Ubuntu”. This will open Ubuntu in it’s own console window.
From Windows Command Prompt or PowerShell, you can enter the name of your installed distribution. For example: ubuntu
From Windows Command Prompt or PowerShell, you can open your default Linux distribution inside your current command line, by entering: wsl.exe.
From Windows Command Prompt or PowerShell, you can use your default Linux distribution inside your current command line, without entering a new one, by entering:wsl [command]. Replacing [command] with a WSL command, such as: wsl -l -v to list installed distributions or wsl pwd to see where the current directory path is mounted in wsl. From PowerShell, the command get-date will provide the date from the Windows file system and wsl date will provide the date from the Linux file system.
The method you select should depend on what you’re doing. If you’ve opened a WSL command line within a Windows Prompt or PowerShell window and want to exit, enter the command: exit.
Want to try the latest WSL preview features?
Try the most recent features or updates to WSL by joining the Windows Insiders Program. Once you have joined Windows Insiders, you can choose the channel you would like to receive preview builds from inside the Windows settings menu to automatically receive any WSL updates or preview features associated with that build. You can choose from:
Dev channel: Most recent updates, but low stability.
Beta channel: Ideal for early adopters, more reliable builds than the Dev channel.
Release Preview channel: Preview fixes and key features on the next version of Windows just before its available to the general public.
The WSL commands below are listed in a format supported by PowerShell or Windows Command Prompt. To run these commands from a Bash / Linux distribution command line, you must replace wsl with wsl.exe. For a full list of commands, run wsl --help.
Install
--distribution: Specify the Linux distribution to install. You can find available distributions by running wsl --list --online.
--no-launch: Install the Linux distribution but do not launch it automatically.
--web-download: Install from an online source rather than using the Microsoft Store.
When WSL is not installed options include:
--inbox: Installs WSL using the Windows component instead of using the Microsoft Store. (WSL updates will be received via Windows updates, rather than pushed out as-available via the store).
--enable-wsl1: Enables WSL 1 during the install of the Microsoft Store version of WSL by also enabling the “Windows Subsystem for Linux” optional component.
--no-distribution: Do not install a distribution when installing WSL.
List available Linux distributions
See a list of the Linux distributions available through the online store. This command can also be entered as: wsl -l -o.
List installed Linux distributions
See a list of the Linux distributions installed on your Windows machine, including the state (whether the distribution is running or stopped) and the version of WSL running the distribution (WSL 1 or WSL 2). Comparing WSL 1 and WSL 2. This command can also be entered as: wsl -l -v. Additional options that can be used with the list command include: --all to list all distributions, --running to list only distributions that are currently running, or --quiet to only show distribution names.
To designate the version of WSL (1 or 2) that a Linux distribution is running on, replace <distribution name> with the name of the distribution and replace <versionNumber> with 1 or 2. Comparing WSL 1 and WSL 2.
To set a default version of WSL 1 or WSL 2, replacing <Version> with either the number 1 or 2 to represent which version of WSL you would like the installation to default on for new Linux distribution installations. For example, wsl --set-default-version 2. Comparing WSL 1 and WSL 2.
To set the default Linux distribution that WSL commands will use to run, replace <Distribution Name> with the name of your preferred Linux distribution.
Change directory to home
Run a specific Linux distribution from PowerShell or CMD
Immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine. This command may be necessary in instances that require you to restart the WSL 2 virtual machine environment, such as changing memory usage limits or making a change to your .wslconfig file.
Replacing <DistributionName> with the name of your targeted Linux distribution will unregister that distribution from WSL so it can be reinstalled or cleaned up. Caution: Once unregistered, all data, settings, and software associated with that distribution will be permanently lost. Reinstalling from the store will install a clean copy of the distribution. For example, wsl --unregister Ubuntu would remove Ubuntu from the distributions available in WSL. Running wsl --list will reveal that it is no longer listed.
You can also uninstall the Linux distribution app on your Windows machine just like any other store application. To reinstall, find the distribution in the Microsoft Store and select “Launch”.
Mount a disk or device
Attach and mount a physical disk in all WSL2 distributions by replacing <DiskPath> with the directory\file path where the disk is located. See Mount a Linux disk in WSL 2. Options include:
--vhd: Specifies that <Disk> refers to a virtual hard disk.
--name: Mount the disk using a custom name for the mountpoint
--bare: Attach the disk to WSL2, but don’t mount it.
--type <Filesystem>: Filesystem type to use when mounting a disk, if not specified defaults to ext4. This command can also be entered as: wsl --mount -t <Filesystem>.You can detect the filesystem type using the command: blkid <BlockDevice>, for example: blkid <dev/sdb1>.
--partition <Partition Number>: Index number of the partition to mount, if not specified defaults to the whole disk.
--options <MountOptions>: There are some filesystem-specific options that can be included when mounting a disk. For example, ext4 mount options like: wsl --mount -o "data-ordered" or wsl --mount -o "data=writeback. However, only filesystem-specific options are supported at this time. Generic options, such as ro, rw, or noatime, are not supported.
Unmount disks
Unmount a disk given at the disk path, if no disk path is given then this command will unmount and detach ALL mounted disks.
Deprecated WSL commands
[] []
These commands were the original wsl syntax for configuring Linux distributions installed with WSL, but have been replaced with the wsl or wsl.exe command syntax.
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), нажать кнопку ОК, и перезагрузить компьютер.
Вы можете включить компоненты WSL в Windows 10 с помощью dism:
После этого также необходимо перезагрузить компьютер.
В настройка BIOS/UEFI компьютера должна быть включена поддержка аппаратной виртуализации: Intel VT (Intel Virtualization Technology) или AMD-V.
Чтобы сделать 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 с помощью файла Ubuntu.exe.
После установки можно проверить используемую версию WSL с помощью команды
wsl --list –-verbose
Если у вашей среды Linux указана версия 1, нужно изменить ее на WSL2 командой:
wsl --set-version Ubuntu-20.04 2
После установки дистрибутива в стартовом меню появляется ярлык на него. Для запуска Ubuntu зайдите в меню Пуск, нажмите на соответствующем ярлыке и получите в отдельном окне полноценную командную оболочку Bash. Запускать WSL можно и с помощью команды wsl. При первом запуске образа в командной строке Bash вам будет предложено создать пользователя и пароль (которые не должны совпадать с учётной записью Windows). Чтобы выполнять команды с правами root, необходимо использовать дополнительный ключ (префикс) sudo. В WSL есть общие команды для Bash и CMD, и тут нужно не забывать, что система Linux чувствительна к регистру.
Вы можете выполнить Linux-команды из CMD. Для этого необходимо вначале указать “WSL”. Например, для просмотра списка файлов и папок в каталоге Windows, выполните:
Также вы можете открыть проводник командой explorer.exe, калькулятор – calc.exe, блокнот – notepad.exe, paint – mspaint.exe, календарь – cal, погоду – curl wttr.in
Ещё один пример взаимосвязи 2х систем – вы можете открыть в Windows файл из WSL-дистрибутива по сетевому пути. Для этого в CMD наберите путь к файлу: notepad \\wsl$\Ubuntu-20.04\home\1122.txt
Из окна консоли вы можете обновить список пакетов в Ubuntu с помощью команд:
Из командной строки Linux можно не только просмотреть Windows-файлы и каталоги, но и получить к ним доступ. Чтобы удобнее копировать файлы, просматривать директории и их содержимое, установите файловый менеджер Midnight Commander с помощью команды
sudo apt-get install mc
Вы можете запустить Midnight Commander как в командной оболочке Bash, так и внутри CMD. На скриншоте ниже показано, что в двух панелях MC показывается список файлов с обеих ОС.
С помощью пакетного менеджера apt-get установим несколько графических программ: например, браузер, текстовый редактор или что-то ещё:
Теперь можете запустить графические программы Linux через WSL командами:
Вы можете установить в Windows 10 несколько дистрибутивов Linux и запускать одновременно в разных окнах WSL. Вывести весь перечень установленных дистрибутивов можете с помощью команды:
wsl --list –all
чтобы завершить работу всех запущенных дистрибутивов и ядра WSL 2, выполните команду:
Windows Subsystem Installation for Windows
WSL 2 is a new version of the Windows Subsystem for Linux architecture that powers the Windows Subsystem for Linux to run ELF64 Linux binaries on Windows. Its primary goals are to increase file system performance, as well as adding full system call compatibility.
There are two ways in which you can install WSL in your Windows Machine:
Simple Installation (Not so good for Privacy)
Manual Installation
Simple Method
This method only requires you to run wsl --install command in your terminal.
But , in order to use this command you must:
Join the Windows Insiders Program
Install a preview build of Windows 10 (OS build 20262 or higher).
Open a command line windows with Administrator privileges
After this, Restart your machine to complete the installation.
The first time you launch a newly installed Linux distribution, a console window will open and you’ll be asked to wait for files to de-compress and be stored on your PC. All future launches should take less than a second.
CONGRATULATIONS! You’ve successfully installed and set up a Linux distribution that is completely integrated with your Windows operating system!
Enables the optional WSL and Virtual Machine Platform components
Downloads and installs the latest Linux kernel
Sets WSL 2 as the default
Downloads and installs a Linux distribution (reboot may be required)
If you want to use WSL-2 as your default version , then execute this command wsl --set-default-version 2 , otherwise the default will be version 1 only.
You can change it anytime, using the same command.
If you are having any problems, running the above command for wsl-2, download this update package WSL2 Linux kernel update package for x64 machines and run it, then try again.
Note: By default, the installed Linux distribution will be Ubuntu. This can be changed using wsl --install -d <Distribution Name>. (Replacing <Distribution Name> with the name of your desired distribution.) Additional Linux distributions may be added to your machine after the initial install using the wsl --install -d <Distribution Name> command. To see a list of available Linux distributions, enter wsl --list --online.
Step 1 — Enable the Windows Subsystem for Linux
You must first enable the “Windows Subsystem for Linux” optional feature before installing any Linux distributions on Windows.
I recommend now moving on to step-2 , updating to WSL 2 , but if you wish to only install WSL 1, you can now restart your machine and move on to Step 6 — Install your Linux distribution of choice. To update to WSL 2, wait to restart your machine and move on to the next step.
Step 2 — Check requirements for running WSL 2
To update to WSL 2, you must be running Windows 10.
For x64 systems: Version 1903 or higher, with Build 18362 or higher.
For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.
Builds lower than 18362 do not support WSL 2. Use the Windows Update Assistant to update your version of Windows.
To check your version and build number, select Windows logo key + R, type winver, select OK. Update to the latest Windows version in the Settings menu.
Step 3 — Enable Virtual Machine feature
Before installing WSL 2, you must enable the Virtual Machine Platform optional feature. Your machine will require virtualization capabilities to use this feature.
Restart your machine to complete the WSL install and update to WSL 2.
Step 4 — Download the Linux kernel update package
Download the latest package: WSL2 Linux kernel update package for x64 machines
Run the update package downloaded in the previous step. (Double-click to run — you will be prompted for elevated permissions, select ‘yes’ to approve this installation.)
Once the installation is complete, move on to the next step — setting WSL 2 as your default version when installing new Linux distributions. (Skip this step if you want your new Linux installs to be set to WSL 1).
Step 5 — Set WSL 2 as your default version
Open PowerShell and run this command to set WSL 2 as the default version when installing a new Linux distribution:
wsl --set-default-version 2
Step 6 — Install your Linux distribution of choice
Note: If you are doing this installation for running/installing Docker , this step is not necessary.
Open the Microsoft Store and select your favorite Linux distribution.
3. From the distribution’s page, select “Get”.
The first time you launch a newly installed Linux distribution, a console window will open and you’ll be asked to wait for a minute or two for files to de-compress and be stored on your PC. All future launches should take less than a second.
CONGRATULATIONS! You’ve successfully installed and set up a Linux distribution that is completely integrated with your Windows operating system!
Troubleshooting installation
Refer to the WSL troubleshooting page for common errors and their solutions.
References
Official WSL-2 Installation Guide: https://docs.microsoft.com/en-us/windows/wsl/install-win10
(A Beginners Guide to Setup Windows Subsystem for Linux 2)
Written in collaboration with Hiren Rupchandani
What is WSL?
WSL stands for Windows Subsystem for Linux provided by Microsoft. It is a tool that helps us integrate and run any Linux distribution natively (such as Ubuntu) on Windows. It offers a hassle-free experience of using Linux by providing a Linux Shell that can interact with the Windows file system.
How is it different than Virtual Box?
Photo by Rick Vanover on Veeam
WSL uses fewer resources than a Virtual Machine. It does not provide a desktop-like interface alternatively, it provides a command-line interface to run tools and apps alongside our Windows tools, desktop, and store apps. It also allows us to use Windows and Linux tools on the same set of files.
Why will you need WSL?
So, now that you have obtained a high-level overview of WSL and its need, let me guide you to its setup on Windows 10.
Prerequisites for WSL 2
The latest version of WSL is version 2. We will be installing Ubuntu as our Linux distribution for WSL 2. To install Ubuntu for WSL 2, you need a Windows Version 1903 or higher, with Build 18362 or higher.
To check your Windows 10 version, you can use the run command by pressing Win+R on your keyboard and writing winver inside the text box. Click on OK, and you will see a pop-up with your OS details:
Windows 10 information with OS Version and Build
Setting Up Ubuntu as WSL
Now that our system is compatible to install Ubuntu as WSL, let’s proceed…
Enable features on Windows 10
Click on the search button or search bar on the taskbar.
Searching for “Turn Windows features on or off” in the search bar
Search for Turn Windows features on or off. You will find a list of features available in Windows
Scroll down till you find the following features:
Virtual Machine Platform
Windows Hypervisor Platform
Windows Subsystem for Linux
Check or tick these three features and click OK.
Your computer will download and install these features from the web. Make sure you have a good internet connection.
Once the features get downloaded and installed, restart your system.
Installing Ubuntu 20
Click on the search button or search bar on the taskbar, and search and open the Microsoft store.
Search for Ubuntu 20.04 LTS on the store. If you can’t find it, click on this link.
Click on the Get button. It will start the download and install the application on your system.
Once the installation gets completed, open Ubuntu from the start menu.
A few initializations will progress, and it will ask for the setting up of username and password for your Linux machine.
After setting up your credentials, you will see something like this:
Type pwd (print working directory)in the command lineto check your current location in the file system. Your output should look like this:
Update and set up WSL 2
Open the Windows PowerShell as an administrator.
Type the following command to check the WSL version in your system:
PS C:\WINDOWS\system32> wsl -l -v
If there is no distribution available, you may find the following output:
PS C:\WINDOWS\system32> wsl -l -vOUTPUT: Windows Subsystem for Linux has no installed distributions. Distributions can be installed by visiting the Microsoft Store: https://aka.ms/wslstore PS C:\WINDOWS\system32>
Alternatively, you may find the WSL version displayed as the output.
If you see the VERSION showing as 1, you will get the output as follows:
PS C:\WINDOWS\system32> wsl -l -vOUTPUT: NAME STATE VERSION * Ubuntu-20.04 Running 1 PS C:\WINDOWS\system32>
In such a case, you need to download an upgradedeveloped by Microsoft and install it.
Approve the administrator access for installation by clicking Yes, if required.
Your WSL version will get upgraded, and all that is left will be to change the default version of WSL from version 1 to version 2, which you can do using the following command:
After the WSL version gets updated, it is time to update Ubuntu’spackages and tools.
We can update our Ubuntu packages from all repositories and PPA’s (Personal Package Archives) using the following command:
Now we will upgrade to the newer version of the tools and packages installed on the system using the following command:
Your system will ask for permission to download the latest tools and packages.
Press y followed by an Enter to grant the permissions.
The installation will begin, and your Ubuntu will get upgraded with the latest packages and tools.
Check for mounted drives and tools
You can write the following command to check the mounted drives available using the Ubuntu terminal:
OUTPUT: c d e f g
Let’s say you want to enter the “c” drive, then you can simply use the “cd” command:
You can also try running python3 on the terminal
OUTPUT: Congratulations! You have successfully installed WSL on Windows 10 >>>
If all the above steps get successfully executed, congratulations! You have successfully set up WSL 2 on your Windows 10.
Final Thoughts and Closing Comments
There are some vital points many people fail to understand while they pursue their Data Science or AI journey. If you are one of them and looking for a way to counterbalance these cons, check out the certification programs provided by INSAID on their website. If you liked this story, I recommend you to go with the Global Certificate in Data Sciencebecause this one will cover your foundations plus machine learningalgorithms (basic to advance).
If you find this read helpful, then hit theClap👏. Your encouragement will catalyze inspiration to keep me going and develop more valuable content.
What’s next?
Setting up Apache Airflow in Windows using WSL 2
Вступление
С 90-х годов в качестве основной операционной системы я задействовал то Windows, то различные дистрибутивы Linux. И почти каждый раз использовал обе эти системы, переключаясь между ними в ходе двойной загрузки либо запуская одну из них на виртуальной машине с помощью стороннего программного обеспечения, такого как VirtualBox. Но после того, как несколько лет назад в Microsoft представили подсистему Windows для Linux, или WSL (Windows Subsystem for Linux), а позже и WSL 2, для меня как разработчика она быстро стала любимой конфигурацией.
Установка подсистемы Windows для Linux
Первым делом убедитесь, что используете Windows 10 версии 1903 или новее. Подсистема Windows для Linux относится к дополнительному функционалу, и по умолчанию в Windows она отключена. Для ее подключения откройте меню «Пуск», введите Windows Feature («Компоненты Windows») и нажмите на клавишу enter («Ввод»).
В диалоговом окне Windows Features («Компоненты Windows») подключите Virtual Machine Platform («Платформу виртуальной машины») и Windows Subsystem for Linux («Подсистему Windows для Linux») и нажмите на кнопку OK. После завершения установки Windows попросит перезагрузить систему. Сделайте это.
Теперь подсистема Windows для Linux установлена, идем дальше.
Обновление WSL до версии 2
Прежде чем использовать подсистему Windows для Linux версии 2, необходимо загрузить и установить обновление для ее ядра:
Загрузите и установите пакет. Теперь поменяем версию по умолчанию, которую использует WSL, на версию 2. Для этого откройте командную строку и введите:
wsl --set-default-version 2
Эта команда настраивает подсистему Windows для Linux на использование версии 2 при установке новых дистрибутивов Linux.
Установка дистрибутива Linux
В этом руководстве описывается установка Ubuntu 20.04, что не мешает вам установить любой другой дистрибутив.
Откройте Microsoft Store.
Найдите Ubuntu 20.04 LTS.
Нажмите на кнопку install («Установить»).
По завершении процесса нажмите на кнопку launch («Запустить»). Откроется новое окно терминала, и Ubuntu завершит установку. Затем введите имя пользователя и пароль для пользователя по умолчанию.
Здесь же в терминале обновите Ubuntu, запустив команду:
sudo apt update && sudo apt upgrade
Введите пароль и дождитесь завершения процесса.
Установка терминала Windows (дополнительно)
Если хотите, можете продолжать использовать этот терминал. Лично я предпочитаю терминал с дополнительными параметрами настройки. И в качестве такового Microsoft предлагает Windows Terminal («Терминал Windows»). Для его установки надо:
Открыть Microsoft Store.
Найти Windows Terminal.
Нажать на кнопку install.
Цветовая схема One Half Dark
Доступных вариантов настройки довольно много. Загляните в официальную документацию, и вы найдете тот вариант, который вам понравится.
Если потребуется помощь в настройке терминала, посмотрите мой ролик на Youtube о том:
Заключение
Итак, у вас с помощью WSL и симпатичного терминала запущен и готов к работе дистрибутив Linux. А что же дальше? А дальше все будет зависеть от вас: от того, что вы будете разрабатывать и, конечно же, от инструментов, которые вы предпочитаете при работе с кодом. Теперь у вас есть отличная база, чтобы эту работу начать.
Очень рекомендую редактор кода Visual Studio Code. Он тоже разработан в Microsoft и хорошо подходит для WSL. По нему есть специальное руководство:
Читайте нас в Telegram, VK и Яндекс.Дзен
Linux or Windows?
December 2021 update with Windows 11:
With newer versions of Windows (including Windows 11), you can set up WSL 2 simply by running wsl --install . This will update the appropriate settings to enable WSL and update the Linux Kernel to the latest version.
NAME FRIENDLY NAME Ubuntu Ubuntu Debian Debian GNU/Linux kali-linux Kali Linux Rolling openSUSE-42 openSUSE Leap 42 SLES-12 SUSE Linux Enterprise Server v12 Ubuntu-16.04 Ubuntu 16.04 LTS Ubuntu-18.04 Ubuntu 18.04 LTS Ubuntu-20.04 Ubuntu 20.04 LTS
To install WSL2 with the Ubuntu default, simply run:
This will do all the magic for you.
I have been part of the Azure Kbernetes Services (aks) team at Microsoft, working on Service Reliability (SRE) and focusing on monitoring, ci/cd automation and toil reduction for about a year and a half now. I do anything I need there using WSL2 (the Windows Subsystem for Linux version 2), Visual Studio Code and Docker Desktop on Windows 10, where I feel more at home (and I can game too).
My first attempt was to create a Linux VM and run it on Azure. The result was dece, I was able to ssh in with Moba XTerm or conEmu, run Docker and build my go code no problem, but editing was a pain. You don’t want to write code on a VNC or RDP connection, as there is lag involved with your keystrokes and over time it becomes frustrating. This was before VS Code had good Remote Development support, Code Server remoting via ssh was in beta at the time, and I had to set it up myself on the VM, but sometimes it would go down. The dealbreaker for me was the lack of productivity tools on Ubuntu Desktop, missing the Office suite meant I had to run everything on the browser or switch between machines all the time and this felt sluggish, while I wanted to go fast!
Next step, I got myself a MacBook Pro and configured it all up. This was definitely a step up, everything was native with the Mac: Docker, ssh, bash, go are at home there, and Visual Studio Code did a magnificent job of not making me feel too stranger to the Mac platform, behaving exactly the way I remembered it on the PC.
With the use of Karabiner I was able to remap ctrl+c / ctrl+v and Home/End to my likings but this was this setting was not respected by all apps, for example on Chrome, editing our Wiki was hard as Home and End were going to top and end of the page and my brain kept pressing them whenever I wanted to go to the beginning/end of the line, again speedbumps slowing me down.
Also, some of the security configuration in my company prefers the Windows integration, so it was a bit of a pain with the Mac (no smartcards support!) as I had to switch to my PC to run some tasks.
I had tried WSL before, but, besides the slow file system speed, the mayor dealbreaker was the inability to use Docker without exposing the daemon outside of TLS. Nik Janetakis’ article explained this very well but I did not feel secure enough to run my service with this configuration. I also had issues with Minikube, and Docker for Windows was not an alternative yet, so I passed.
The right version of Windows 10
To install WSL2 you will need at least Windows 10 May 2020 Update. At the time of this update (August 2020), most people should have received the update and running the correct version.
To check, press the Windows+R keys and run winver.exe , you should see your version of Windows 10:
If you have an older version, check Microsoft article on how to Get the Windows 10 May 2020 Update or check out my older article on how to Install Windows 10 May 2020 Update via Winodws Insider Program.
After the script is complete, you need to reboot your machine, since this enables new Windows features.
OK, now it is time to set WSL2 to be the default for all WSL installations. Trust me, you don’t need to use WSL version 1 ever again. Open PowerShell and run:
The result is not very exciting, but it will come handy soon.
Installing Ubuntu on WSL2
Now it is time to install your favorite Linux distro. As per the instructions here, open the Microsoft Store app and type Linux in the search box, all the available distros show up:
I run Ubuntu 18.04 TLS, but you can select the one you prefer and click Install:
Once it is installed, press Launch:
If you get lost, you can always type Ubuntu from the Start menu and run it from there:
Now open PowerShell and ensure that WSL is correctly using version 2 for your distro:
wsl --list -v
If this is still showing version 1, you can run the upgrade command:
wsl --set-version Ubuntu-18.04 2
There, you have a shiny full Ubuntu distro on your PC, you can open your Ubuntu shell and (proudly) check the version:
Until next time
Check out Part 3: Visual Studio Code and go, for configuring VS Code and golang on Ubuntu in Windows 10 with WSL2.