Bash is the command-line interface for Linux distributions like Ubuntu, CentOS, Debian, Mint, Kali, RedHat, Fedora, etc. Bash provides a lot of different type of commands and tools to manage a Linux system. In this tutorial, we will learn how to install Bash on a Windows operating system like Windows 10.
What Is Bash?
Bash is the most popular shell or command line used in Linux distributions. Bash alternatives are Sh, KornShell, CShell etc. Bash is the short form of the GNU Bourne-Again Shell and created in 1989 by the GNU supporter Free Software Foundation (FSF).
Windows Subsystem for Linux (WSL)
Containers are a new era of the Virtualization where provides less resource usage and less complexity. Containers provide isolated environments for applications, processes, files, etc like a virtual system. Docker is the most known and popular containerization system. Windows also started full and complete container usage on Windows for Linux. It is called Windows Subsystem for Linux (WSL). Which means the Linux operating system calls and standards are provided as a container on a Windows operating system. WSL is currently supported by the modern Windows operating systems like Windows 10 and Windows Server 2016 and 2019.
In order to install Bash on Windows, we will enable the WSL and download a Linux container image like Ubuntu, SUSE, etc from Microsoft store. Then we will run this container from the Windows command line MS-DOS or PowerShell.
Enable Windows Subsystem For Linux
First, we will enable or install Windows Subsystem For Linux (WSL) with the PowerShell. We need
Administrative features enabled by running
Start Menu where we will right-click and then select
Run as administrator.
We will run the following
Enable-WindowsOptionalFeaturecommand in order to install and enable
PS> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
We will be asked is we want to restart the computer after the installation is complete. We will answer
This will restart the system automatically in order to start the Windows with the WSL enabled.
Download Linux Image/Distributions From Windows Store
In order to run bash, we have to download a Linux image/distributions which will provide the bash shell. Linux distributions can be downloaded from the
Microsoft Store like below. We can access Microsoft Store from start menu with
Microsoft Store keyword.
We will write
linux to the search box and search. Alternatively, if we are looking for a specific Linux
The search results for the Linux container will be listed like below. We can see that Linux distributions like Kali, Ubuntu, Debian, Suse, etc. Following information also provided with the search results.
- `Popularity` provides the count of the rating provided the given Linux distribution image.
- `Rating` is the provided points or starts for the given Linux distribution.
- `Supported Systems` shows which environments can run given Linux image like Computer, Phone etc.
- `Price` is generally zero but used to show the price of the given Linux image.
We will select the Linux distribution like Kali, Ubuntu, Debian, SUSE like below just click them. In this example, we will select the Ubuntu image with the latest version.
Ubuntu 18.04 LTS can be downloaded to for Lon Term Support.
During the download, the download status will be shown in the header like below. We can see that the Ubuntu image is about 221 MB and downloaded very fast.
Launch Bash From Microsoft Store
When the download is complete we can launch Ubuntu container from the Microsoft Store from the
Launch button like below.
We will see following bash shell where it is initialized for the first run. As it says it may take a few minutes to see the shell.
Before starting to use bash we will be asked some basic questions like the username and password which will set. In this example, we set the username
ismail. The password is not shown for security reasons. We see that the hostname part of the bash shell is the name of the computer which is
DESKTOP-HQVAMA3 and the user name is
Start Bash From MS-DOS and PowerShell
We can also start the Bash from the command line. MS-DOS or PowerShell can be used to start bash shell with the
bash command like below.
Run Bash Commands On Windows
We can run any Linux bash command on Windows like below. In this part, we will run commands like
$ whoami $ ping poftut.com $ uname -a $ cat /etc/lsb-release
Access Windows Drives C:\ , D:\
After starting the bash on Windows we may need to access Windows partitions like C:\ , D:\, and the users
Documents and Settings folders. These partitions and folders are mounted in
/mnt directory with their partition names. In this following example, we see the folders are listed in the
$ cd /mnt $ cd c