windows linux power shell

本教程介绍如何在Windows10上安装Linux Bash Shell,利用Windows子系统为Linux(WSL),用户可以在不使用虚拟机的情况下运行Linux命令。文章详细讲解了在新旧版本Windows10中启用此功能的步骤。

You are here: Home / Tutorial / How to Install Linux Bash Shell on Windows 10

How to Install Linux Bash Shell on Windows 10

Last updated July 20, 2019 By Abhishek Prakash 44 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. But before we go on installing Bash on Windows, let me tell you a little more about it.

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 Fall Creator’s Update 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 10 Linux subsytem. 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 Subsyetm for Linux feature from PowerShell.

Go to the Start menu and search for PowerShell. Run it as administrator:

Enable Windows subsytem for Linux

Once you have the PowerShell running, use the command below to enable Bash in Windows 10.

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

You’ll be asked to confirm your choice. Type Y or press enter:

Enable Windows subsytem for Linux

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.”

Search for Linux in Windows 10 Store

You’ll see the option to install Ubuntu or SUSE. I have installed Ubuntu for Bash on Windows here.

Install Windows Subsyetm for Linux

What’s the difference between using Ubuntu or openSUSE or SUSE Linux Enterprise? And which one should you use?

If that’s your question then perhaps you don’t know much about Linux distributions. 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. So you should have a good internet connection here.

Install Ubuntu from Windows Store

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.

Using Bash on Windows 10

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:

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 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 though.

Installing Linux Bash Shell on Older Windows 10 (Click to expand)

I hope you find this tutorial helpful for installing bash on Windows 10. It lets you play with Linux inside of Windows. If you have questions or suggestions, feel free to ask.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值