apt、apt-get、apt-cache使用详解

2023-11-18

1. 概述

aptapt-getapt-cache是三个软件,但可以将apt理解为apt-get、apt-cache的超集,因为apt包含了apt-getapt-cache

2. 搜索软件、查看软件信息、依赖关系

# 搜索指定的包
apt search packagename
或
apt-cache search packagename  

#显示包的相关信息,如说明、大小、版本等
apt show packagename
或
apt-cache show packagename 
	 
#了解使用该包依赖哪些包
apt-cache depends packagename  

#查看该包被哪些包依赖
apt-cache rdepends packagename 

3. 查看已安装软件

apt list
或
apt-cache pkgnames

4. 安装、升级软件

# 更新软件库 建议安装之前先执行该操作
apt update
或
apt-get update

# 安装软件
apt install packagename
或
apt-get install packagename

# 升级已安装的软件
apt upgrade
或
apt-get upgrade

# 仅升级指定的包
apt-get install packagename --only-upgrade

# 重新安装包
apt-get install packagename --reinstall

# 修复安装
apt-get -f install

# 安装相关的编译环境
apt-get build-dep packagename

# 下载该包的源代码
apt-get source packagename

# 升级系统
apt-get dist-upgrade

# 使用 dselect 升级
apt-get dselect-upgrade

5. 删除

# 删除包 保留配置文件
apt remove packagename
或
apt-get remove packagename

# 删除包,包括删除配置文件等
apt-get remove packagename -- purge

# 删除包及其依赖的软件包+配置文件等
apt-get autoremove packagename --purge

# 删除所有未使用的包 
apt autoremove
或
apt-get autoremove 

6. 清理、检查

# 清理无用的包 删除包缓存中的所有包
apt-get clean

# 清理无用的包 将已经删除了的软件包的.deb安装文件从硬盘中删除掉
apt-get autoclean

7. 忽略更新

# 使用这个命令可以将指定的包的版本hold住,这样在更新的时候就会忽略掉这个包
apt-mark hold packagename		

# 解除对包的锁定
apt-mark unhold packagename

8. apt-get参数

 -h 		帮助文件。  
 -q 		输出到日志 - 无进展指示  
 -qq 		不输出信息,错误除外  
 -d 		仅下载 - 不安装或解压归档文件  
 -s 		不实际安装。模拟执行命令  
 -y 		在需要确认的场景中回应 yes
 -f 		尝试修正系统依赖损坏处  
 -m 		如果归档无法定位,尝试继续  
 -u 		同时显示更新软件包的列表  
 -b 		获取源码包后编译  
 -V 		显示详细的版本号  
 -c=? 		阅读此配置文件  
 -o=? 		设置自定的配置选项,如 -o dir::cache=/tmp  

9. 参考文档

apt --help

apt 2.0.2ubuntu0.1 (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 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
  reinstall - reinstall 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
  satisfy - satisfy dependency strings

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-get --help

apt 2.0.2ubuntu0.1 (amd64)
Usage: apt-get [options] command
       apt-get [options] install|remove pkg1 [pkg2 ...]
       apt-get [options] source pkg1 [pkg2 ...]

apt-get is a command line interface for retrieval of packages
and information about them from authenticated sources and
for installation, upgrade and removal of packages together
with their dependencies.

Most used commands:
  update - Retrieve new lists of packages
  upgrade - Perform an upgrade
  install - Install new packages (pkg is libc6 not libc6.deb)
  reinstall - Reinstall 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
  satisfy - Satisfy dependency strings
  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

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-cache --help

apt 2.0.2ubuntu0.1 (amd64)
Usage: apt-cache [options] command
       apt-cache [options] show pkg1 [pkg2 ...]

apt-cache queries and displays available information about installed
and installable packages. It works exclusively on the data acquired
into the local cache via the 'update' command of e.g. apt-get. The
displayed information may therefore be outdated if the last update was
too long ago, but in exchange apt-cache works independently of the
availability of the configured sources (e.g. offline).

Most used commands:
  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

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.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

apt、apt-get、apt-cache使用详解 的相关文章

  • 在centos中安装sqlite3 dev和其他包

    我正在尝试使用 cpanel 在 centos 机器上安装 sqlite dev 和其他库 以便能够编译应用程序 我对 debian 比 centos 更熟悉 我知道我需要的库是 libsqlite3 dev libkrb5 dev lib
  • 在 Linux 上以编程方式设置 DNS 名称服务器

    我希望能够通过我的 C C 程序为 Linux 上的 DNS 名称服务器添加 IP 地址 我在一个带有只读 etc resolv conf 的嵌入式平台上 这意味着我不能简单地将 nameserver xxx xxx xxx xxx 行添加
  • Linux 上的静态 Qt5 构建:部署时如何处理字体?

    我使用这些配置选项创建了 Qt 5 2 0 库的静态版本 Ubuntu 12 04 开源 确认许可 force pkg config 发布 静止的 前缀 home juzzlin qt5 无icu opengl桌面 无油嘴滑舌 辅助功能 n
  • 如何在linux中以编程方式获取dir的大小?

    我想通过 C 程序获取 linux 中特定目录的确切大小 我尝试使用 statfs path struct statfs 但它没有给出确切的大小 我也尝试过 stat 但它返回任何目录的大小为 4096 请建议我如何获取 dir 的确切大小
  • GMail 421 4.7.0 稍后重试,关闭连接

    我试图找出为什么它无法使用 GMail 从我的服务器发送邮件 为此 我使用 SwiftMailer 但我可以将问题包含在以下独立代码中
  • 如何根据标签将单个 XML 文件拆分为多个

    我有一个带有标签的 XML 文件 我想像这样分割文件
  • 并行运行 shell 脚本

    我有一个 shell 脚本 打乱大型文本文件 600 万行和 6 列 根据第一列对文件进行排序 输出 1000 个文件 所以伪代码看起来像这样 file1 sh bin bash for i in seq 1 1000 do Generat
  • .net-core:ILDASM / ILASM 的等效项

    net core 是否有相当于 ILDASM ILASM 的功能 具体来说 我正在寻找在 Linux 上运行的东西 因此为什么是 net core ildasm 和 ilasm 工具都是使用此存储库中的 CoreCLR 构建的 https
  • Bash - 在与当前终端分开的另一个终端中启动命令的新实例

    我有一个简单的 bash 脚本 test sh 设置如下 bin bash args if args 0 check capture then watch n 1 ls lag home user capture0 watch n 1 ls
  • 如何使用waf构建共享库?

    我想使用构建一个共享库waf http code google com p waf 因为它看起来比 GNU 自动工具更容易 更简洁 到目前为止 我实际上有几个与我开始编写的 wscript 有关的问题 VERSION 0 0 1 APPNA
  • 内核的panic()函数是否完全冻结所有其他进程?

    我想确认内核的panic 功能和其他类似kernel halt and machine halt 一旦触发 保证机器完全冻结 那么 所有的内核和用户进程都被冻结了吗 是panic 可以被调度程序中断吗 中断处理程序仍然可以执行吗 用例 如果
  • 使用 python 脚本更改 shell 中的工作目录

    我想实现一个用户态命令 它将采用其参数之一 路径 并将目录更改为该目录 程序完成后 我希望 shell 位于该目录中 所以我想实施cd命令 但需要外部程序 可以在 python 脚本中完成还是我必须编写 bash 包装器 Example t
  • 如何在 *nix 中登录时运行脚本?

    我知道我曾经知道如何做到这一点 但是 如何在 unix 中登录时运行脚本 bash 可以 From 维基百科 Bash http en wikipedia org wiki Bash 28Unix shell 29 当 Bash 启动时 它
  • linux下如何从文本文件中获取值

    我有一些文本格式的文件 xxx conf 我在这个文件中有一些文本 disablelog 1 当我使用 grep r disablelog oscam conf 输出是 disablelog 1 但我只需要值1 请问你有什么想法吗 一种方法
  • Apache 访问 Linux 中的 NTFS 链接文件夹

    在 Debian jessie 中使用 Apache2 PHP 当我想在 Apache 的文档文件夹 var www 中创建一个新的小节时 我只需创建一个指向我的 php 文件所在的外部文件夹的链接 然后只需更改该文件夹的所有者和权限文件夹
  • 我什么时候应该编写 Linux 内核模块?

    有些人出于某种原因想要将 Linux 中的代码从用户空间移动到内核空间 很多时候 原因似乎是代码应该具有特别高的优先级 或者只是 内核空间更快 这对我来说似乎很奇怪 我什么时候应该考虑编写内核模块 有一套标准吗 我怎样才能激励将代码保存在
  • 如何在 Mac OSX Mavericks 中正确运行字符串工具?

    如何在 Mac OSX Mavericks 中正确运行字符串工具 我尝试按照我在网上找到的示例来运行它 strings a UserParser class 但我收到此错误 错误 Applications Xcode app Content
  • 复制目录内容

    我想将目录 tmp1 的内容复制到另一个目录 tmp2 tmp1 可能包含文件和其他目录 我想使用C C 复制tmp1的内容 包括模式 如果 tmp1 包含目录树 我想递归复制它们 最简单的解决方案是什么 我找到了一个解决方案来打开目录并读
  • 从 Linux 内核模块中调用用户空间函数

    我正在编写一个简单的 Linux 字符设备驱动程序 以通过 I O 端口将数据输出到硬件 我有一个执行浮点运算的函数来计算硬件的正确输出 不幸的是 这意味着我需要将此函数保留在用户空间中 因为 Linux 内核不能很好地处理浮点运算 这是设
  • 从另一个 python 脚本获取返回信息

    我在 Linux 上 我有一个 python 脚本 我想从另一个 python 脚本调用它 我不想将其作为模块导入 为了一层安全性 现在为了学术练习 因为我想弄清楚这一点 我实际上想让一个脚本使用 os system 或另一个类似的函数 并

随机推荐

  • 大数据毕设选题 - 大数据招聘职业数据分析可视化系统(python 爬虫)

    文章目录 0 前言 1 课题背景 2 实现效果 3 Flask框架 4 数据爬虫 5 最后 0 前言 Hi 大家好 这里是丹成学长的毕设系列文章 对毕设有任何疑问都可以问学长哦 这两年开始 各个学校对毕设的要求越来越高 难度也越来越大 毕业
  • maven项目pom.xml中parent标签的使用

    本文来说下maven项目pom xml中parent标签的使用 文章目录 parent标签 parent标签由来 依赖排除 本文小结 parent标签 parent标签使用例子
  • HTML5编程简介及示例代码

    HTML5是一种用于构建网页和Web应用程序的标准 它引入了许多新的元素 属性和API 为开发者提供了更多的功能和灵活性 在本文中 我们将探讨HTML5编程的一些不同方面 并提供相应的示例代码 标题 Headings HTML5引入了新的标
  • 网络存储ISCSI实战

    1 网络存储iSCSI SCSI small computer system interface 小型计障机系统接口 SCSI以目前的定义来说就是一个硬盘的接口标准 你硬盘通过SCSI口插上 就可以使用SCSI的协议来对磁盘进行读写 iSC
  • 理解Servlet和Servlet容器、Web服务器等概念

    转载自http blog csdn net iAm333 之前在开源中国看到一篇文章 初学 Java Web 开发 请远离各种框架 从 Servlet 开发 觉得很不错 想到自己之前一直对各种框架执迷不悟 顿感惭愧 于是 看了孙鑫的 Ser
  • 递归与开根号运算

    include
  • 19功能之C++中调用C的函数要添加extern声明

    19功能之C 中调用C的函数要添加extern声明 因为C 支持重载 如果不添加extern声明的话 那么C 编译后的名字是与C的不一样 当执行时 去C库中找 会找不到该函数名
  • 电力系统的虚假数据注入攻击和MTD系统研究(Matlab代码实现)

    欢迎来到本博客 博主优势 博客内容尽量做到思维缜密 逻辑清晰 为了方便读者 座右铭 行百里者 半于九十 本文目录如下 目录 1 概述 2 运行结果 3 参考文献 4 Matlab代码实现 1 概述 智能电网的深度融合 提升了电网的整体调度能
  • 【代码】python调用api示例

    调用api的基本步骤如下 1 导入requests库 这是一个常用的发送和处理http请求的库 2 创建一个请求对象 指定请求的url 方法 参数 头部等信息 3 发送请求 获取响应对象 4 检查响应的状态码 内容 格式等信息 5 如果响应
  • linux下gz和tar.gz、zip压缩解压

    文章目录 说明 分享 tar gz 常用命令 gz 常用命令 zip 常用命令 总结 说明 本博客每周五更新一次 日常数据处理中 经常需要压缩数据文件 减小传输带宽 方便分享和存储 整理gz tar gz zip三种格式 一般场景中的压缩解
  • niginx 配置代理websokcet

    server listen 80 server name xxx xxx cn client max body size 20m location proxy redirect off proxy set header Host host
  • C++写csv文件

    代码如下 include
  • ubuntu 如何放开端口

    在 Ubuntu 上放开端口 可以通过以下步骤进行操作 使用 root 用户或具有管理员权限的用户登录到 Ubuntu 系统 使用防火墙工具 如ufw 放开特定的端口 ufw 是 Ubuntu 上的一个简化的防火墙配置工具 可以轻松管理端口
  • JS阻止事件冒泡的3种方法

    什么是JS事件冒泡 在一个对象上触发某类事件 比如单击onclick事件 如果此对象定义了此事件的处理程序 那么此事件就会调用这个处理程序 如果没有定义此事件处理程序或者事件返回true 那么这个事件会向这个对象的父级对象传播 从里到外 直
  • 小技巧粗讲 - 用栈实现括号匹配的判断

    Codeforces上有一道我曾经讲过的题 买看过的小伙伴看这个链接 https blog csdn net ericgipsy article details 79980874 然后再来一道题 http www fjutacm com P
  • 2021年11月6日-11月12日(ogre抄写+ue4视频,本周35小时,共1035小时,剩8965小时。)

    这周还不错 不但完成了本周学习任务 还完成了本月学习任务 方法就是 拼命抄源码 抄到吐时就再看看Ue4视频教程 内外兼修 可以在未来的日子里这么进行 每天5小时学习 还是进入状态的 5 7 35小时 共1035小时 剩8965小时 另外 去
  • [HBZ分享] 小米手机如何解BL锁

    第一步 进入 设置 gt 我的设备 gt 全部参数 gt 连续疯狂的点MIUI版本那一行 第二步 进入 更多设置 gt 开发者模式 打开USB调试 与 USB安装 第三步 进入 更多设置 gt 开发者模式 进入 设别解锁状态 在下方有一个
  • 利用PostMan 模拟上传/下载文件

    我们经常用postman模拟各种http请求 但是有时候因为业务需要 我们需要测试上传下载功能 其实postman也是很好支持这两种操作的 一 上传文件 1 打开postman 选择对应request类型 以及url 2 选择body 单击
  • OkHttp3封装网络请求框架

    网络请求是开发中最基础的功能 框架原生API不便于复用 今天在这里分享慕课一位老师基于OkHttp封装的一个思路 希望对大家有帮助 首先 我们看一下Okhttp的基本使用 发送异步GET请求 1 new OkHttpClient 2 构造R
  • apt、apt-get、apt-cache使用详解

    文章目录 1 概述 2 搜索软件 查看软件信息 依赖关系 3 查看已安装软件 4 安装 升级软件 5 删除 6 清理 检查 7 忽略更新 8 apt get参数 9 参考文档 1 概述 apt apt get apt cache是三个软件