Bash on ubuntu on windows install

Step-by-step screenshot guide to show you how to install bash on Windows 11 and 10.

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, several people couldn’t believe it. #BashOnWindows trended on Twitter for days; such was the impact of this news.

But Bash on Windows (or Windows Subsystem for Linux) was not available to everyone immediately. People had to install the Windows 10 technical preview to install Linux on Windows 10.

That’s not the case anymore; it is pretty easy to install and use WSL now!

📋

This tutorial was tested with the latest Windows 11 version 22H2, and build 22621.819. You might need to update your Windows installation if you have an older build to follow everything in this tutorial.

What is Bash on Windows?

Bash on Windows provides a Windows subsystem, and Linux runs atop it. It is not a virtual machine or an application like Cygwin. It is a complete Linux system inside Windows 10/11. It allows you to run the same Bash shell you find on Linux. You can run Linux commands inside Windows without installing 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.

Check for System Compatibility

You must be running specific versions of Windows for the different features described in this article. Requirements necessary for a particular feature to work are described under its titles. To check your Windows version, search for about in the start menu.

search about in start menu

Search about in the Start Menu

Here, you can see the build of your PC, as shown in the screenshot below. Make sure it is matching with the respective requirements described under various sub-headings here in this article.

checking build number of windows

Checking the build number of Windows
  • You must be running Windows 10 version 1607 (the Anniversary update) or above.
  • WSL only runs on 64-bit versions 32-bit versions are not supported.

Install Bash in Newer Windows 10 and 11

The good thing is that the latest set of upgrades, including the stable release of WSL v1.0 released from Windows, makes it easier to install Bash on Windows.

There are two ways you can go about it:

  1. You can get it in one click from Windows Store.
  2. Choose to use the command-line.

1. Install WSL Using the Microsoft Store

wsl on microsoft store

Launch the Microsoft Store and search for «Windows subsystem«.

Install it, and you’re done with the first step. Next, you have to install a Linux distribution.

So, if you try to open WSL, you will get to see a window informing you that no distribution is installed.

command prompt asking to continue installing distributions

Similar to WSL, search for the distribution on Microsoft Store, and then install it.

For instance, I installed Ubuntu from the store as shown in the image below:

ubuntu 22.04 lts wsl on microsoft store

And, then proceed to «Open» it and it will automatically start installing. The procedure is same for any distribution you choose.

We then have to configure it, which is discussed right after installing it through the command line.

2. Install WSL and the default distribution using the command-line

In WSL, the default distribution is Ubuntu (which can be changed). To install, open Powershell as an administrator.

For this, search for Powershell in the start menu, right-click on Powershell and select Run as Administrator.

run powershell as an administrator

Run Powershell as an administrator

Inside Powershell, enter the following command to install WSL, along with all necessary features and the default distribution, that is, Ubuntu.

wsl --install

Once finished downloading and installing, you need to reboot to apply the changes.

Whether you installed WSL and Ubuntu using the Microsoft Store or the command line, you need to configure it.

Here’s how it is done:

🛠️ Configure the newly installed Ubuntu

After rebooting, search for Ubuntu in Start Menu and open it.

open ubuntu from windows 11 start menu

Open Ubuntu from Windows 11 start menu

It will ask you to enter a UNIX Username and Password. Enter these details and press enter key.

enter unix username and password

Enter UNIX username and password

You will now be inside the terminal window of Ubuntu.

logged into new ubuntu 22.04 lts in windows 11 wsl

Logged into new Ubuntu 22.04 LTS in Windows 11 WSL

Once logged in, you need to update the installed Ubuntu. For this, enter the following commands one by one:

sudo apt update
sudo apt full-upgrade

After completing the update, you are good to go with Ubuntu in WSL.

running ubuntu in wsl 1

Running Ubuntu in WSL

Install Bash on Older Windows

If you have the minimum requirements mentioned in the beginning but are running an older Windows build, the previous method may not be supported. So there is a manual installation method.

Also, there are both WSL1 and WSL2 available. WSL2 offers some upgraded functionalities but has some minimum requirements to run:

  • For x64 systems: Version 1903 or later, with Build 18362 or later.
  • For ARM64 systems: Version 2004 or later, with Build 19041 or later.

So this brings us to two possibilities to install:

  1. Install Ubuntu with WSL1
  2. Install Ubuntu with WSL2

1. Install Ubuntu with WSL 1

This is a relatively simple procedure for those with a system incompatible with WSL2. First, you need to enable the Windows Subsystem for the Linux feature. This can be done through the command line. Open Powershell as an administrator and enter the following command:

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

Or, to do this via GUI, follow the steps below:

windows 10 features enable/disable menu

  1. Search for Windows Features in Start Menu.
  2. Turn on Windows Subsystem for the Linux feature.
  3. Reboot your system.
  4. Open the Windows store and search for the distribution of your choice to install.

Once installation is completed, open the Ubuntu app from the start menu. It will take a couple of seconds to install. You will be prompted to enter a username and password. Provide those credentials, and you are good to go with Ubuntu in WSL1.

2. Install Ubuntu with WSL 2

It is recommended to use WSL2 instead of WSL1 if you have support. To install Ubuntu with WSL2, you need to make sure that the Windows Subsystem for Linux feature is turned on. For this, as in the above case, execute the following command in an elevated Powershell:

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

Reboot the device once the command is completed.

After this, you need to enable the Virtual Machine Platform feature. Open the Powershell with admin privileges and enter the following command:

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

Once again, restart the device to complete the WSL install and update to WSL 2.

Now, download the Linux Kernel Update Package for x64 machines from the official website. If you are using ARM64 devices, use this link to download the latest kernel update package.

If you are not sure about the device architecture, enter the command below in Powershell to get the type:

systeminfo | find "System Type"

When the file is downloaded, double-click on it and finish the installation of the Kernel update package.

Now, 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

Once WSL2 is set as the default version, you can now install the Linux distribution of your choice.

Go to Windows Store and install Ubuntu, as described in the earlier steps. and the rest of the procedure is already described above.

Enjoy Linux inside Windows.

🔧 Troubleshooting Tip 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:

The WSL optional component is not enabled. Please enable it and try again.
See https://aka.ms/wslinstall for details.
Error: 0x8007007e
Press any key to continue...

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 this guide. You can do that even after you have installed Linux.

🔧 Troubleshooting Tip 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 ensure that when you download Linux from the Windows Store, it is stored and installed in the C Drive.

On Windows 10, go to Settings -> Storage -> More Storage Settings -> Where new content is saved: Change where new content is saved and select C Drive here.

windows 10 new app storag location

On Windows 11, go to Settings -> System -> Storage -> Advanced storage settings -> Where new content is saved and select C Drive here.

select the c drive as storage space for new apps in windows 11 settings

Select the C-Drive as storage space for new apps in Windows 11 settings

🔧 Troubleshooting Tip 3

«Failed to attach disk Error»

Sometimes, this error will appear when we reinstall the Ubuntu in WSL.

file not found error in wsl

File not found error in WSL

In this case, open Powershell and run the following command:

wsl -l -v

This will list the installed Linux systems. Find the name of the system, that is throwing the error, in my case Ubuntu. Now run the following command:

wsl --unregister Ubuntu

You can restart the ubuntu app and it will run without any issues.

You can refer to more common troubleshooting methods from the official website.

Run GUI Apps On Windows Subsystem for Linux

The ability to run GUI apps on Windows Subsystem for Linux was introduced with the WSL 2 release in May 2020.

Windows Subsystem for Linux (WSL) with WSL2 now supports running Linux GUI applications (X11 and Wayland) on Windows in a fully integrated desktop experience. This allows you to install Linux applications and seamlessly integrate them into Windows desktop, including features like “pin to taskbar”.

📋

One crucial point is that you must be on Windows 10 Build 19044+ or Windows 11 to access this feature.

Step 1: Enable/Update WSL 2

This procedure has been explained in the above section and you can refer to it.

Step 2: Download and Install Graphics drivers

To run GUI apps, you need to install appropriate graphics drivers. You can use the following link to download the drivers according to your provider.

  • Intel GPU Driver for WSL
  • AMD GPU Driver for WSL
  • NVIDIA GPU Driver for WSL

Once installed, you are all done.

Step 3: Install some GUI Apps

Now, go to your Ubuntu app and install any GUI app using the APT package manager. You should note that running apps from other sources like flatpak are problematic within WSL.

For this article, I installed the Gedit text editor using the following command:

sudo apt install gedit -y

This will install several MB of packages including required libraries. Once completed, you can run the following command to start the GUI Gedit app in Windows.:

gedit

run gedit text editor gui in wsl ubuntu

Run Gedit text editor GUI in WSL Ubuntu

Similarly, you can install all the popular applications available to Linux, including Nautilus file manager, GIMP, etc. For more about running GUI applications in WSL, you can refer to the official documentation.

Install Linux Bash Shell on other 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.

Press Windows Key + I to access Windows system settings. Here, go to Update & Security:

select updatesecurity option in windows system settings

Select Updates&Security option in Windows system settings

From the left side pane, choose “For developers.” You’ll see an option for “Developer mode.” Enable it.

select for developers option from the side pane

Select For Developers option from the side pane

Now search for Control Panel and in Control Panel, click on “Programs”:

select programs from the windows control panel

Select Programs from the Windows Control Panel

In Programs, click “Turn Windows features on or off”:

select turn windows feature on or off from programs and features section

Select Turn Windows features on or off from the Programs and Features section

When you do this, you’ll see several Windows features. Look for “Windows Subsystem for Linux” and enable it.

select the windows subsystem for linux checkbox

Select the Windows Subsystem for Linux checkbox

You’ll need to restart the system after doing this.

restart the device to apply the changes

Restart the device to apply the changes

After restarting the computer, click the start button and search for “bash”.

select bash from windows start menu

Select Bash from Windows Start Menu

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.

running ubuntu inside windows

Running Ubuntu inside Windows

Once this is done, go back to the Start menu and search for Ubuntu or Bash.

search for ubuntu or bash in windows start menu

Search for Ubuntu or Bash in Windows Start Menu

Now you have a command line version of Ubuntu Linux. You can use apt to install various command line tools in it.

checking the working of bash shell in windows

Checking the working of Bash shell in Windows

💬 I hope you find this tutorial helpful for installing bash on Windows and experimenting with Linux GUI apps on Windows. No wonder WSL lets you play with Linux inside of Windows. If you have questions or suggestions, feel free to ask.

Bash On Ubuntu On Windows

This is a collaborative document where we help new bash users get the basics things working in Bash. It’s especially targeted for the users of Bash On Ubuntu On Windows — where the bash environment is fairly new.

In other words: Here we share resources, tips, known issues etc for Bash On Ubuntu On Windows.
Analytics

1. How to Install Bash on Ubuntu in Windows 10 (Windows Subsystem for Linux)

  1. Install the Windows 10 Anniversary Update
  2. Go to «Turn Windows features on or off»
  3. Scroll down to «Windows subsystem for Linux (Beta)»

(video: http://www.hanselman.com/blog/VIDEOHowToRunLinuxAndBashOnWindows10AnniversaryUpdate.aspx)

2. Start an bash ssh-agent on launch

2.1: Open the config

2.2: Add the following somewhere:

 #!/bin/bash
 
 # Set up ssh-agent
 SSH_ENV="$HOME/.ssh/environment"
 
 function start_agent {
     echo "Initializing new SSH agent..."
     touch $SSH_ENV
     chmod 600 "${SSH_ENV}"
     /usr/bin/ssh-agent | sed 's/^echo/#echo/' >> "${SSH_ENV}"
     . "${SSH_ENV}" > /dev/null
     /usr/bin/ssh-add
 }
 
 # Source SSH settings, if applicable
 if [ -f "${SSH_ENV}" ]; then
     . "${SSH_ENV}" > /dev/null
     kill -0 $SSH_AGENT_PID 2>/dev/null || {
         start_agent
     }
 else
     start_agent
 fi

2.3: Then run source ~/.bashrc to reload your config.

3. Troubleshoot ssh-agent forwarding

Connect with ssh and check if you forward your keys by running echo "$SSH_AUTH_SOCK". If you get no output, that means it’s not working. Make sure it’s running (above script should work) and that your ~/.ssh/config is configured to run ForwardAgent, for example:

Host 123.456.123.45
 ForwardAgent yes

4. Use Windows 10 Virtual desktop to have your own workspace

Create a new virtual desktop from Win+Tab and setup your ubuntu workspace. Or run 4 terminals on that screen, for different ssh sessions for example. Switch desktops easily and fast by either Win+Ctrl+left / Win+Ctrl+right or win+tab tab enter

5. How to access the filesystem from Windows / Ubuntu

In Ubuntu, you can find your entire C drive under /mnt/c. (You have the same permissions as the User you launched Ubuntu with)

In Windows, you can find your entire Ubuntu installation under %LocalAppData%lxss. (C:/Users/YOURUSERNAME/AppData/Local/lxss)

Note: Your ubuntu installation might end up on different paths depending on installation method, check this guide to find yours

6. Make full use of Interop

With interoperability, you can open Windows programs from WSL. Here are some ways to use to your advantage:

6.1: Set a Default Windows Browser

Some commands, such as Heroku CLI’s heroku open, need to open a browser. There’s no default browser in WSL by default, but one easy way to set this up is by adding the following to ~/.bashrc:

# replace with relevant browser
export BROWSER=/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe

6.2: Use Symlinks to open Windows Programs

One use case is to open your text editor to the current directory. Interop + symlinks make this possible. For example:

ln -s /mnt/c/Program Files/Microsoft VS Code/Code.exe /usr/local/bin/code

Now in any directory, type code and your text editor opens. Even better, type code . and it opens that directory, ready for editing.

6.3: wslview command

If you are used to using the open command in a terminal on macOS, the equivalent command for WSL is wslview. If you wish to use open in the same way, you can add the following to the end of your ~/.bashrc:

# open to match macOS-style use
alias open=/usr/bin/wslview

Now you can use open like you would in macOS.

7. Disable ding/beep/bell sound when tabbing

You know that annoying bell sound you get when you try to autocomplete something and it doesn’t exist? It’s super loud and annoying, so lets mute it. Run this command and restart your shell to give peace to your ears:

echo 'set bell-style none' >> ~/.inputrc

Restart your shell and it’s quiet :)

8. How to configure proxy settings in apt

If your network uses a proxy-server, services like apt-get, git, wget, and curl, etc. would not be able to access internet directly.

There is an open source tool : ProxyMan, which lets you easily configure system-wide proxy settings from the command-line in one go. Download latest release.
As of now, ProxyMan is capable of managing GNOME desktop, /etc/environment, .bashrc, apt.conf, git, npm, and Dropbox proxy settings

However, you can also manually modify the configuration file.

To add prox in apt, modify /etc/apt/apt.conf and add the following:

   Acquire::http::Proxy "http://username:password@proxy.server:port";
   Acquire::https::Proxy "https://username:password@proxy.server:port";
   Acquire::ftp::Proxy "ftp://username:password@proxy.server:port";
   Acquire::socks::Proxy "socks://username:password@proxy.server:port";

Do a sudo apt-get update afterwards to update repository infromation

Example:

username: johnwick password password proxy-server proxy.foobar.com port 8080

Acquire::http::Proxy "http://johnwick:password@proxy.foobar.com:8080";

To add system wide proxy settings, go to /etc/environment and add the following:

   export http_proxy="http://username:password@proxy.server:port"
   export https_proxy="https://username:password@proxy.server:port"
   export ftp_proxy="ftp://username:password@proxy.server:port"
   export socks_proxy="socks://username:password@proxy.server:port"

Example:

export http_proxy="http://johnwick:password@proxy.foobar.com:8080";

Use source /etc/environment to load the new environment variables.

To make git work behind proxy use the following commands

git config --global http.proxy http://johnwick:password@proxy.foobar.com:8080`
git config --global https.proxy https://johnwick:password@proxy.foobar.com:8080

9. Program compatibility — What works, what doesn’t?

This crowdsourced list of programs and their compatibility gives you a searchable list for compatibility. Want to know if apt works 100%? Just check the list. Also worth a mention, the Official repository contains a full list of all issues reported.

10. Mapping a Driver Letter to your linux root folder

Open a Windows Terminal (cmd) and:

subst l: c:Userspathtoyourrootfs

Now you can access the root linux folder typing l: in the Windows Command, or Explorer.

Your rootfs might be located in different paths: Check this guide on askubuntu to find your linux folder on windows

Недавно мы говорили о том, как выполнять различные Linux утилиты в Windows. Но для Windows 10 это, похоже, уже неактуально. Уже давно в Windows 10 появилась нативная поддержка оболочки Bash, в окружении дистрибутива Ubuntu благодаря подсистеме Linux для Windows 10.

Вы можете запускать различные дистрибутивы Linux в Windows без виртуализации, а с недавних пор, можно даже полноценно заставить работать графический интерфейс, правда для этого уже нужна вторая версия WSL. В этой статье мы рассмотрим как установить Linux в Windows 10.

Что такое WSL?

В начале цикла разработки Windows 10, Microsoft открыла страницу обсуждения и голосования за новые функции. Там зашел разговор о командной строке Windows. Разработчики спросили сообщество, что им не нравится в командной строке Windows и какие функции они хотели бы увидеть в новой версии.

Многие пользователи заявили что им нужны небольшие улучшения командной строки, другие же сказали что неплохо было бы иметь возможность использовать инструменты Linux / Unix и Bash в Windows 10. Много пользователей согласились с тем, что нужно сделать проще использование этих инструментов в Windows.

Прислушиваясь к голосу сообщества, в Microsoft первым делом улучшили CMD, PowerShell и другие инструменты командной строки. А во-вторых, они сделали, то что казалось невероятным несколько лет назад, они добавили реальный, нативный Bash вместе с поддержкой всех необходимых инструментов командной строки, работающих непосредственно на Windows, в среде, которая ведет себя как Linux. Это не какая-нибудь виртуальная машина, это реальный Linux в Windows.

Для реализации этого Microsoft построили новую инфраструктуру в Windows, это Windows Subsystem for Linux или WSL, на основе которой работает образ окружения Ubuntu, поставляемый партнером Canonical. Эта функция позволит разработчикам более эффективно использовать инструменты Linux. Инфраструктура основана на уже заброшенном проекте, Project Astoria, который должен был использоваться для запуска Android-приложений в Windows. Ее можно расценивать как противоположность Wine, только Wine запускает приложения Windows в Linux, подсистема Linux позволяет выполнять приложения Linux в Windows, точнее, только консольные приложения Bash в Windows 10.

С технической точки зрения, это вообще не Линукс. Каждая система GNU Linux должна быть основана на ядре Linux, здесь же просто есть возможность выполнять двоичные файлы, которые работают в Ubuntu.

С каждой новой версией  в WSL всё меньше ограничений, вы уже можете использовать сервисы, а также с WSL 2 стали доступны графические приложения. Решение предназначено для разработчиков, которые хотят запускать linux-утилиты из командной строки Windows. Да, эти команды имеют доступ к файловой системе Windows, но вы не можете использовать их для автоматизации своих задач или в стандартной командной строке Windows. Теперь давайте разберемся как установить WSL в Windows 10.

1. Проверка версии системы

Вы можете установить WSL в Windows 10 начиная с версии Windows 10 Insider Preview 14316, а для WSL версии 2, которая принесла много улучшений нужно обновление Windows 10 19041 или новее. Сначала убедитесь, что у вас правильная версия Windows. Для этого октройте PowerShell кликнув правой кнопкой по иконке пуск:

Затем выполните команду:

[environment]::osversion

Если отображается версия как на снимке экрана или выше, значит всё хорошо. Иначе идите обновлять систему.

2. Активация WSL и виртуализации

Чтобы активировать компонент Windows Subsystem for Linux можно использовать уже открытую командную строку PowerShell. Для этого выполните:

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

Затем выполните ещё одну команду чтобы включить компонент виртуализации Hyper-V:

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

Когда эта работа будет выполнена перезапустите компьютер, чтобы все компоненты установились.

3. Активация WSL 2

Чтобы установить WSL 2 необходимо скачать пакет с новым ядром с официального сайта Microsoft. Кликните по ссылке download the latest WSL2 Linux kernel:

Затем установите загруженный файл:

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

wsl --set-default-version 2

Если вы всё же получаете ошибку, с сообщением о том, что такой опции у этой команды нет, значит у вас старая версия Windows, обновляйте. Если команда не выдала ошибки — значит настройка WSL завершена успешно.

4. Установка Linux

Далее вам надо установить какой-либо дистрибутив Linux из магазина Microsoft. Достаточно просто открыть магазин и набарть в поиске имя дистрибутива, например Ubuntu, затем нажмите кнопку Get:

Дождитесь завершения установки и запустите загруженный дистрибутив из главного меню:

5. Настройка дистрибутива

При первом запуске будет выполняться настройка окружения. Вам необходимо указать имя пользователя:

Затем два раза пароль:

После этого вы сможете пользоваться оболочкой Bash в Windows 10:

6. Установка X сервера

Если вы хотите запускать графические приложения из WSL Windows, то вам понадобится установить в систему X сервер. Скачать его можно здесь.

Затем просто установите.

7. Запуск X сервера

После завершения установки на рабочем столе появится ярлык. В первом окне выберите Multipe windows чтобы окна программ, выполняемых на X сервере интегрировались в систему:

Затем выберите, что клиентов запускать не надо — Start no client:

Поставьте все галочки, затем нажмите кнопку Next, а потом Finish для завершения установки.

Брандмауэр Windows тоже попросит разрешить доступ этому приложению в сеть. Надо разрешить.

8. Настройка подключения

Чтобы настроить подключение к X серверу из WSL нужно узнать какой адрес система Windows присвоила WSL окружению, для этого вернитесь к PowerShell и выполните:

ipconfig

В данном случае это 172.25.224.1. Выполните в окружении дистрибутива такую команду:

export DISPLAY=172.25.224.1:0

Шаг 9. Установка и запуск приложений

Для установки приложений в дистрибутив необходимо сначала обновить списки репозиториев:

sudo apt update

Затем установите графическое приложение, например, Firefox:

sudo apt install firefox

После этого его можно запустить:

firefox

На снимке вы видите графический интерфейс WSL для браузера Firefox, запущенного в Linux:

Использование WSL

Установка WSL Windows 10 завершена. Теперь у вас есть полноценная командная строка Ubuntu в Windows с оболочкой Bash. Поскольку используются одни и те же двоичные файлы, вы можете устанавливать программное обеспечение с помощью apt из репозиториев Ubuntu. Можно установить любое приложение, но не все будут работать.

Если вы раньше уже пользовались Bash в Linux или MacOS, то будете чувствовать себя здесь как дома. Здесь не нужно использовать команду sudo, поскольку у оболочки уже есть права администратора. Ваша файловая система Windows доступна в /mnt/c.

Для управления и перемещения по каталогам используйте те же команды что и в Linux. Если вы привыкли к стандартной оболочке Windows, то вот основные команды, которые вам могут понадобится:

  • cd — изменить текущий каталог;
  • ls — посмотреть содержимое каталога;
  • mv — переместить или переименовать файл;
  • cp — скопировать файл;
  • rm — удалить файл;
  • mkdir — создать папку;
  • vi или nano — открыть файл для редактирования.

Важно также понимать, что в отличии от WIndows, оболочка Bash и ее окружение чувствительны к регистру. Другими словами, file.txt и File.txt, это совсем разные файлы.

Для установки и обновления программ необходимо использовать команду apt-get. Вот небольшой список ее  параметров:

  • apt update — скачать списки программного обеспечения из репозиториев;
  • apt install пакет — установить пакет;
  • apt search слово — поиск пакета по слову;
  • apt upgrade — загрузка и установка последних обновлений дистрибутива.

Не забудьте, что устанавливаемые в этой оболочке программы, ограничиваются по области действия оболочкой. Вы не можете получить доступ к ним из обычной командной строки PowerShell, CMD или в любом другом месте Windows. Также WSL не может напрямую взаимодействовать с исполняемыми файлами Windows, хотя обе среды имеют доступ к одним и тем же файлам на компьютере.

Выводы

Использование Linux в Windows как нельзя лучше подойдёт для разработчиков, но может понадобиться и начинающим пользователям, которые хотят познакомиться с системой. А что вы обо всём этом думаете? Использовали ли когда-нибудь WSL? Напишите в комментариях!

Creative Commons License

Статья распространяется под лицензией Creative Commons ShareAlike 4.0 при копировании материала ссылка на источник обязательна .

Download PC Repair Tool to quickly find & fix Windows errors automatically

Before we get on to see how to run Bash on Ubuntu on Windows, here’s a little bit on the amazing step by Microsoft to integrate user mode Linux and its tools into Windows OS. Who would have thought one would be running native Bash directly on Windows.

At the start of Windows 10 cycle, Microsoft opened an user-voice page and started a conversation about the Windows command-line. They asked the community what they like about Windows command line and what features they would like to see in Windows command-line.

Many in the community replied that they would like to see some improvements to Windows Command line.  Some others said they would like to bring Linux/Unix tools to Windows. As working with open-source tools on Windows is often a struggle users said that they would like Microsoft to make it easier to use these tools on Windows.

Listening to the community voice, Microsoft first improved CMD, PowerShell and many other Windows command-line tools and secondly did what was unbelievable few years back. Microsoft decided to add real, native Bash and with it support for Linux command-line tools which run directly on Windows in an environment that behaves like Linux! Its not any VM but the real Linux on Windows.

Windows Subsystem for Linux

For this Microsoft built new infrastructure within Windows – the Windows Subsystem for Linux (WSL) upon which  genuine Ubuntu user-mode image is run provided by its partner Canonical, creators of Ubuntu Linux.

This will make Windows developers far more productive and use these tools much more seamlessly. And this will be a long term solid, reliable and stable solution.

Here is what Mark Shuttleworth, founder of Canonical said:

“In our journey to bring free software to the widest possible audience, this is not a moment we could have predicted. Nevertheless, we are delighted to stand behind Ubuntu for Windows, committed to addressing the needs of Windows developers exploring Linux in this amazing new way, and are excited at the possibilities heralded by this unexpected turn of events.”

What is Bash in Linux

For those who do not know, Bash or Bourne Again shell is a standard GNU Linux Shell program.

According to Wikipedia, Bash is a Unix shell and command language for the GNU Project as a free software replacement for the Bourne shell. it has been distributed widely as the shell for the GNU operating system and as a default shell on Linux and OS X.

Starting with Windows 10 Insider Preview Build 14316, Windows Subsystem for Linux has been provided. Starting with this build, one can run native Bash on Ubuntu in Windows. This was first announced at Build 2016. This is how one does it.

  • First one has to turn on Developers Mode from

    • Settings > Update & Security > For Developers. Check the Developer Mode radio button. And search for “Windows Features”  , choose “Turn Windows features on or off”.  How to run Bash on Ubuntu on Windows 11/10

    • Select “Windows Subsystem for Linux (Beta)” . Press OK.  How to run Bash on Ubuntu on Windows 11/10

    •  It will start searching for the required files and starts applying changes. Once done, one has to reboot to finish installing the requested changes. Press Restart now.  BashOnWindows03

  • Once rebooted, from the Start button right click and open Command Prompt (Admin)  or PowerShell.

    • Type “bash” at command prompt and Enter. You’ll get a message “This will install Ubuntu on Windows, distributed by Canonical and…” . Type “y” to continue. Press ‘y’ and your download from the Windows Store starts. After downloading, it will start extracting the file system. This will take some time, so be patient. How to run Bash on Windows 10

    • After sometime you’ll get the message “Installation Successful! The environment will start momentarily…” and you’ll be at the Bash prompt. run Bash on Ubuntu on Windows 10

  • From here on , now you can run Bash scripts, Linux command-line tools like sed, awk, grep and you can even try Linux-first tools like Ruby, Git, Python, etc. directly on Windows. One can also access Windows filesystem from within Bash. BashOnWindows06

  • After installing, it’ll also be listed in the App list. So that one can open All apps and click on “Bash on Ubuntu on Windows” to open Bash prompt.BashOnWindows07

Remember, this is a developer toolset to help you write and build all your code for all your scenarios and platforms. This is not a server platform upon which you will host websites, run server infrastructure, etc.

As this being one of the coolest thing to happen to Windows, one must give it a try if you are interested about Linux, Ubuntu on Windows.

Source: Windows.com.

You can also check out this video tutorial by Scott Hanselman:

How do I open Bash on Ubuntu in Windows 11/10?

To open Bash on Ubuntu in Windows 11 or Windows 10, you need to install it first. Before that, you need to install the Windows Subsystem for Linux, which you can do from the Windows Features panel. Following that, open a Command Prompt window and enter the bash command. Let it finish the installation process to open the Bash on Ubuntu.

How do I run Ubuntu shell on Windows?

To run Ubuntu shell on Windows 11 or Windows 10, you need to install the Windows Subsystem for Linux first. Then, you can enter the bash command to install the Bash on Ubuntu. Once the installation is done, you can run the Bash on Ubuntu on Windows.

Visit his blog for additional information.

Ezoic

The author has been a Microsoft MVP awardee in various Windows categories (2006-2016) and currently a Windows Insider MVP. A Technology Enthusiast, interested in anything technical and is committed to Microsoft technologies and products. He is actively associated with various Microsoft online communities, forums, Newsgroups and has been actively involved in Beta testing various Microsoft products and bug submissions.

Понравилась статья? Поделить с друзьями:
  • Bash npm command not found windows
  • Bash make command not found windows
  • Bash java command not found windows
  • Bash gulp command not found windows
  • Bash cmake command not found windows