如何在Windows 10的Ubuntu Bash Shell中安装Linux软件

如何在Windows 10的Ubuntu Bash Shell中安装Linux软件_第1张图片

Install Windows 10’s Ubuntu-based Bash shell and you’ll have a complete Ubuntu environment that lets you install and run the same applications you could run on an Ubuntu-based Linux system. Just like on Ubuntu, though, you’ll need the apt-get command to install and update software.

安装Windows 10的基于Ubuntu的Bash shell ,您将拥有一个完整的Ubuntu环境,可让您安装和运行与在基于UbuntuLinux系统上运行的应用程序相同的应用程序。 就像在Ubuntu上一样,您将需要apt-get命令来安装和更新软件。

Note that Windows 10’s Linux subsystem doesn’t officially support graphical applications or server software (though it is possible to run some graphical applications, unofficially). Officially, it’s intended for Linux terminal applications and other command-line utilities developers might want.

请注意,Windows 10Linux子系统并不正式支持图形应用程序或服务器软件(尽管可以非正式地运行某些图形应用程序 )。 正式地,它用于Linux终端应用程序和开发人员可能需要的其他命令行实用程序。

Windows 10’s Bash shell only supports 64-bit binaries, so you can’t install and run 32-bit Linux programs.

Windows 10的Bash Shell仅支持64位二进制文​​件,因此您无法安装和运行32位Linux程序。

公寓说明 (Apt-get Explained)

On Ubuntu and other Debian-based Linux distributions, you use the apt-get command to install software. “Apt” stands for “Advanced Package Tool”. This command downloads software packages from Ubuntu’s centralized software repositories and installs them on your system. If the packages you try to install require–or “depend on”–other packages, apt-get will automatically download and install those packages (known as dependencies) as well. Apt-get works with “.deb” packages, named for Debian, the Linux distribution Ubuntu is based on.

在Ubuntu和其他基于DebianLinux发行版上,您可以使用apt-get命令来安装软件。 “ Apt”代表“高级打包工具”。 此命令从Ubuntu的集中式软件存储库下载软件包,并将其安装在系统上。 如果您尝试安装的软件包需要(或“依赖”)其他软件包,则apt-get也会自动下载并安装这些软件包(称为依赖项)。 Apt-get与“ .deb”软件包一起工作,该软件包以Debian为名,Ubuntu是基于Linux发行版的。

You’ll need to run apt-get along with the “sudo” command, which gives it superuser, or root, permissions. This allows the command to modify and install system files in the Linux environment. You’ll have to enter your current user account’s password when you use sudo.

您需要将apt-get与“ sudo ”命令一起运行,从而为其赋予超级用户或root用户权限。 这允许该命令在Linux环境中修改和安装系统文件。 使用sudo时,您必须输入当前用户帐户的密码。

You can also use the newer apt command instead of the traditional apt-get command, although either command will work.

您也可以使用更新的apt命令来代替传统的apt-get命令,尽管这两个命令都可以使用。

如何下载更新的软件包列表 (How to Download Updated Package Lists)

First, you’ll want to run the following command to download up-to-date package lists from the software repositories:

首先,您需要运行以下命令以从软件存储库下载最新的软件包列表:

sudo apt-get update
如何在Windows 10的Ubuntu Bash Shell中安装Linux软件_第2张图片

You’ll want to do this before you install any package.

在安装任何软件包之前,您需要执行此操作。

如何安装套件 (How to Install a Package)

If you know the name of a package you want to install, you can download and install it with the following command, replacing “packagename” with the name of the package you want to install:

如果知道要安装的软件包的名称,则可以使用以下命令下载并安装它,将“ packagename”替换为要安装的软件包的名称:

sudo apt-get install packagename

For example, if you wanted to install Ruby, you’d run the following command:

例如,如果您想安装Ruby,则可以运行以下命令:

sudo apt-get install ruby

You can press the Tab key while typing the name of a package (or any command) to use Bash’s autocomplete feature, which will help you automatically finish typing things and suggest available options, if multiple options are available.

您可以在键入软件包名称(或任何命令)时按Tab键来使用Bash的自动完成功能 ,如果有多个选项,它将帮助您自动完成输入内容并建议可用选项。

After running this and other apt-get commands, you’ll be presented with the changes that will be made and you’ll have to type “y” and press Enter to continue.

运行此命令和其他apt-get命令后,将显示将要进行的更改,您必须键入“ y”,然后按Enter继续。

如何在Windows 10的Ubuntu Bash Shell中安装Linux软件_第3张图片

如何搜索包裹 (How to Search for a Package)

You may not always know the name of the package you want to install. In this case, you can use the apt-cache command to search your downloaded package cache (the lists that were download with apt-get update) for a program. This command searches package names and descriptions for the text you specify.

您可能并不总是知道要安装的软件包的名称。 在这种情况下,您可以使用apt-cache命令在下载的程序包缓存(使用apt-get update下载的列表)中搜索程序。 该命令在软件包名称和描述中搜索您指定的文本。

This command doesn’t require sudo, as it’s just a simple search. However, you can run it with sudo if you like, and it will still work.

该命令不需要sudo,因为它只是一个简单的搜索。 但是,您可以根据需要使用sudo运行它,并且仍然可以使用。

apt-cache search sometext

For example, if you wanted to search for packages related to w3m, a text-based web browser for the terminal, you’d run:

例如,如果要搜索与w3m相关的软件包,w3m是终端的基于文本的Web浏览器,则可以运行:

apt-cache search w3m
如何在Windows 10的Ubuntu Bash Shell中安装Linux软件_第4张图片

如何更新所有已安装的软件包 (How to Update All Your Installed Packages)

To update your installed software packages to the latest available versions in the repository–which gives you any security updates available for your current packages–run the following command:

要将安装的软件包更新到存储库中的最新可用版本(这将为您提供当前软件包的可用安全更新),请运行以下命令:

sudo apt-get upgrade

Remember to run the “sudo apt-get update” command before you run this command, as you need to update your package lists before apt-get will see the latest available versions.

请记住在运行此命令之前先运行“ sudo apt-get update”命令,因为您需要先更新软件包列表,然后apt-get才能看到最新的可用版本。

如何在Windows 10的Ubuntu Bash Shell中安装Linux软件_第5张图片

如何卸载软件包 (How to Uninstall a Package)

To uninstall a package when you’re done with it, run the following command:

要在完成后卸载软件包,请运行以下命令:

sudo apt-get remove packagename

The above command just removes the package’s binary files, but not any associated configuration files. If you’d like to remove everything associated with the software package, run the following command instead:

上面的命令仅删除软件包的二进制文件,而不删除任何关联的配置文件。 如果要删除与该软件包相关的所有内容,请改为运行以下命令:

sudo apt-get purge packagename

Neither of the above commands will remove any “dependencies,” which are packages that were installed because they were required for a package. If you uninstall a package and then remove it later, your system may still have a number of additional dependencies that are no longer necessary. To remove any packages that were installed as dependencies and are no longer required, run the following command:

上面的两个命令都不会删除任何“依赖项”,这些依赖项是已安装的软件包,因为它们是软件包必需的。 如果卸载软件包,然后再将其删除,则系统可能仍然具有许多不再需要的其他依赖项。 要删除所有已安装为依赖项且不再需要的软件包,请运行以下命令:

sudo apt-get autoremove
如何在Windows 10的Ubuntu Bash Shell中安装Linux软件_第6张图片

如何安装其他软件 (How to Install Other Software)

The above commands will help you install and update most common software you’ll require. However, some software will be installed through other commands and tools.

上面的命令将帮助您安装和更新所需的大多数常用软件。 但是,某些软件将通过其他命令和工具安装。

For example, Ruby gems are installed with the “gem install” command once you’ve installed Ruby via apt-get. Ruby has its own software installation system that’s separate from apt-get.

例如,通过apt-get安装Ruby后,将使用“ gem install”命令安装Ruby gem。 Ruby拥有自己的软件安装系统,该系统与apt-get分开。

Some software packages are available in PPAs, or “personal package archives,” that are hosted by third parties. To install these, you’ll need to add the PPA to your system and then use the normal apt-get commands.

在第三方托管的PPA或“个人软件包档案”中提供了一些软件包。 要安装这些程序,您需要将PPA添加到系统中 ,然后使用常规的apt-get命令。

Newer software may need to be compiled and installed from source. All the packages you install with apt-get were compiled from source by Ubuntu’s build system and conveniently packaged into .deb packages you can install. You should avoid this if possible, but it may be unavoidable in some cases.

较新的软件可能需要从源代码进行编译和安装。 您使用apt-get安装的所有软件包都是由Ubuntu的构建系统从源代码编译的,并方便地打包为您可以安装的.deb软件包。 如果可能,应避免这种情况,但在某些情况下可能不可避免。

Whatever the case, if you’re trying to install another Linux application, you should be able to find instructions that tell you how you should install it. The same instructions that work on Ubuntu 14.04 LTS will work in Windows 10’s Bash shell. When it’s updated to the next major version of Ubuntu, the same instructions that work on Ubuntu 16.04 LTS will work on Windows 10.

无论如何,如果您要安装另一个Linux应用程序,都应该能够找到指示如何安装它的说明。 适用于Ubuntu 14.04 LTS的相同说明将适用于Windows 10的Bash shell。 将其更新到Ubuntu的下一个主要版本时,适用于Ubuntu 16.04 LTS的相同说明将适用于Windows 10。

翻译自: https://www.howtogeek.com/261449/how-to-install-linux-software-in-windows-10s-ubuntu-bash-shell/

你可能感兴趣的:(linux,ubuntu,java,python,数据库)