APT-GET 和 APT-CACHE 软件包管理的基本命令

linuxsoftware & codinghardware更新于 2026/1/19 1:37:17

Apt-get 是用于处理应用程序的命令行实用程序,可以被视为其他使用 APT 库的工具的"后端"。Apt-cache 对 APT 软件包执行各种操作。本文介绍了"APT-GET 和 APT-CACHE 软件包管理的基本命令"。

Apt-get

要获取有关 apt-get 的更多选项,请使用以下命令 –

$ apt-get -h

示例输出包含以下选项,如下所示 –

update - Retrieve new lists of packages
   upgrade - Perform an upgrade
   install - Install new packages (pkg is libc6 not libc6.deb)
   remove - Remove packages
   purge - Remove packages and config files
   autoremove - Remove automatically all unused packages
   dist-upgrade - Distribution upgrade, see apt-get(8)
   dselect-upgrade - Follow dselect selections
   build-dep - Configure build-dependencies for source packages
   clean - Erase downloaded archive files
   autoclean - Erase old downloaded archive files
   check - Verify that there are no broken dependencies
   source - Download source archives
   download - Download the binary package into the current directory
   changelog - Download and display the changelog for the given package

安装软件包

要使用 apt-get 安装软件包,请使用以下命令:

$ sudo apt-get install <软件包名称>

升级软件包

要升级软件包,请使用以下命令 –

$ sudo apt-get upgrade

删除未使用的软件包

要自动删除所有未使用的软件包,请使用以下命令 –

$ sudo apt-get autoremove

删除已下载的存档文件

要删除已下载的存档文件,请使用以下命令 –

$ sudo apt-get clean

删除旧的下载存档文件

要删除旧的下载存档文件,请使用以下命令 –

$ sudo apt-get自动清理

验证依赖项是否损坏

要验证依赖项是否损坏,请使用以下命令 –

$ sudo apt-get check

Apt-cache

要获取有关 apt-cache 的更多选项,请使用以下命令 –

$ sudo apt-cache --help

apt-cache 的示例选项如下所示 –

showsrc - Show source records
   search - Search the package list for a regex pattern
   depends - Show raw dependency information for a package
   rdepends - Show reverse dependency information for a package
   show - Show a readable record for the package
   pkgnames - List the names of all packages in the system
   policy - Show policy settings

获取软件包的依赖项

要获取软件包或源记录的依赖项,请使用以下命令 –

$sudo apt-cache showsrc <packegename>

正则表达式的软件包列表

要获取正则表达式的软件包列表,请使用以下命令 –

$sudo apt-cache search <packegename>

原始依赖项信息

要显示软件包的原始依赖项信息,请使用以下命令 –

$ apt-cache depends <packegename>

显示反向依赖信息

要显示软件包的反向依赖信息,请使用以下命令 –

$ apt-cache rdepends <packegename>

显示可读记录

要显示软件包的可读记录,请使用以下命令 –

$ apt-cache show <packegename>

显示所有软件包的名称

要显示系统中所有软件包的名称,请使用以下命令 –

$ apt-cache pkgnames

在上文中,我们了解了 –学习 APT-GET 和 APT-CACHE 的基本软件包管理命令。在接下来的文章中,我们将分享更多 Linux 相关的技巧和窍门。继续阅读。


有用资源