apt命令

在基于 Debian 的 Linux 发行版中,有各种工具可以与 APT 进行交互,以方便用户安装、删除和管理的软件包。apt-get 便是其中一款广受欢迎的命令行工具,另外一款较为流行的是 Aptitude 这一命令行与 GUI 兼顾的小工具。最常用的 Linux 包管理命令都被分散在了 apt-get、apt-cache 和 apt-config 这三条命令当中。
apt 命令的引入就是为了解决命令过于分散的问题,它包括了 apt-get 命令出现以来使用最广泛的功能选项,以及 apt-cache 和 apt-config 命令中很少用到的功能。
在使用 apt 命令时,用户不必再由 apt-get 转到 apt-cache 或 apt-config,而且 apt 更加结构化,并为用户提供了管理软件包所需的必要选项。
简单来说就是:apt = apt-get、apt-cache 和 apt-config 中最常用命令选项的集合。

apt update

update (apt-get(8))
update is used to download package information from all configured sources. Other commands operate on this data to e.g. perform package upgrades or search in and display details about all packages available for installation.

update用于从所有配置源(包括/etc/apt/sources.list/etc/apt/sources.list.d)下载包信息。 其他命令对这些数据进行操作,例如执行包升级或搜索并显示所有可用于安装的包的详细信息。
apt update只是更新了apt的资源列表,没有真正的对系统执行更新。

apt upgrade

upgrade (apt-get(8))
upgrade is used to install available upgrades of all packages currently installed on the system from the sources configured via sources.list(5). New packages will be installed if required to statisfy dependencies, but existing packages will never be removed. If an upgrade for a package requires the remove of an installed package the upgrade for this package isn’t performed.

upgrade用于通过sources.list配置的源中安装系统上当前安装的所有包的可用升级。
如果需要满足依赖关系,将安装新的包,但现有的包将永远不会被删除。
如果对一个包进行升级需要删除已安装的包,则不会执行对该包的升级。

apt remove package_name
删除已安装包(保留配置文件)。

apt purge package_name
删除已安装包(不保留配置文件)。

apt autoremove
删除为了满足依赖而安装的,但现在不再需要的软件包。

apt clean
apt clean 命令清除遗留在 /var/cache 中的已取回的包文件的本地仓库。它清除的目录是 /var/cache/apt/archives/ 和 /var/cache/apt/archives/partial/。它留在 /var/cache/apt/archives 中的唯一文件是 lock 文件和 partial 子目录。

apt autoclean
apt autoclean 类似于 apt-get clean,它会清除已检索包文件的本地仓库,但它只会删除不会再下载且几乎无用的文件。它有助于防止缓存过大。

apt命令

$ man apt
APT(8)                                                                         APT                                                                        APT(8)

NAME
       apt - command-line interface

SYNOPSIS
       apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [-a=architecture] {list | search | show | update |
           install pkg [{=pkg_version_number | /target_release}]...  | remove pkg...  | upgrade | full-upgrade | edit-sources | {-v | --version} |
           {-h | --help}}

DESCRIPTION
       apt provides a high-level commandline interface for the package management system. It is intended as an end user interface and enables some options
       better suited for interactive usage by default compared to more specialized APT tools like apt-get(8) and apt-cache(8).

       Much like apt itself, its manpage is intended as an end user interface and as such only mentions the most used commands and options partly to not
       duplicate information in multiple places and partly to avoid overwhelming readers with a cornucopia of options and details.

       update (apt-get(8))
           update is used to download package information from all configured sources. Other commands operate on this data to e.g. perform package upgrades or
           search in and display details about all packages available for installation.

       upgrade (apt-get(8))
           upgrade is used to install available upgrades of all packages currently installed on the system from the sources configured via sources.list(5). New
           packages will be installed if required to satisfy dependencies, but existing packages will never be removed. If an upgrade for a package requires the
           remove of an installed package the upgrade for this package isn't performed.

       full-upgrade (apt-get(8))
           full-upgrade performs the function of upgrade but will remove currently installed packages if this is needed to upgrade the system as a whole.

       install, remove, purge (apt-get(8))
           Performs the requested action on one or more packages specified via regex(7), glob(7) or exact match. The requested action can be overridden for
           specific packages by append a plus (+) to the package name to install this package or a minus (-) to remove it.

           A specific version of a package can be selected for installation by following the package name with an equals (=) and the version of the package to
           select. Alternatively the version from a specific release can be selected by following the package name with a forward slash (/) and codename
           (stretch, buster, sid ...) or suite name (stable, testing, unstable). This will also select versions from this release for dependencies of this
           package if needed to satisfy the request.

           Removing a package removes all packaged data, but leaves usually small (modified) user configuration files behind, in case the remove was an
           accident. Just issuing an installation request for the accidentally removed package will restore its function as before in that case. On the other
           hand you can get rid of these leftovers by calling purge even on already removed packages. Note that this does not affect any data or configuration
           stored in your home directory.

       autoremove (apt-get(8))
           autoremove is used to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed as
           dependencies changed or the package(s) needing them were removed in the meantime.

           You should check that the list does not include applications you have grown to like even though they were once installed just as a dependency of
           another package. You can mark such a package as manually installed by using apt-mark(8). Packages which you have installed explicitly via install are
           also never proposed for automatic removal.

       search (apt-cache(8))
           search can be used to search for the given regex(7) term(s) in the list of available packages and display matches. This can e.g. be useful if you are
           looking for packages having a specific feature. If you are looking for a package including a specific file try apt-file(1).

       show (apt-cache(8))
           Show information about the given package(s) including its dependencies, installation and download size, sources the package is available from, the
           description of the packages content and much more. It can e.g. be helpful to look at this information before allowing apt(8) to remove a package or
           while searching for new packages to install.

       list (work-in-progress)
           list is somewhat similar to dpkg-query --list in that it can display a list of packages satisfying certain criteria. It supports glob(7) patterns for
           matching package names as well as options to list installed (--installed), upgradeable (--upgradeable) or all available (--all-versions) versions.

       edit-sources (work-in-progress)
           edit-sources lets you edit your sources.list(5) files in your preferred texteditor while also providing basic sanity checks.

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.

SEE ALSO
       apt-get(8), apt-cache(8), sources.list(5), apt.conf(5), apt-config(8), The APT User's guide in /usr/share/doc/apt-doc/, apt_preferences(5), the APT
       Howto.

DIAGNOSTICS
       apt returns zero on normal operation, decimal 100 on error.

BUGS
       APT bug page[1]. If you wish to report a bug in APT, please see /usr/share/doc/debian/bug-reporting.txt or the reportbug(1) command.

AUTHOR
       APT team

NOTES
        1. APT bug page
           http://bugs.debian.org/src:apt

APT 1.6.12ubuntu0.2                                                      20 October 2015                                                                  APT(8)
$

apt-get命令

$ apt-get --help
apt 1.6.12ubuntu0.2 (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)
  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

See apt-get(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.
$
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值