所有 apt 命令行命令和选项是什么?

所有 apt 命令行命令和选项是什么?

apt --help我知道他们认为他们是有帮助的,但事实上,在手册页中他们所做的事情恰恰相反:

与 apt 本身非常相似,它的手册页旨在作为最终用户界面,因此只提到最常用的命令和选项,部分是为了不在多个地方重复信息,部分是为了避免让读者被大量的选项和细节所淹没。

换句话说,他们只列出了一些命令和选项,却没有告诉你如何找到其余的,如果我要使用这个工具,这将非常无用。

那么,他们认为不提供哪些命令和选项是“有帮助的”,它们的详细信息和用法是什么,如果他们没有正式提供这些信息,我如何才能及时了解这些信息?或者现在情况已经发生了变化,它们被列在某个地方?

我正在运行带有 GNOME 3.20 的 Ubuntu GNOME 16.04。

答案1

请改进这个 wiki 并添加您最喜欢的 apt 命令:)


apt changelog PACKAGE_NAME

上述命令以日期倒序(最新优先)显示指定软件包的变更日志历史记录less,格式如下:变更日志


apt full-upgrade

(需要 root 权限)新名称apt-get dist-upgrade- 参见man apt-get

dist-upgrade 除了执行升级功能外,还智能地处理软件包新版本依赖关系的变化;apt-get 有一个“智能”冲突解决系统,它会尝试升级最重要的软件包,并在必要时牺牲不太重要的软件包。因此 dist-upgrade 命令可能会删除一些软件包。


apt search PACKAGE_NAME

几乎相同,apt-cache search但输出经过美化——行距和颜色更易于阅读:

search 针对给定的 POSIX 正则表达式模式对所有可用软件包列表执行全文搜索。它会在软件包名称和描述中搜索正则表达式的出现,并打印出软件包名称和简短描述,包括虚拟软件包名称。


apt list -manual-installed -a

对于特定软件包,比 -v 更详细


答案2

来自apt(8)手册页

SCRIPT USAGE AND DIFFERENCES FROM OTHER APT TOOLS
   The apt(8) commandline is designed as an end-user tool and it may change
   behavior between versions. While it tries not to break backward
   compatibility this is not guaranteed either if a change seems beneficial
   for interactive use.

   All features of apt(8) are available in dedicated APT tools like apt-get(8)
   and apt-cache(8) as well.  apt(8) just changes the default value of some
   options (see apt.conf(5) and specifically the Binary scope). So you should
   prefer using these commands (potentially with some additional options
   enabled) in your scripts as they keep backward compatibility as much as
   possible.

我理解这意味着要apt与手册页和其他 apt 工具中显示的选项一起使用,例如apt-get(8)或者apt-cache(8)为最终用户提供附加选项和功能。

答案3

据我所知,所有选项只能在completions/bash/apt文件中找到GitHub apt 存储库.apt有各种通用选项和命令。这些命令可能还有其他选项。

通用选项

的通用选项apt如下:

-d --download-only
-y --assume-yes
--assume-no
-u --show-upgraded
-m --ignore-missing
-t --target-release
--download
--fix-missing
--ignore-hold
--upgrade
--only-upgrade
--allow-change-held-packages
--allow-remove-essential
--allow-downgrades
--print-uris
--trivial-only
--remove
--arch-only
--allow-unauthenticated
--allow-insecure-repositories
--install-recommends
--install-suggests
--no-install-recommends
--no-install-suggests
--fix-policy

命令

可用的命令如下:

list
search
show|showsrc
install|reinstall|remove|purge|autoremove|autopurge
update
upgrade|full-upgrade|dist-upgrade
edit-sources
help
source|build-dep
clean|autoclean
download|changelog
moo
depends|rdepends
policy

附加命令选项

  • 对于命令,install|reinstall|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove|autopurge附加选项包括:

    --show-progress
    --fix-broken
    --purge
    --verbose-versions
    --auto-remove
    -s --simulate --dry-run
    --download
    --fix-missing
    --fix-policy
    --ignore-hold
    --force-yes
    --trivial-only
    --reinstall
    --solver
    -t --target-release
    

    还有通用apt选项。

  • 对于命令,update附加选项包括:

    --list-cleanup
    --print-uris
    --allow-insecure-repositories
    
  • 对于命令,list附加选项包括:

    --installed
    --upgradable 
    --manual-installed
    -v --verbose
    -a --all-versions
    -t --target-release
    
  • 对于命令,show附加选项包括:

    -a --all-versions
    
  • 对于命令,depends|rdepends附加选项包括:

    -i --important
    --installed
    --pre-depends
    --depends
    --recommends
    --suggests
    --replaces
    --breaks
    --conflicts
    --enhances
    --recurse
    --implicit
    
  • 对于命令,search附加选项包括:

    -n --names-only
    -f --full
    
  • 对于命令,showsrc附加选项是:

    --only-source
    
  • 对于命令,source附加选项包括:

    -s --simulate --dry-run
    -b --compile --build
    -P --build-profiles
    --diff-only
    --debian-only
    --tar-only
    --dsc-only
    -t --target-release
    

    还有通用apt选项。

  • 对于命令,build-dep附加选项包括:

    -a --host-architecture
    -s --simulate --dry-run
    -P --build-profiles
    -t --target-release
    --purge
    --solver
    

    还有通用apt选项。

  • 对于命令,moo附加选项是:

    --color
    
  • 对于命令,clean|autoclean附加选项包括:

    -s --simulate --dry-run
    

相关内容