使用 Aptitude 進行 Linux 包管理
Aptitude 基於 Ncurses 構建 APT 前端和 Debian 包管理器,它是一個基於文字的工具,運行於終端或命令列介面 (CLI)。本文介紹了“使用 Aptitude 進行 Linux 包管理”。
什麼是 APT?
apt 是一個命令列包管理器,提供用於搜尋、管理以及查詢包資訊的命令。它提供與專用 APT 工具(如 apt-get 和 apt-cache)相同的功能,但預設情況下啟用了更適合互動使用的選項。
要獲取有關 APT 的更多資訊,請使用以下命令:
$ apt
示例輸出應如下所示:
apt 1.2.15 (amd64) Usage: apt [options] command apt is a commandline package manager and provides commands for searching and managing as well as querying information about packages. It provides the same functionality as the specialized APT tools, like apt-get and apt-cache, but enables options which are more suitable for interactive use by default. Most used commands: list - list packages based on package names search - search in package descriptions show - show package details install - install packages remove - remove packages autoremove - Remove automatically all unused packages update - update list of available packages upgrade - upgrade the system by installing/upgrading packages full-upgrade - upgrade the system by removing/installing/upgrading packages edit-sources - edit the source information file See apt(8) for more information about the available commands. Configuration options and syntax is detailed in apt.conf(5). Information about how to configure sources can be found in sources.list(5). Package and version choices can be expressed via apt_preferences(5). Security details are available in apt-secure(8). This APT has Super Cow Powers.
包列表
要根據包名稱獲取包列表,請使用以下命令:
$ apt list
示例輸出應如下所示:
revolution-r/xenial,xenial 3.0.0-1ubuntu1 all revu-tools/xenial,xenial,trusty,trusty 0.6.1.5 all rex/xenial,xenial 1.3.3-1 all rexical/xenial,xenial 1.0.5-2build1 all rexima/xenial 1.4-7build1 amd64 rfc5766-turn-server/trusty 3.2.3.1-1 amd64 rfcdiff/xenial,xenial 1.42-1 all rfdump/xenial 1.6-4 amd64 rfkill/xenial,now 0.5-1ubuntu3 amd64 [installed,automatic] rgbpaint/xenial,trusty 0.8.7-5 amd64 rgxg/xenial,trusty 0.1-1 amd64 rhash/xenial 1.3.3-1 amd64 rhc/xenial,xenial 1.38.4-2 all rheolef/xenial 6.6-1build2 amd64 rheolef-doc/xenial,xenial 6.6-1build2 all rhino/xenial,xenial 1.7R4-3 all rhino-doc/xenial,xenial 1.7R4-3 all rhinote/xenial,xenial,trusty,trusty 0.7.4-2 all rhn-client-tools/xenial 1.8.26-4 amd64 rhnsd/xenial 5.0.4-3 amd64 ..................................................................
安裝包
要使用 APT 安裝包,請使用以下命令:
$ sudo apt install firefox
上述命令安裝 firefox。示例輸出應如下所示:
Reading package lists... Done Building dependency tree Reading state information... Done firefox is already the newest version (50.1.0+build2-0ubuntu0.16.04.1). firefox set to manually installed. The following packages were automatically installed and are no longer required: libterm-readkey-perl linux-headers-4.4.0-31 linux-headers-4.4.0-31-generic linux-image-4.4.0-31-generic linux-image-extra-4.4.0-31-generic linux-signed-image-4.4.0-31-generic Use 'sudo apt autoremove' to remove them. ..................................................................
刪除包
要使用 APT 刪除包,請使用以下命令:
$ sudo apt remove firefox
上述命令將從 Linux 中刪除 firefox 包。示例輸出應如下所示:
Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libterm-readkey-perl linux-headers-4.4.0-31 linux-headers-4.4.0-31-generic linux-image-4.4.0-31-generic linux-image-extra-4.4.0-31-generic linux-signed-image-4.4.0-31-generic Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: firefox 0 upgraded, 0 newly installed, 1 to remove and 26 not upgraded. After this operation, 114 MB disk space will be freed.
刪除未使用的包
要自動刪除所有未使用的包,請使用以下命令:
$ sudo apt autoremove
示例輸出應如下所示:
Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: libterm-readkey-perl linux-headers-4.4.0-31 linux-headers-4.4.0-31-generic linux-image-4.4.0-31-generic linux-image-extra-4.4.0-31-generic linux-signed-image-4.4.0-31-generic 0 upgraded, 0 newly installed, 6 to remove and 26 not upgraded. After this operation, 295 MB disk space will be freed. ..............................................................................
更新包
要更新包,請使用以下命令:
$ sudo apt update
升級包
要透過安裝/升級包來升級系統,請使用以下命令:
$ sudo apt upgrade
閱讀本文後,您將能夠理解“使用 Aptitude 進行 Linux 包管理”,我們將陸續推出更多基於 Linux 的技巧和提示。敬請關注!
廣告