在 AL2 執行個體上尋找並安裝軟體套件 - Amazon Linux 2

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

在 AL2 執行個體上尋找並安裝軟體套件

您可以使用套件管理工具來尋找並安裝軟體套件。在 Amazon Linux 2 中,預設軟體套件管理工具為 YUM。在 AL2023 中,預設軟體套件管理工具為 DNF。如需詳細資訊,請參閱《Amazon Linux 2023 使用者指南》中的套件管理工具

尋找 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 套件管理工具會搜尋所有已啟用的儲存庫,尋找不同的軟體套件,並處理軟體安裝程序中的任何相依性。如需在 AL2023 中安裝軟體套件的詳細資訊,請參閱《Amazon Linux 2023 使用者指南》中的管理套件和作業系統更新

若要從儲存庫中安裝套件

請使用 yum install 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