2019-03-26 21:39:48 +08:00
|
|
|
|
# Pacman
|
|
|
|
|
|
2020-04-27 11:36:57 +08:00
|
|
|
|
Pacman 是 ArchLinux 及其分版的软件包管理工具,本文简单介绍其使用方法和常见问题处理。
|
|
|
|
|
|
2019-07-30 13:52:13 +08:00
|
|
|
|
## Search
|
2019-03-26 21:39:48 +08:00
|
|
|
|
|
2020-04-27 11:36:57 +08:00
|
|
|
|
使用如下命令查找软件包:
|
|
|
|
|
|
2020-05-20 16:18:39 +08:00
|
|
|
|
```bash
|
2019-08-02 15:26:37 +08:00
|
|
|
|
pacman -Ss <key words>
|
|
|
|
|
```
|
2019-03-26 21:39:48 +08:00
|
|
|
|
|
2019-07-30 13:52:13 +08:00
|
|
|
|
## Install
|
2019-03-26 21:39:48 +08:00
|
|
|
|
|
2020-04-27 11:36:57 +08:00
|
|
|
|
使用如下命令安装软件包:
|
|
|
|
|
|
2020-05-20 16:18:39 +08:00
|
|
|
|
```bash
|
2019-08-02 15:26:37 +08:00
|
|
|
|
pacman -S <package name>
|
|
|
|
|
# if error <file> exists in filesystem
|
|
|
|
|
pacman -S <package name> --force
|
|
|
|
|
```
|
2019-03-26 21:39:48 +08:00
|
|
|
|
|
2019-07-30 13:52:13 +08:00
|
|
|
|
## Remove
|
2019-03-26 21:39:48 +08:00
|
|
|
|
|
2020-04-27 11:36:57 +08:00
|
|
|
|
卸载命令和常用参数如下:
|
|
|
|
|
|
2020-05-20 16:18:39 +08:00
|
|
|
|
```bash
|
|
|
|
|
$ pacman -Rscun <package name>
|
2019-08-02 15:26:37 +08:00
|
|
|
|
-c, --cascade remove packages and all packages that depend on them
|
|
|
|
|
-n, --nosave remove configuration files
|
|
|
|
|
-s, --recursive remove unnecessary dependencies
|
|
|
|
|
-u, --unneeded remove unneeded packages
|
|
|
|
|
```
|
2019-08-02 15:27:19 +08:00
|
|
|
|
|
|
|
|
|
## Update
|
|
|
|
|
|
2020-04-27 11:36:57 +08:00
|
|
|
|
使用如下命令升级软件包和系统。
|
|
|
|
|
|
2020-05-20 16:18:39 +08:00
|
|
|
|
```bash
|
2019-08-02 15:27:19 +08:00
|
|
|
|
pacman -Syu
|
|
|
|
|
```
|
2020-04-27 11:36:57 +08:00
|
|
|
|
|
2020-07-14 10:45:37 +08:00
|
|
|
|
## 从本地文件安装
|
|
|
|
|
|
|
|
|
|
使用如下命令可以从本地“*.pkg.tar.xz”文件进行安装:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
pacman {-U --upgrade} [选项] <文件>
|
|
|
|
|
```
|
|
|
|
|
|
2020-04-27 11:36:57 +08:00
|
|
|
|
## 问题处理
|
|
|
|
|
|
2020-04-27 13:47:16 +08:00
|
|
|
|
### conflicting files
|
|
|
|
|
|
2020-04-27 11:36:57 +08:00
|
|
|
|
在升级或安装软件包时经常遇到如下错误:
|
|
|
|
|
|
2020-05-20 16:18:39 +08:00
|
|
|
|
```bash
|
2020-04-27 11:36:57 +08:00
|
|
|
|
error: failed to commit transaction (conflicting files)
|
|
|
|
|
xxxxxxxxx exists in filesystem
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
此时可以使用 --overwrite 强制覆盖该文件。
|
|
|
|
|
|
2020-05-20 16:18:39 +08:00
|
|
|
|
```bash
|
2020-04-27 11:36:57 +08:00
|
|
|
|
pacman -Syyu --overwrite '*'
|
|
|
|
|
```
|