如何在Windows 10上下载并安装Linux Bash Shell?_cunjiu9486的博客-程序员秘密

技术标签: ubuntu  linux  操作系统  windows  docker  

Bash is the command-line interface for Linux distributions like Ubuntu, CentOS, Debian, Mint, Kali, RedHat, Fedora, etc. Bash provides a lot of different types 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.

Bash是Linux发行版的命令行界面,如Ubuntu,CentOS,Debian,Mint,Kali,RedHat,Fedora等。Bash提供了许多不同类型的命令和工具来管理Linux系统。 在本教程中,我们将学习如何在Windows 10等Windows操作系统上安装Bash。

什么是Bash? (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).

Bash是Linux发行版中最流行的shell或命令行。 Bash的替代品包括Sh,KornShell,CShell等。Bash是GNU Bourne-Again Shell的简称,由GNU支持者自由软件基金会(FSF)于1989年创建。

What Is  Bash?
What Is  Bash?
什么是Bash?

Windows Linux子系统(WSL) (Windows Subsystem for Linux (WSL))

Containers are a new era of 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). This 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.

容器是虚拟化的新纪元,在此时代,资源使用量减少,复杂性降低。 容器为应用程序,进程,文件等(如虚拟系统)提供隔离的环境。 Docker是最著名和最受欢迎的容器化系统。 Windows还开始在Windows for Linux上完全使用和完全使用容器。 它称为Linux的Windows子系统(WSL)。 这意味着Linux操作系统调用和标准作为Windows操作系统上的容器提供。 当前,现代Windows操作系统(例如Windows 10和Windows Server 2016和2019)支持WSL。

Bash安装 (Bash Installation)

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.

为了在Windows上安装Bash,我们将启用WSL并从Microsoft商店下载Linux容器映像,例如Ubuntu,SUSE等。 然后,我们将从Windows命令行MS-DOS或PowerShell运行此容器。

为Linux启用Windows子系统 (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 PowerShell from Start Menu where we will right-click and then select Run as administrator.

首先,我们将使用PowerShell启用或安装Linux的Windows子系统(WSL)。 我们需要通过从Start Menu运行PowerShell来启用Administrative功能,在该Start Menu上单击鼠标右键,然后选择Run as administrator

Enable Windows Subsystem For Linux
Enable Windows Subsystem For Linux
为Linux启用Windows子系统

We will run the following Enable-WindowsOptionalFeaturecommand in order to install and enable Microsoft-Windows-Subsystem-Linux feature.

我们将运行以下Enable-WindowsOptionalFeature命令以安装并启用Microsoft-Windows-Subsystem-Linux功能。

PS> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable Microsoft-Windows-Subsystem-Linux
Enable Microsoft-Windows-Subsystem-Linux
启用Microsoft-Windows-子系统-Linux

We will be asked is we want to restart the computer after the installation is complete. We will answer Y.

系统将询问我们是否要在安装完成后重新启动计算机。 我们将回答Y

Restart The Computer
Restart The Computer
重新启动电脑

This will restart the system automatically in order to start the Windows with the WSL enabled.

为了启动启用了WSL的Windows,这将自动重新启动系统。

从Windows Store下载Linux映像/发行版 (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.

为了运行bash,我们必须下载将提供bash shellLinux映像/发行版。 可以从Microsoft Store下载Linux发行版,如下所示。 我们可以使用Microsoft Store关键字从开始菜单访问Microsoft Store。

Download Linux Image/Distributions From Windows Store
Download Linux Image/Distributions From Windows Store
从Windows Store下载Linux映像/发行版

We will write linux to the search box and search. Alternatively, if we are looking for a specific Linux

我们将linux写入搜索框并进行搜索。 或者,如果我们正在寻找特定Linux

Search Linux Images
Search Linux Images
搜索Linux映像

The search results for the Linux container will be listed below. We can see that Linux distributions like Kali, Ubuntu, Debian, Suse, etc. The following information also provided with the search results.

Linux容器的搜索结果将在下面列出。 我们可以看到Linux发行版,例如Kali,Ubuntu,Debian,Suse等。以下信息也随搜索结果提供。

  • Popularity provides the count of the rating provided the given Linux distribution image.

    Popularity提供了给定Linux发行映像所提供的等级计数。

  • Rating is the provided points or starts for the given Linux distribution.

    Rating是给定Linux发行版提供的分数或起点。

  • Supported Systems shows which environments can run given Linux image like Computer, Phone, etc.

    Supported Systems显示了可以在给定Linux映像(例如计算机,电话等)下运行的环境。

  • Price is generally zero but used to show the price of the given Linux image.

    Price通常为零,但用于显示给定Linux映像的价格。

WSL Linux Images List
WSL Linux Images List
WSL Linux映像列表
WSL Ubuntu Image
WSL Ubuntu Image
WSL Ubuntu映像

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 for Lon Term Support.

我们将选择如下所示Linux发行版,如Kali,Ubuntu,Debian,SUSE,如下所示。 在此示例中,我们将选择最新版本的Ubuntu映像。 可以下载Ubuntu 18.04 LTS以获得长期支持。

WSL Ubuntu Image Download
WSL Ubuntu Image Download
WSL Ubuntu映像下载

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.

在下载过程中,下载状态将显示在下面的标题中。 我们可以看到Ubuntu映像约为221 MB,并且下载速度非常快。

WSL Ubuntu Image Download
WSL Ubuntu Image Download
WSL Ubuntu映像下载

从Microsoft Store启动Bash(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.

下载完成后,我们可以通过如下所示的“ Launch按钮从Microsoft Store启动Ubuntu容器。

Launch Ubuntu Container On Windows
Launch Ubuntu Container On Windows
在Windows上启动Ubuntu容器

We will see the following bash shell where it is initialized for the first run. As it says it may take a few minutes to see the shell.

我们将看到以下bash shell,其中该bash shell在首次运行时被初始化。 就像说的那样,可能需要几分钟才能看到外壳。

Ubuntu Shell
Ubuntu Shell
Ubuntu 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 ismail.

在开始使用bash之前,我们将被询问一些基本问题,例如将设置的用户名和密码。 在此示例中,我们将用户名设置为ismail 。 出于安全原因,未显示密码。 我们看到bash shell的主机名部分是计算机的名称,它是DESKTOP-HQVAMA3 ,用户名是ismail

Linux Bash Shell On Windows 10
Linux Bash Shell On Windows 10
Windows 10上Linux Bash Shell

从MS-DOS和PowerShell启动Bash (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.

我们也可以从命令行启动Bash。 可以使用MS-DOS或PowerShell通过如下所示的bash命令启动bash外壳。

> bash

OR

要么

PS> bash
Start Bash From MS-DOS
Start Bash From MS-DOS
从MS-DOS启动Bash
Start Bash From PowerShell
Start Bash From PowerShell
从PowerShell启动Bash

在Windows上运行Bash命令 (Run Bash Commands On Windows)

We can run any Linux bash command on Windows like below. In this part, we will run commands like ping, uname , lsb-release.

我们可以在Windows上运行任何Linux bash命令,如下所示。 在这一部分中,我们将运行pingunamelsb-release类的命令。

$ whoami

$ ping poftut.com

$ uname -a

$ cat /etc/lsb-release
Run Bash Commands On Windows
Run Bash Commands On Windows
在Windows上运行Bash命令

访问Windows驱动器C:\,D:\(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 C:\ partition.

在Windows上启动bash之后,我们可能需要访问Windows分区,例如C:\,D:\,以及用户的Documents and Settings文件夹。 这些分区和文件夹及其分区名称挂载在/mnt目录中。 在下面的示例中,我们看到文件夹在C:\分区中列出。

$ cd /mnt

$ cd c
Access Windows Drives C:\ , D:\ 
Access Windows Drives C:\ , D:\
访问Windows驱动器C:\,D:\
LEARN MORE  How To Check If File Exists In Linux Bash?
了解更多如何检查Linux Bash中是否存在文件?

翻译自: https://www.poftut.com/how-to-download-and-install-linux-bash-shell-on-windows-10/

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/cunjiu9486/article/details/109077601

智能推荐

Spark在Windows下idea中本地调试及Jar方式集群运行_一个jar集群运行在windows下_翱翔的江鸟的博客-程序员秘密

1. Windows本地调试依赖包版本(Maven下载),scope模式为complie<properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><spark.version>2.2.0</spark.version><s...

python 求数组a 的最大值和最小值_2021乐乐的博客-程序员秘密

>>> a=[1,2,3,4,5,6,7,8,98,9]>>> print(max(a))98>>> print(min(a))1>>>

ASP.NET MVC4 用户登录验证_u014180504的博客-程序员秘密

文件结构:主要核心代码:View/AdminLogin代码:<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %><!DOCTYPE html><html><head runat="server"> <meta name="viewport" content="width=device-width" /> <title>AdminLogin</title> <link href="..

集成第三方-支付宝那些事_weixin_33832340的博客-程序员秘密

这两天,在移动APP上集成了支付宝支付功能,费了一些周折,除了其他博客上提到的一些问题,这里分享一下自己的经验Android客户端代码集成1、准备a 注册支付宝商家账号b 开通移动支付功能c 生成RSA私钥和公钥,上传自己的公钥给支付宝 官网方法2、类库下载支付宝demo下载,将alipaysdk.jar放到自己的项目中。...

NUC980开发板DIY项目大挑战:室内环境采集监测系统_nucwriter_RT-Thread物联网操作系统的博客-程序员秘密

本文由RT-Thread论坛用户@纯白酱原创发布:https://club.rt-thread.org/ask/article/75b0b1edc9ec7289.html#项目描述使用新唐公司的NUC980,开发一款室内环境监测平台。采集端通常位于家庭中的室内,采集传感器数据,如温湿度数据,光照数据,空气质量数据等,读取完成后,打包成json格式的数据,通过以太网,使用http post方式传输传感器数据。#设备清单主控板:NUC980-IOT传感器扩展板:板载多种传感器,基于立创EDA制作,已开

ubuntu编译安装opencv3.3+python3,解决ippicv下载问题_opencv-python ippicv_neilooo的博客-程序员秘密

2018.01.11更新如果只是要在python用opencv,那么下面重新编译的方法真的太蠢了,可以用pip直接安装。真不明白为什么那么多博客都是教怎么编译源码,就这么简单一句话。$ sudo pip3 install opencv_python参考opencv官网https://opencv.org/opencv源码下载下载opencv3.3源码https://open

随便推点

JavaScript:事件、属性_微凉128的博客-程序员秘密

一、事件HTML 事件是发生在 HTML 元素上的事情。当在 HTML 页面中使用 JavaScript 时, JavaScript 可以触发这些事件。事件通常与函数配合使用,这样就可以通过发生的事件来驱动函数执行。1、鼠标移入移出事件(1)onmouseover 和 onmouseoutonmouseover:在鼠标指针移动到元素上时触发onmouseout :在鼠标指针移出元素后触发(2)onmouseenter 和 onmouseleaveonmouseenter:在鼠标指

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException异常产生的原因及解决办法_「已注销」的博客-程序员秘密

SQL语句错误:注意SQL语句格式是否正确;注意SQL语句的符号是否是英文(误写成中文符号);注意SQL语句拼接时,内容前后是否缺少空格,以保持SQL语句的正确性;...

大数据高频面试题-Sqoop参数_sqoop的个数取决于_Mr.光铭的博客-程序员秘密

4.8 Sqoop参数4.8.1 Sqoop导入导出Null存储一致性问题 4.8.2 Sqoop数据导出一致性问题 4.8.3 Sqoop底层运行的任务是什么 4.8.4 Sqoop数据导出的时候一次执行多长时间4.8.0Sqoop参数/opt/module/sqoop/bin/sqoop import \--connect \--username \--password \--target-dir \--delete-target-dir \--num-...

《从0到1:CTFer成长之路》书籍配套题目-[第二章 web进阶]文件上传_从0到1ctfer成长之路文件上传练习题_一个平凡de人的博客-程序员秘密

[第二章 web进阶]文件上传开始行动绕过第1个限制绕过第2个限制介绍:记录一下笔记,方便以后迅速回忆使用。《从0到1:CTFer成长之路》书籍配套题目,来源网站:《从0到1:CTFer成长之路》先看一下题目源码:&lt;?phpheader("Content-Type:text/html; charset=utf-8");// 每5分钟会清除一次目录下上传的文件require_once('pclzip.lib.php');if(!$_FILES){ echo '

对stm32程序(HEX)的读取和烧录(使用JLink和JFlash)_stm32程序可以读出来吗_吴禅染的博客-程序员秘密

本文主要讲解:使用J-LinK仿真器,借助于J-Flash软件,如何读取现有的stm32内部的程序(HEX文件),并烧录到另一台新的stm32中。(前提是原stm32未进行加密处理)先介绍下载器J-LinK和 软件J-Flash:上一篇介绍了 J-LinK-OB改造版 仿真/调试器 使用说明:J-LinK-OB改造版 仿真/调试器 使用说明_m0_46511220的博客-程序员秘密https://blog.csdn.net/m0_46511220/article/details..

推荐文章

热门文章

相关标签