在 AL2 实例上查找并安装软件包 - Amazon Linux 2
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

在 AL2 实例上查找并安装软件包

您可以使用软件包管理工具来查找和安装软件包。在 Amazon Linux 2 中,默认的软件包管理工具是YUM。在 AL2 023 中,默认的软件包管理工具是DNF。有关更多信息,请参阅《亚马逊 Linux 2023 用户指南》中的 Pack age 管理工具

在 AL2 实例上查找软件包

您可以使用 yum search 命令搜索在您配置的存储库中可用的程序包的描述。如果不知道要安装的程序包的确切名称,这尤其有帮助。只需将关键字搜索附加到该命令;对于多字词搜索,请使用引号括起搜索查询。

[ec2-user ~]$ yum search "find"

下面是示例输出。

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd ============================== N/S matched: find =============================== findutils.x86_64 : The GNU versions of find utilities (find and xargs) gedit-plugin-findinfiles.x86_64 : gedit findinfiles plugin ocaml-findlib-devel.x86_64 : Development files for ocaml-findlib perl-File-Find-Rule.noarch : Perl module implementing an alternative interface to File::Find robotfindskitten.x86_64 : A game/zen simulation. You are robot. Your job is to find kitten. mlocate.x86_64 : An utility for finding files by name ocaml-findlib.x86_64 : Objective CAML package manager and build helper perl-Devel-Cycle.noarch : Find memory cycles in objects perl-Devel-EnforceEncapsulation.noarch : Find access violations to blessed objects perl-File-Find-Rule-Perl.noarch : Common rules for searching for Perl things perl-File-HomeDir.noarch : Find your home and other directories on any platform perl-IPC-Cmd.noarch : Finding and running system commands made easy perl-Perl-MinimumVersion.noarch : Find a minimum required version of perl for Perl code texlive-xesearch.noarch : A string finder for XeTeX valgrind.x86_64 : Tool for finding memory management bugs in programs valgrind.i686 : Tool for finding memory management bugs in programs

引号中的多个字词搜索查询仅返回符合确切查询的结果。如果您没有看到需要的程序包,请将搜索简化为一个关键字,然后扫描结果。您还可以尝试使用关键字同义词来扩大搜索范围。

有关软件包的更多信息 AL2,请参阅以下内容:

在 AL2 实例上安装软件包

在中 AL2,yum 软件包管理工具会在所有启用的存储库中搜索不同的软件包,并处理软件安装过程中的任何依赖关系。有关在 AL2 023 中安装软件包的信息,请参阅 Amazon Linux 2023 用户指南中的管理软件包和操作系统更新

从存储库安装软件包

使用yum install package命令,package替换为要安装的软件的名称。例如,若要安装 links 基于文本的 Web 浏览器,请输入以下命令。

[ec2-user ~]$ sudo yum install links
安装您已下载的 RPM 软件包文件

您还可使用 yum install 安装您已经从互联网下载的 RPM 程序包文件。为此,将 RPM 文件的路径名称而不是存储库程序包名称附加到安装命令。

[ec2-user ~]$ sudo yum install my-package.rpm
列出已安装软件包

要查看实例上已安装的软件包的列表,请使用以下命令。

[ec2-user ~]$ yum list installed