pacman 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

pacman 命令安装:


-bash/zsh: pacman command not found

#Debian
apt-get install pacman

#Ubuntu
apt-get install pacman

#Alpine
apk add pacman

#Arch Linux
pacman -S pacman

#Kali Linux
apt-get install pacman

#Fedora
dnf install pacman

#Raspbian
apt-get install pacman

#Docker
docker run cmd.cat/pacman pacman

pacman 命令补充说明:


Pacman 是一个软件包管理实用程序,用于跟踪 Linux 系统上已安装的软件包。 它具有依赖关系支持,软件包组,安装和卸载脚本以及将本地计算机与远程存储库同步以自动升级软件包的功能。 Pacman 软件包是 tar 压缩格式。

从 3.0.0 版开始,pacman 成为 libalpm (3)(Arch Linux 软件包管理库)的前端。 该库允许编写替代的前端(例如,GUI 前端)。

调用 pacman 涉及指定具有任何潜在选项和操作目标的操作。 目标通常是程序包名称,文件名,URL 或搜索字符串。 目标可以作为命令行参数提供。 此外,如果不是从终端输入 stdin,而是将单个连字符 - 作为参数传递,则将从 stdin 中读取目标。

pacman 命令语法:


pacman <operation> [options] [targets]

pacman 命令选项:


-D, --database
Operate on the package database. This operation allows you to modify certain attributes of the installed packages in pacman’s database. It also allows you to check the databases for internal consistency. See Database Options below.

-Q, --query
Query the package database. This operation allows you to view installed packages and their files, as well as meta-information about individual packages (dependencies, conflicts, install date, build date, size). This can be run against the local package database or can be used on individual package files. In the first case, if no package names are provided in the command line, all installed packages will be queried. Additionally, various filters can be applied on the package list. See Query Options below.

-R, --remove
Remove package(s) from the system. Groups can also be specified to be removed, in which case every package in that group will be removed. Files belonging to the specified package will be deleted, and the database will be updated. Most configuration files will be saved with a .pacsave extension unless the --nosave option is used. See Remove Options below.

-S, --sync
Synchronize packages. Packages are installed directly from the remote repositories, including all dependencies required to run the packages. For example, pacman -S qt will download and install qt and all the packages it depends on. If a package name exists in more than one repository, the repository can be explicitly specified to clarify the package to install: pacman -S testing/qt. You can also specify version requirements: pacman -S "bash>=3.2". Quotes are needed, otherwise the shell interprets ">" as redirection to a file.

In addition to packages, groups can be specified as well. For example, if gnome is a defined package group, then pacman -S gnome will provide a prompt allowing you to select which packages to install from a numbered list. The package selection is specified using a space- and/or comma-separated list of package numbers. Sequential packages may be selected by specifying the first and last package numbers separated by a hyphen (-). Excluding packages is achieved by prefixing a number or range of numbers with a caret (^).

Packages that provide other packages are also handled. For example, pacman -S foo will first look for a foo package. If foo is not found, packages that provide the same functionality as foo will be searched for. If any package is found, it will be installed. A selection prompt is provided if multiple packages providing foo are found.

You can also use pacman -Su to upgrade all packages that are out-of-date. See Sync Options below. When upgrading, pacman performs version comparison to determine which packages need upgrading. This behavior operates as follows:

Alphanumeric:
  1.0a < 1.0b < 1.0beta < 1.0p < 1.0pre < 1.0rc < 1.0 < 1.0.a < 1.0.1
Numeric:
  1 < 1.0 < 1.1 < 1.1.1 < 1.2 < 2.0 < 3.0.0
Additionally, version strings can have an epoch value defined that will overrule any version comparison, unless the epoch values are equal. This is specified in an epoch:version-rel format. For example, 2:1.0-1 is always greater than 1:3.6-1.

-T, --deptest
Check dependencies; this is useful in scripts such as makepkg to check installed packages. This operation will check each dependency specified and return a list of dependencies that are not currently satisfied on the system. This operation accepts no other options. Example usage: pacman -T qt "bash>=3.2".

-U, --upgrade
Upgrade or add package(s) to the system and install the required dependencies from sync repositories. Either a URL or file path can be specified. This is a “remove-then-add” process. See Upgrade Options below; also see Handling Config Files for an explanation on how pacman takes care of configuration files.

-F, --files
Query the files database. This operation allows you to look for packages owning certain files or display files owned by certain packages. Only packages that are part of your sync databases are searched. See File Options below.

-V, --version
Display version and exit.

-h, --help
Display syntax for the given operation. If no operation was supplied, then the general syntax is shown.

pacman 命令实例:


pacman 同步并更新所有软件包:

pacman -Syu

pacman 安装新包:

pacman -S package_name

pacman 删除软件包及其依赖项:

pacman -Rs package_name

pacman 在软件包数据库中搜索正则表达式或关键字:

pacman -Ss "search_pattern"

pacman 列出已安装的软件包和版本:

pacman -Q

pacman 仅列出明确安装的软件包和版本:

pacman -Qe

pacman 查找哪个包拥有某个文件:

pacman -Qo filename

pacman 空软件包缓存以释放空间:

pacman -Scc

pacman 命令扩展阅读:




pacman 命令评论