How to Install Linux Bash Shell on Windows
One of the nicest things added in the recent Windows 10 feature updates is the Windows Subsystem for Linux. Thanks to WSL, you can run Linux Bash commands inside a Command Prompt window. This requires fewer resources than a full virtual machine and has a built-in integration with Windows file system. It’s not enabled by default, but if you would like to try it, just follow this guide.
This feature requires a 64-bit version of Windows 10 and the procedure differs depending on the OS Build number. You can check your version in Settings / System / About or just click the Windows menu, type
winver and press enter.
Fall Creators Update and later
You need OS Build 16215 or later.
1. In the Windows menu, start typing Turn Windows features on or off, run it and turn on Windows Subsystem for Linux.
You can also right-click on Windows menu, select Windows PowerShell (Admin) and execute this command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
2. Restart Windows
3. Select your prefered distribution from the Windows Store: Ubuntu 16.04 LTS, openSUSE or SUSE Linux Enterprise Server. UPDATE: now you can choose Debian, Kali Linux and Ubuntu 18.04 LTS too. Click Get and then Launch. A console window will pop up.
4. Create your UNIX user account. This can be different from your Windows user login and password and will be used for sudo command.
Creators Update and earlier
If you haven’t yet installed Fall Creators Update, the procedure is a bit different.
1. In the Windows menu, start typing Turn Windows features on or off, run it and turn on Windows Subsystem for Linux (Beta).
2. Restart Windows
3. Go to Settings / Update and Security, turn on Developer Mode.
4. Open a Command Prompt window and type:
5. Accept the licence. This will download and install Ubuntu distribution.
bash in another Command Prompt window and create a UNIX user. This can be different from your Windows user login and password and will be used for sudo command.
After installation, it is a good idea to refresh repository index and upgrade all packages. For Ubuntu:
sudo apt update sudo apt upgrade sudo apt autoremove
Install the Midnight Commander for easy filesystem navigation:
sudo apt install mc
To install standard compilers like gcc and g++:
sudo apt install build-essential
If you need Python:
sudo apt install python-dev
You may want to use Git too:
sudo apt install git
To enter Bash mode, type in a Command Prompt window:
You can also use distribution names like
sles-12. Another option is to use an icon in the Windows start menu.
To end your current session:
You can mix Windows and Linux commands in Command Prompt:
C:\Users\lazarus>bash -c "ls /" bin dev home lib media opt root sbin srv tmp var boot etc init lib64 mnt proc run snap sys usr
Similarly, you can run Windows apps while you’re in Bash session:
[email protected]:/$ /mnt/c/Windows/System32/notepad.exe
Access to files
All the Windows local drives will be mounted under the
/mnt folder. To view a file located at
D:\file.txt simply type:
You can find Linux system files in a location similar to this one:
%localappdata%\lxss\ for older OS builds), but you should not change them using Windows programs. As they will not handle Linux permissions properly, this will corrupt them. The only allowed operation is deletion.
Windows Subsystem for Linux doesn’t support Graphical User Interface applications, you cannot start an X server and use Gnome or KDE. Running web services is also not recommended. If you need such features, use Virtual Box to host your favourite Linux distribution inside it.
…well, unless you really want to. The previous paragraph is based on the official information from Microsoft. You can get around this and install an X server on Windows. One of them is Xming X Server for Windows. Then, all you need to do inside WSL is to set an environment variable for Bash session:
This way GUI applications will redirect their display output to your X server on Windows.
Some programs will throw warnings, some may crash. If this happens, it simply means that something is not yet supported in WLS. Your mileage may vary, but if you install
sudo apt install gvim
they will work just fine. I even checked
darktable, an open-source alternative to Lightroom, and it also seems to work:
As WSL is developed with other goals in mind (i.e. command-line tools), this little “hack” is just a proof of concept. But, if you have some Linux app that hasn’t been ported to Windows yet and there are no better alternatives, then give it a try.
Sometimes, after issuing the
bash command, Windows may reply:
Windows Subsystem for Linux has no installed distributions. Distributions can be installed by visiting the Microsoft Store: https://aka.ms/wslstore Press any key to continue...
You can check the installed distributions:
wslconfig /l Windows Subsystem for Linux Distributions: Ubuntu-18.04 (Default)
But WSL can display “no installed distributions” message again, even if you are pretty sure that there is at least one distro installed.
The solution is to restart LxssManager service. Run
services.msc, find it on the list and restart it.
If you would like to uninstall Windows Subsystem for Linux, you can do this in Settings / Apps. Look for Linux distribution name (e.g. Ubuntu). For older OS builds, type in a Command Prompt:
lxrun /uninstall /full
If your tools require Linux environment or have Linux-specific dependencies, then WSL may be a very useful solution. Also, with a bit of additional setup, you can even run Windows and Linux GUI programs side by side.
Comments are automatically closed on articles older than 512 days.