- How to Install Linux Bash Shell on Windows 10
- What is Bash on Windows?
- Method 1: Install Linux Bash Shell on Windows 10 Newer Versions
- Step 1: Enable “Windows Subsystem for Linux” feature
- Step 2: Download a Linux system from the Windows store
- Step 3: Run Linux inside Windows 10
- Troubleshooting 1: The WSL optional component is not enabled. Please enable it and try again.
- Troubleshoot 2: Installation failed with error 0x80070003
- Method 2: Install Linux Bash Shell on older Windows 10
- Step 1:
- Step 2:
- Step 3:
- Step 4:
- Step 5:
- Step 6:
- Step 7:
- Step 8:
- Step 9:
- Step 10:
- Bonus Tip: Run GUI Apps On Windows Subsystem for Linux
- Step 1: Enable/Update WSL 2
- Step 2: Download and Install a Windows X Server Program
- Step 3: Configure Windows X Server
- Как установить и использовать оболочку Linux Bash в Windows 10
- Что нужно знать про оболочку Bash в Windows 10
- Как установить Bash в Windows 10
- Как использовать оболочку Bash и устанавливать программное обеспечение Linux
- Дополнительно: установка родного шрифта Ubuntu
How to Install Linux Bash Shell on Windows 10
Last updated October 29, 2020 By Abhishek Prakash 104 Comments
Brief: This beginner’s tutorial shows you how to install bash on Windows.
Linux on Windows is a reality, thanks to the partnership between Canonical (parent company of Ubuntu) and Microsoft. When Microsoft’s CEO announced that the Bash shell was coming to Windows, a number of people just couldn’t believe it. #BashOnWindows trended on Twitter for days, such was the impact of this news.
But Bash on Windows was not available to everyone immediately. People had to install the Windows 10 technical preview to install Linux on Windows 10. But this is not the case anymore. The Windows 10 anniversary upgrade is here and now you can easily get Bash on Windows. And, before we go on installing Bash on Windows, let me tell you a little more about it.
Note: This tutorial was tested with the latest available Windows 10 version 2004 and build 19041.450. You might need to update your Windows installation if you’ve an older build to follow everything in this tutorial.
What is Bash on Windows?
Bash on Windows provides a Windows subsystem and Ubuntu Linux runs atop it. It is not a virtual machine or an application like Cygwin. It is complete Linux system inside Windows 10.
Basically, it allows you to run the same Bash shell that you find on Linux. This way you can run Linux commands inside Windows without the needing to install a virtual machine, or dual boot Linux and Windows. You install Linux inside Windows like a regular application. This is a good option if your main aim is to learn Linux/Unix commands.
I recommend reading this article to know more about Bash on Windows.
Method 1: Install Linux Bash Shell on Windows 10 Newer Versions
Good thing is that the Fall Creator’s Update and the recent Windows 10, version 2004 makes it easier to install Bash on Windows 10. You can get it in one click from Windows Store. There are still a few things to do however.
I am installing Ubuntu using Windows Subsystem for Linux. You can also use SUSE Linux. The procedure is same for both distributions.
Step 1: Enable “Windows Subsystem for Linux” feature
The first thing you need to do is to enable Windows Subsystem for Linux feature from PowerShell or from the Windows feature options.
If you want to utilize the GUI, you can simply search for option to get the list of Windows features to enable a few things as shown in the screenshot below.
Now, you just have to open it to access all the options. Among the ones listed, you have to enable (or check) the feature for “Windows Subsystem for Linux” and “Virtual Machine Platform” and then perform a reboot to make sure you have both of them enabled.
In either case, if you want to utilize the PowerShell, you can just go to the Start menu and search for PowerShell. Run it as administrator:
Once you have the PowerShell running, use the command below to enable Bash in Windows 10.
You’ll be asked to confirm your choice. Type Y or press enter:
Now you should be asked to reboot. Even if you are not asked to, you must restart your system.
Step 2: Download a Linux system from the Windows store
Once your system has rebooted, go to the Windows Store and search for “Linux” or just “Ubuntu”.
You’ll see the option to install Ubuntu or SUSE. I have installed Ubuntu for Bash on Windows here.
What’s the difference between using Ubuntu or openSUSE or SUSE Linux Enterprise? And which one should you use?
To tell you quickly, the main difference would be in the commands for installing new packages inside these Linux subsystems. I advise going for Ubuntu in this case.
Once you choose the distribution of your choice, you’ll see the option to install it. Do note that it will download files of around 1Gb in size or less depending on what you’re downloading.
Step 3: Run Linux inside Windows 10
You are almost there. Once you have installed Linux, it’s time to see how to access Bash in Windows 10.
Just search for the Linux distribution you installed in the previous step. In my case it was Ubuntu. You’ll see that it runs like a normal Windows application.
It will take some time installing and then you’ll have to set up the username and password.
Don’t worry, it’s just for the first run. Bash shell will be available for use directly from the next time onwards.
Enjoy Linux inside Windows 10.
Troubleshooting 1: The WSL optional component is not enabled. Please enable it and try again.
You may see an error like this when you try to run Linux inside Windows 10:
And when you press any key, the application closes immediately.
The reason here is that the Windows Subsystem for Linux is not enabled in your case. You should enable it as explained in step 1 of this guide. You can do that even after you have installed Linux from Windows Store.
Troubleshoot 2: Installation failed with error 0x80070003
This is because Windows Subsystem for Linux only runs on the system drive i.e. the C drive. You should make sure that when you download Linux from the Windows Store, it is stored and installed in the C Drive.
Go to Settings -> Storage -> More Storage Settings: Change where new content is saved and select C Drive here.
Method 2: Install Linux Bash Shell on older Windows 10
If you cannot get the Fall Creator’s update on Windows 10 for some reason, you can still install it if you have the Anniversary update of Windows 10. But here, you’ll have to enable developer mode. I still recommend upgrading to the Fall Creator’s update or the latest Windows 10 2004 version update though.
Step 1:
Press Windows Key + I to access Windows system settings. In here, go to Update & Security:
Step 2:
From the left side pane, choose “For developers.” You’ll see an option for “Developer mode.” Enable it.
Step 3:
Now search for Control Panel and in Control Panel, click on “Programs”:
Step 4:
In Programs, click “Turn Windows features on or off”:
Step 5:
When you do this, you’ll see several Windows features. Look for “Windows Subsystem for Linux” and enable it.
Step 6:
You’ll need to restart the system after doing this.
Step 7:
After restarting the computer, click the start button and search for “bash”.
Step 8:
When you run it for the first time, you’ll be given the option to download and install Ubuntu. You’ll be asked to create a username and password during this process. It will install an entire Ubuntu Linux system, so have patience as it will take some time in downloading and installing Linux on Windows.
Step 9:
Once this is done, go back to the Start menu and search for Ubuntu or Bash.
Step 10:
Now you have a command line version of Ubuntu Linux. You can use apt to install various command line tools in it.
Bonus Tip: Run GUI Apps On Windows Subsystem for Linux
The ability to run GUI apps on Windows Subsystem for Linux was introduced with WSL 2 release in May 2020.
It’s still not something officially supported out-of-the-box, but if you’re curious, you can experiment with it by following the steps below:
Step 1: Enable/Update WSL 2
If you have the latest Windows version 2004, build 19041, you already have WSL 2 support but you need to enable it and set it to default instead of WSL 1.
To do that, first you need to ensure that you have the latest WSL 2 Linux Kernel by updating the WSL 2 Linux Kernel.
You just need to follow the instructions on the official documentation page and download/install the package. Once done, you need to launch the PowerShell (run it as administrator) and set WSL 2 as the default by typing the following command:
You should get a message that says “For information on key differences with WSL 2 please visit https://aka.ms/wsl2”.
In case you get an error (Error: 0x1bc), you need to make sure that you have updated the WSL 2 Linux Kernel, that solved the issue for me.
Step 2: Download and Install a Windows X Server Program
As I mentioned, WSL 2 does not have the official support for running GUI apps by default. So, to do it, we need to download and install a Windows X Server program to give WSL access to display the apps.
You can try the open-source XLaunch server that we’re using here.
Step 3: Configure Windows X Server
Now that you have installed it, you just need to configure a few things.
First, Launch XLaunch and proceed to ensure that you have the following options enabled:
1. Keep the Display number set as -1 and select “Multiple Windows“
2. Next, you need to enable “Start no client“.
3. Finally, you just need to check “Disable access control” to avoid permission issues and save the configuration on the next step to complete the configuration.
Now everything’s almost done, you need to launch Ubuntu from the list of apps installed and configure it to launch Linux GUI apps on Windows.
Just enter the following command in the Linux terminal (Ubuntu):
Now, just install your favorite Linux GUI app from the terminal and test if it works! In my case, I installed and launched Gedit using the following commands:
And, here’s how it looks:
I hope you find this tutorial helpful for installing bash on Windows 10 and experimenting Linux GUI apps on Windows 10. No wonder WSL lets you play with Linux inside of Windows. If you have questions or suggestions, feel free to ask.
Like what you read? Please share it with others.
Как установить и использовать оболочку Linux Bash в Windows 10
Подсистема Windows для Linux (Windows Subsystem for Linux, WSL), впервые представленная в Windows 10 версии 1607, стала действительно стабильной функцией в Windows 10 (версия 1709). Теперь пользователи получают среду для тестирования Linux-приложений прямо внутри Windows, которая работает быстрее, чем в виртуальной машине.
Что нужно знать про оболочку Bash в Windows 10
Функция WSL на самом деле не является виртуальной машиной, контейнером или программным обеспечением Linux, скомпилированным для Windows. Windows 10 предлагает полноценную подсистему Windows 10, предназначенную для запуска программного обеспечения Linux. Подсистема основана на проекте Microsoft Astoria, который первоначально предназначался для запуска приложений Android в Windows.
WSL можно рассматривать как противоположность Wine. В то время как Wine позволяет вам запускать приложения Windows прямо в Linux, подсистема Windows для Linux позволяет запускать приложения Linux непосредственно в Windows.
При создании среды оболочки на базе Bash Ubuntu, Microsoft работала совместно с компанией Canonical. Оболочка работает поверх подсистемы и технически не является Linux. Linux является основным ядром операционной системы, которое недоступно в подсистеме. Вместо этого функция WSL позволяет запускать оболочку Bash и исполнять такие же бинарные файлы, которые работают в Ubuntu Linux. Многие сторонники открытого программного обеспечения считает, что операционную систем Linux правильно называть именно “GNU/Linux”, потому что на ядре Linux работает много программного обеспечения GNU. Оболочка Bash, которую вы получаете в Windows 10, как раз содержит утилиты GNU и другое программное обеспечение.
Хотя эта функция изначально называлась “Ubuntu Bash в Windows”, она также позволяет запускать Zsh и другие оболочки командной строки. Сейчас поддерживаются и другие дистрибутивы Linux. Вы можете выбрать openSUSE Leap или SUSE Enterprise Server вместо Ubuntu, поддержка Fedora скоро будет реализована.
При использовании оболочки имеются некоторые ограничения. По умолчанию фоновое серверное ПО и графические приложения Linux не поддерживаются. Кроме того, в данной среде работают не все приложения командной строки, потому что функция не идеальна.
Как установить Bash в Windows 10
Данная функция не работает в 32-разрядной версии Windows 10, поэтому убедитесь, что вы используете 64-разрядную версию.
Если вы используете 64-битную версию Windows, то для начала работы перейдите в Панель управления > Программы и компоненты > Включение и отключение компонентов Windows. Отметьте галочкой пункт Подсистема Windows для Linux и нажмите кнопку ОК.
Затем нажмите “Перезагрузить сейчас”, чтобы перезапустить компьютер и применить изменения. Функция не будет работать до перезагрузки.
Примечание: начиная с Windows 10 (версия 1709), чтобы использовать эту функцию вам больше не нужно включать режим разработчика в приложении Параметры. Вам просто нужно включить подсистему в окне “Компоненты Windows”.
После перезагрузки ПК откройте Магазин Microsoft и выполните поисковый запрос “Linux”. Откроется список доступных для установки приложений.
Примечание: начиная с Windows 10 (версия 1709), вы больше не сможете устанавливать Ubuntu, выполнив команду bash. Вместо этого вам нужно установить Ubuntu или другой дистрибутив Linux из Магазина Microsoft.
Итак, вы увидите список всех дистрибутивов Linux, доступных в Магазине Microsoft. Начиная с Windows 10 (версия 1709), в магазине предлагаются Ubuntu, openSUSE Leap, openSUSE Enterprise, Debian Linux, Arch Linux и Kali Linux.
Чтобы установить конкретный дистрибутив, выберите его и нажмите кнопку “Получить” или “Установить”. В результате запуститься обычная установка, как и в случае с другими приложениями из Магазина Microsoft.
Если вы не знаете, какую среду Linux установить, мы рекомендуем Ubuntu. Этот популярный дистрибутив Linux был ранее единственным доступным вариантом, но теперь доступны другие системы Linux для различных нужд пользователей.
Вы также можете установить несколько дистрибутивов Linux, и каждый из них получит свои собственные уникальные ярлыки. Вы даже можете запускать несколько разных дистрибутивов Linux одновременно в разных окнах.
Как использовать оболочку Bash и устанавливать программное обеспечение Linux
После успешной установки вы получаете полноценную командную оболочку Bash на основе Ubuntu или другого выбранного дистрибутива Linux.
Поскольку в системах Linux используются одинаковые бинарные файлы, вы можете использовать команды Ubuntu apt или apt-get, чтобы установить программное обеспечение из репозитория Ubuntu. Просто используйте любую команду, которую вы обычно используете в этом дистрибутиве Linux. У вас будет доступ ко всему программному обеспечению командной строки Linux там, хотя некоторые приложения могут работать не идеально.
Чтобы открыть установленную среду Linux, просто откройте меню Пуск и выполните поиск любого дистрибутива, который вы установили. Например, если вы установили Ubuntu, запустите ярлык Ubuntu.
Вы можете закрепить плитку приложения в меню Пуск, на панели задач или разместить ярлык на рабочий стол для быстрого доступа.
При первом запуске среды Linux вам будет предложено ввести имя пользователя и пароль UNIX. Они не должны совпадать с вашим именем пользователя и паролем Windows, и будут использоваться в среде Linux.
Например, если вы введете “comss” и “qwerty” в качестве своих учетных данных, ваше имя пользователя в среде Linux будет “comss”, а пароль, который вы используете в среде Linux, будет “qwerty”, независимо от имени пользователя и пароля Windows.
Вы можете запустить установленную среду Linux с помощью команды wsl. Если у вас установлено несколько дистрибутивов Linux, вы можете выбрать среду Linux по умолчанию, которую будет запускаться этой командой.
Если у вас установлен Ubuntu, вы также можете запустить команду ubuntu для ее запуска. Для OpenSUSE Leap 42 используйте opensuse-42. Для SUSE Linux Enterprise Server 12 используйте sles-12. Эти команды перечислены на странице каждого дистрибутива Linux в Магазине Microsoft.
Кроме того, вы можете запустить стандартную среду Linux, выполнив команду bash, но Microsoft заявляет, что данный метод устаревает. Это означает, что команда bash может перестать функционировать в будущем.
Если у вас есть опыт использования оболочки Bash в Linux, MacOS или на других платформах, вы будете чувствовать себя уверенно.
В Ubuntu нужно использовать префикс команд sudo чтобы запускать их с правами root. Пользователь “root” на платформах UNIX имеет полный доступ к системе, аналогично “Администратору” в Windows. Файловая система Windows расположена по пути в /mnt/c в среде оболочки Bash.
В WSL можно использовать привычные команды терминала Linux. Если вы привыкли к стандартной командной строке Windows с ее командами DOS, вот несколько основных команд, общих для Bash и Windows:
- Изменить директорию: cd в Bash, cd или chdir в DOS
- Показать содержимое директории: ls в Bash, dir в DOS
- Переместить или переименовать файл: mv в Bash, move и rename в DOS
- Копировать файл: cp а Bash, copy в DOS
- Удалить файл: rm в Bash, del или erase в DOS
- Создать директорию: mkdir in Bash, mkdir в DOS
- Использовать текстовые редактор: vi или nano в Bash, edit в DOS
Важно помнить, что, в отличие от Windows, оболочка Bash и имитирующая ее Linux среда чувствительны к регистру. Другими словами, файл с названием “File.txt” отличается от файла с названием “file.txt”.
Для установки и обновления программного обеспечения среды Ubuntu нужно будет воспользоваться командой apt. Обязательно прикрепите эти команды к sudo, что заставляет их запускаться от пользователя root. Ниже представлены базовые команды apt-get, которые вам нужно знать:
- Загрузить обновленную информацию о доступных пакетах: sudo apt update
- Установить пакет приложения: sudo apt install packagename (замените packagename на название пакета)
- Удалить пакет приложения: sudo apt remove packagename (замените packagename на название пакета)
- Выполнить поиск доступных пакетов: sudo apt search word (замените word на ключевое слово в названии или описании пакета)
- Загрузить и установить новейшие версии установленных пакетов: sudo apt upgrade
После того, как вы загрузили и установили приложение, вы можете ввести его имя в оболочку и нажать Enter для его запуска.
Примечание: Программное обеспечение, которое вы устанавливаете в оболочке Bash, ограничено оболочкой Bash. Вы можете получить доступ к этим программам из командной строки, PowerShell или из другого места в Windows, но только если вы запустите команду bash -c.
Дополнительно: установка родного шрифта Ubuntu
Если вы хотите получить более точный опыт использования Ubuntu в Windows 10, то можете использовать следующую инструкцию, чтобы установить родные шрифты Ubuntu в терминал.
Чтобы установить шрифт, сначала загрузите семейство шрифтов Ubuntu с веб-сайта Ubuntu. Откройте загруженный .zip-файл и найдите файл UbuntuMono-R.ttf. Это шрифт Ubuntu с фиксированный шириной, который используется только в терминале. Это единственный шрифт, который вам нужно установить.
Дважды щелкните файл UbuntuMono-R.ttf, и вы увидите предварительный просмотр шрифта. Нажмите “Установить”, чтобы установить шрифт в систему.
Чтобы моноширинный шрифт Ubuntu стал доступен в консоли, вам нужно добавить параметр в реестр Windows.
Запустите редактор реестра, используя сочетание Windows + R , введя запрос regedit и нажав Enter.
Перейдите по следующему пути:
Щелкните правой кнопкой мыши в правой панели и выберите Создать > Строковый параметр . Назовите новое значение 000. Дважды щелкните на строке “000”, которую вы создали, а затем введите Ubuntu Mono в качестве значения.
Затем запустите окно Ubuntu, щелкните правой кнопкой мыши строку заголовка и выберите команду “Свойства”. Перейдите на вкладку “Шрифт” и выберите “Ubuntu Mono” в списке шрифта.