2019-03-26 21:39:48 +08:00
|
|
|
|
# Pacman
|
|
|
|
|
|
2020-04-27 11:36:57 +08:00
|
|
|
|
Pacman 是 ArchLinux 及其分版的软件包管理工具,本文简单介绍其使用方法和常见问题处理。
|
|
|
|
|
|
2020-12-10 10:29:08 +08:00
|
|
|
|
## 1.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
|
|
|
|
|
2020-12-10 10:29:08 +08:00
|
|
|
|
## 2.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
|
|
|
|
|
2020-12-10 10:29:08 +08:00
|
|
|
|
## 3.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
|
|
|
|
|
2020-12-10 10:29:08 +08:00
|
|
|
|
## 4.Refresh Package Databases
|
|
|
|
|
|
|
|
|
|
长时间不进行更新的话本地 package databases 会与远程的不一致,导致安装软件时出现:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
error: failed retrieving file
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
这样的错误,此时需要使用以下命令更新 package databases
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
pacman -Syu
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 5.Update
|
2019-08-02 15:27:19 +08:00
|
|
|
|
|
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-12-10 10:29:08 +08:00
|
|
|
|
## 6.从本地文件安装
|
2020-07-14 10:45:37 +08:00
|
|
|
|
|
2020-09-24 00:18:47 +08:00
|
|
|
|
使用如下命令可以从本地“\*.pkg.tar.xz”(2020年1月份以后改为 “\*.pkg.tar.zst”)文件进行安装:
|
2020-07-14 10:45:37 +08:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
pacman {-U --upgrade} [选项] <文件>
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-10 10:29:08 +08:00
|
|
|
|
## 7.问题处理
|
2020-04-27 11:36:57 +08:00
|
|
|
|
|
2020-12-10 10:29:08 +08:00
|
|
|
|
### 7.1.conflicting files
|
2020-04-27 13:47:16 +08:00
|
|
|
|
|
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 '*'
|
|
|
|
|
```
|