Introduction to Package Management Systems

There was a time when software was distributed via FTP or mailing lists (i.e., patch packages with source code distributed via mailing lists) (eventually these distribution methods evolved, thanks to the rapid growth of the Internet, into one of the common software distribution sites of today). (There is only one very small file (usually in a tar file) that contains instructions for creating the binary. All you need to do is unpack the package, read the README file carefully, and then create the binary via . /configure, make, make install to install the software. Imagine how boring and time-consuming it would be to perform the above process for every piece of software on your system, not to mention how complicated and labor-intensive it would be to update an already installed piece of software.

The concept of package is used to address the complexity of the software installation and upgrade process. A package combines multiple data files needed for software installation and upgrade into a single file, which facilitates transfer and (by compressing the file) reduces storage space, and the binary executable in the package is pre-compiled according to the compilation identifier chosen by the developer. The package itself contains all the required metadata, such as the name of the software, the description of the software, the version number, and the dependent packages needed to run the software, etc.

Different schools of Linux distributions have created their own package formats, the most common of which are

  • .deb: This package format is used by Debian, Ubuntu, Linux Mint, and other variants. This was the first package type to be invented.
  • rpm: This package format was originally called the Red Hat Package Manager (LCTT). Linux distributions that use this package include Red Hat, Fedora, SUSE, and some other smaller distributions.
  • .tar.xz: This package format is simply a software archive, which is the format used by Arch Linux. (LCTT note: this format does not require a special package manager, just unzip it)

Although the above package formats do not directly manage software dependencies on their own, they are a big step forward in Linux package management.

Years ago, the concept of a repository was difficult to understand for non-users of the Linux world. Even today, most users working entirely under Windows are used to opening a browser, searching for software (or upgrade packages) to install, downloading them, and installing them. However, smartphones have spread the concept of an AppStore (software store/application) marketplace. The way smartphone users get software is already very similar to the way package managers work. The difference is that most Linux users prefer to use the command line to install software, even though most software stores are still trying to beautify their graphical interfaces to attract users. In a nutshell, a repository is a centralized list of installable software, listing all the software that can be installed in a pre-configured repository on the current system.

In Linux distributions, almost every distribution has its own package manager. The common ones are.

  • Debian’s dpkg and its
    • front-end apt (used in Debian, Ubuntu).
  • Red Hat’s RPM package manager and its
    • front-end dnf (used in Fedora, CentOS 8)
    • Front-end yum (used on Red Hat Enterprise Linux, CentOS 7 and below)
    • Front-end ZYpp (used in openSUSE)
    • Front-end urpmi (used on Mandriva Linux, Mageia)
  • Other package managers are
    • Pacman used in ArchLinux
    • Source-based Portage for Gentoo
    • Homebrew for Mac systems, etc.

Using a package manager will greatly simplify the process of installing software in a Linux distribution.

Why do you need a package manager with its front-end tools?

Package managers such as RPM and DPKG can only check for dependencies and tell the user that the dependencies are not met when installing or removing, and then the user has to find out the required components to install on their own. This is very inconvenient, in order to achieve automatic handling of dependencies, and to install all dependent packages at once, without the need to download and install them again and again, front-end tools such as APT and YUM were born.

Debian-based package manager

dpkg

dpkg is an abbreviation for Debian Packager. A package management system developed specifically for Debian to facilitate the installation, update and removal of software. The software is a compiled binary package ending in .deb. All “Linux” distributions derived from “Debian” use “dpkg”, e.g. “Ubuntu “, “Knoppix”, etc.

Common commands.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
1)安装软件
命令:dpkg -i <.deb file name>
示例:dpkg -i avg71flm_r28-1_i386.deb

2)安装一个目录下面所有的软件包
命令:dpkg -R
示例:dpkg -R /usr/local/src

3)释放软件包,但是不进行配置
命令:dpkg –-unpack package_file 如果和-R一起使用,参数可以是一个目录
示例:dpkg –-unpack avg71flm_r28-1_i386.deb

4)重新配置和释放软件包
命令:dpkg –configure package_file
如果和-a一起使用,将配置所有没有配置的软件包
示例:dpkg –configure avg71flm_r28-1_i386.deb

5)删除软件包(保留其配置信息)
命令:dpkg -r
示例:dpkg -r avg71flm

6)替代软件包的信息
命令:dpkg –update-avail

7)合并软件包信息
dpkg –merge-avail

8)从软件包里面读取软件的信息
命令:dpkg -A package_file

9)删除一个包(包括配置信息)
命令:dpkg -P

10)丢失所有的Uninstall的软件包信息
命令:dpkg –forget-old-unavail

11)删除软件包的Avaliable信息
命令:dpkg –clear-avail

12)查找只有部分安装的软件包信息
命令:dpkg -C

13)比较同一个包的不同版本之间的差别
命令:dpkg –compare-versions ver1 op ver2

14)显示帮助信息
命令:dpkg –help

15)显示dpkg的Licence
命令:dpkg –licence (or) dpkg –license

16)显示dpkg的版本号
命令:dpkg –version

17)建立一个deb文件
命令:dpkg -b directory [filename]

18)显示一个Deb文件的目录
命令:dpkg -c filename

19)显示一个Deb的说明
命令:dpkg -I filename [control-file]

20)搜索Deb包
命令:dpkg -l package-name-pattern
示例:dpkg -I vim

21)显示所有已经安装的Deb包,同时显示版本号以及简短说明
命令:dpkg -l

22)报告指定包的状态信息
命令:dpkg -s package-name
示例:dpkg -s ssh

23)显示一个包安装到系统里面的文件目录信息
命令:dpkg -L package-Name
示例:dpkg -L apache2

24)搜索指定包里面的文件(模糊查询)
命令:dpkg -S filename-search-pattern

25)显示包的具体信息
命令:dpkg -p package-name
示例:dpkg -p cacti

apt

APT (known as Advanced Packaging Tools) is the Linux equivalent of YUM, a package installation tool. apt-get, apt-cache and apt-cdrom are command-line tools that handle packages. apt-get, apt-cache and apt-cdrom are command-line tools for processing packages.

Common commands.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
apt-cache search package #搜索包
apt-cache show package #获取包的相关信息,如说明、大小、版本等
apt-cache depends package #了解使用依赖
apt-cache rdepends package #查看该包被哪些包依赖
apt-get source package #下载该包的源代码
sudo apt-get install package #安装包
sudo apt-get install package=version #安装指定版本的包
sudo apt-get install package --reinstall #重新安装包
sudo apt-get -f install #修复安装, "-f = --fix-missing"
sudo apt-get remove package #删除包
sudo apt-get remove package --purge #删除包,包括删除配置文件等
sudo apt-get update #更新apt软件源信息
sudo apt-get upgrade #更新已安装的包
sudo apt-get dist-upgrade #升级系统
sudo apt-get dselect-upgrade #使用dselect升级
sudo apt-get build-dep package #安装相关的编译环境
sudo apt-get clean && sudo apt-get autoclean #清理无用的包
sudo apt-get check #检查是否有损坏的依赖

Difference between apt and apt-get commands

One of the notable new features introduced with the release of Ubuntu 16.04 was the introduction of the apt command. In fact, the first stable version of the apt command was released as early as 2014, but it was not until the Ubuntu 16.04 system release in 2016 that it started to attract attention. As the apt install package command became more frequent and common than the apt-get install package, more and more other Linux distributions started to follow in Ubuntu’s footsteps and encouraged users to use apt instead of apt-get. What is the difference between apt-get and apt commands? If they have a similar command structure, why do we need the new apt command? Is apt really better than apt-get? Should the average user use the new apt command or stick with the old habit of using apt-get?

Before we start comparing apt and apt-get, let’s look at the background of these two commands and what they are trying to accomplish. Debian uses a set of tools called Advanced Packaging Tool (APT) to manage this package system, but don’t confuse it with the apt command, they are not really the same thing. In Debian-based Linux distributions, there are various tools that interact with the APT to facilitate the installation, removal, and management of packages. apt-get is one of the popular command-line tools, and another popular one is Aptitude, a small command-line and GUI tool.

If you’ve read the apt-get command guide, you’ve probably encountered many similar commands such as apt-cache, apt-config, and so on. As you can see, these commands are relatively low-level and contain many functions that the average Linux user will probably never use. To put it another way, the most commonly used Linux package management commands are scattered among apt-get, apt-cache, and apt-config. apt was introduced to solve the problem of scattered commands by including the most widely used feature options since the apt-get command came out, as well as apt-cache and apt-config, which are rarely used. apt-config commands. When using the apt command, users no longer have to go from apt-get to apt-cache or apt-config, and apt is more structured and provides users with the necessary options needed to manage packages. Simply put, apt = a collection of the most commonly used command options in apt-get, apt-cache, and apt-config.

With the apt command, the user has all the necessary tools in one place. apt’s main purpose is to provide an efficient way to work with Linux packages in a way that “makes the end user happy”. apt has a more reduced but sufficient set of command options, and the parameter options are organized in a more efficient way. In addition, it has several features that are enabled by default that are very helpful to end-users. For example, you can see a progress bar when installing or removing programs using the apt command. apt also prompts the user for the number of packages that can be upgraded when updating the repository database. If you use the other command options of apt, you can achieve the same thing as when you use apt-get.

Although apt has some similar command options to apt-get, it is not fully backward compatible with the apt-get command. That is, apt can be used to replace some, but not all, of the apt-get family of commands.

apt command Replaced command Command function
apt install apt-get install install packages
apt remove apt-get remove removes packages
apt purge apt-get purge Remove packages and configuration files
apt update apt-get update refresh the repository index
apt upgrade apt-get upgrade upgrade all upgradeable packages
apt autoremove apt-get autoremove automatically remove unneeded packages
apt full-upgrade apt-get dist-upgrade Automatically handle dependencies when upgrading packages
apt search apt-cache search search for applications
apt show apt-cache show show installation details

Of course, apt has a few commands of its own.

New apt commands Command functions
apt list list packages that contain conditions (installed, upgradeable, etc.)
apt edit-sources edits the list of sources

Note that the apt command is still evolving, so you may see new options in future releases.

There is no official word yet from any Linux distribution that apt-get will be discontinued, at least it has more and more fine-grained operations than apt. For low-level operations, you still need apt-get, and since both commands are useful, should I use apt or apt-get? As a regular Linux user, it is recommended that you get used to apt and start using it first, not only because it is recommended by Linux publishers, but also because it provides the necessary options for Linux package management. Most importantly, the apt command has fewer options and is easier to remember and therefore easier to use, so there is no reason to stick with apt-get.

Package manager based on RPM package format

rpm

RPM Package Manager (RPM for short, known as The RPM Package Manager or Redhat Package Manager) is a package manager widely used under Linux. Distributions that use RPM.

  • Fedora and Red Hat Enterprise Linux
  • openSUSE and SUSE Linux Enterprise
  • Mandriva Linux and Mageia
  • PCLinuxOS

RPM packages are divided into three types: Binary, Source and Delta packages. Binary packages can be installed directly on your computer, while source packages will be compiled and installed automatically by RPM. RPM is only available for installing software packaged with RPM and is currently one of the most resourceful package types for GNU/Linux.

Common commands for rpm.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
1)安装软件包
rpm -ivh PACKAGE_NAME-VERSION.rpm

2)测试安装软件包,不做真实的安装
rpm -ivh --test PACKAGE_NAME-VERSION.rpm

3)安装软件包,并重新定义安装路径
rpm -ivh --relocate /=/usr/local/PACKAGE_NAME PACKAGE_NAME-VERSION.rpm

4)强行安装软件包,忽略依赖关系
rpm -ivh PACKAGE_NAME-VERSION.rpm --force --nodeps

5)升级软件包
rpm -Uvh PACKAGE_NAME-VERSION.rpm

6)强行升级软件包,忽略依赖关系
rpm -Uvh PACKAGE_NAME-VERSION.rpm --force --nodeps

7)删除软件包,并忽略依赖关系
rpm -e PACKAGE_NAME --nodeps #只是包名,不需要跟版本号

8)导入签名
rpm --import RPM-GPG-KEY

9)查询某个包是否已经安装
rpm -q PACKAGE_NAME

10)查询系统中所有已安装的包
rpm -qa

11)查询某个文件属于哪个包
rpm -qf /etc/auto.misc

12)查询某个已安装软件所包含的所有文件
rpm -ql PACKAGE_NAME

13)查询某个包的依赖关系
rpm -qpR PACKAGE_NAME-VERSION.rpm

14)查询某个包的信息
rpm -qpi PACKAGE_NAME-VERSION.rpm

15)删除软件包
rpm -e PACKAGE_NAME

yum

yum is a backend program for managing rpm packages, written in python, which makes it very easy to resolve rpm dependencies. After setting up a yum server, yum clients can get packages via http, ftp, and use convenient commands to directly manage and update all rpm packages, even kernel updates.

Common commands for yum.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
1.安装yum包:
$ yum install PACKAGE_NAME

2.删除yum包:
$ yum remove PACKAGE_NAME

3.重新安装一个yum包:
$ yum reinstall PACKAGE_NAME

4.搜索yum包:
$ yum search PACKAGE_NAME

5.显示yum包的信息:
$ yum info PACKAGE_NAME

6.更新安装的yum包:
$ yum update

7.更新具体的yum包:
$ yum update PACKAGE_NAME

8.显示yum历史:
$ yum history

9.显示已启用的yum存储库的列表:
$ yum repolist

10.找出哪个yum包提供了一个特定的文件(例如:/usr/bin/nc)):
$ yum whatprovides "*bin/nc"

11.清除yum缓存:
$ yum clean all

Queries related.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
1.使用YUM查找软件包
命令:yum search ~
2.列出所有可安装的软件包
命令:yum list
3.列出所有可更新的软件包
命令:yum list updates
4.列出所有已安装的软件包
命令:yum list installed
5.列出所有已安装但不在Yum Repository內的软件包
命令:yum list extras
6.列出所指定软件包
命令:yum list ~
7.使用YUM获取软件包信息
命令:yum info ~
8.列出所有软件包的信息
命令:yum info
9.列出所有可更新的软件包信息
命令:yum info updates
10.列出所有已安裝的软件包信息
命令:yum info installed
11.列出所有已安裝但不在Yum Repository內的软件包信息
命令:yum info extras
12.列出软件包提供哪些文件
命令:yum provides~

dnf

DNF is a new generation of rpm package manager. It first appeared in Fedora 18 distribution and recently replaced yum as the package manager for Fedora 22. DNF package manager overcomes some of the bottlenecks of YUM package manager and improves many things including user experience, memory usage, dependency analysis, speed, etc. DNF uses RPM, libsolv and hawkey libraries for package management operations. Although it is not pre-installed in CentOS and RHEL 7, you can use DNF in conjunction with YUM.

Common commands for dnf.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
1. 查看 DNF 包管理器版本
# dnf –version

2.查看系统中可用的 DNF 软件库
# dnf repolist

3.查看系统中可用和不可用的所有的 DNF 软件库
# dnf repolist all

4.列出所有 RPM 包
# dnf list

5.列出所有安装了的 RPM 包
# dnf list installed

6.列出所有可供安装的 RPM 包
# dnf list available

7.搜索软件库中的 RPM 包
# dnf search nano

8.查找某一文件的提供者
# dnf provides /bin/bash

9.查看软件包详情
# dnf info nano

10.安装软件包
# dnf install nano

11.升级软件包
# dnf update systemd

12.检查系统软件包的更新
# dnf check-update

13.升级所有系统软件包
# dnf update 或 # dnf upgrade

14.删除软件包
# dnf remove nano 或 # dnf erase nano

15.删除无用孤立的软件包
# dnf autoremove

16.删除缓存的无用软件包
# dnf clean all

17.获取有关某条命令的使用帮助
# dnf help clean

18.查看所有的 DNF 命令及其用途
# dnf help

19.查看 DNF 命令的执行历史
# dnf history

20.查看所有的软件包组
# dnf grouplist

21.安装一个软件包组
# dnf groupinstall ‘Educational Software’

22.升级一个软件包组中的软件包
# dnf groupupdate ‘Educational Software’

23.删除一个软件包组
# dnf groupremove ‘Educational Software’

24.从特定的软件包库安装特定的软件
# dnf –enablerepo=epel install phpmyadmin

25.更新软件包到最新的稳定发行版
# dnf distro-sync

26.重新安装特定软件包
# dnf reinstall nano

27.回滚某个特定软件的版本
# dnf downgrade acpid

Differences between DNF and Yum

Many long-standing issues in Yum remain unresolved, including poor performance, excessive memory usage, and slow dependency resolution. Therefore, the Yum package manager has been replaced by the DNF package manager.

Number DNF (Dandified YUM) YUM (Yellowdog Updater, Modified)
1 DNF uses libsolv to resolve dependencies and is developed and maintained by SUSE YUM uses a public API to resolve dependencies
2 API is fully documented API is not fully documented
3 Written in C, C++, Python Written in Python only
4 DNF is currently used in Fedora, RHEL 8, CentOS 8, OEL 8, and Mageia 6/7 YUM is currently used in RHEL 6/7, CentOS 6/7, OEL 6/7
5 DNF supports various extensions Yum only supports Python based extensions
6 The API is well documented, so it’s easy to create new features It’s very difficult to create new features because the API is not properly documented
7 DNF uses less memory when synchronizing the repository’s metadata YUM uses too much memory when synchronizing the repository’s metadata
8 DNF uses a satisficing algorithm to resolve dependency resolution (it uses a dictionary approach to store and retrieve package and dependency information) Yum dependency resolution becomes sluggish due to the use of a public API
9 Dependency resolution performs well in terms of both memory usage and repository metadata Overall, underperforms due to many factors
10 DNF updates: during DNF updates, packages are not updated if they contain irrelevant dependencies YUM will update packages without validation
11 If an enabled repository is not responding, DNF will skip it and continue to use the available repositories for transactions YUM will stop immediately if a repository is not available
12 dnf update and dnf upgrade are equivalent not in Yum
13 Dependencies of installed packages are not updated Yum provides an option for this behavior
14 Clean up deleted packages: When a package is deleted, DNF automatically removes any dependencies that are not explicitly installed by the user Yum does not do this
15 Repository cache update schedule: By default, DNF checks for updates to the configured repositories once an hour, 10 minutes after the system starts. This action is controlled by the system timer unit dnf-makecache.timer Yum will also do this
6 Kernel packages are not protected by DNF. Unlike Yum, you can delete all kernel packages, including running kernel packages Yum does not allow you to delete running kernels
17 libsolv: Used for unpacking and reading repositories. hawkey: Provides a simplified C and Python API library for libsolv. librepo: Provides a C and Python (libcURL-like) API library for downloading Linux repository metadata and packages. libcomps: Is a replacement for the yum.comps library. It is a library written in pure C, with Python 2 and Python 3 bindings. Yum does not use separate libraries to perform these functions
18 DNF contains 29,000 lines of code Yum contains 56,000 lines of code
19 DNF was developed by Ales Kozumplik YUM was developed by Zdenek Pavlas, Jan Silhan and team members

zypp

Zypper is another package manager used to manage RPM packages. This package manager is mainly used for SUSE (and openSUSE), but is also used on MeeGo, Sailfish OS, and Tizen. It was originally developed in 2006 and has gone through several iterations. There is not much to say about it except that it serves as a backend for the system management tool YaST and that some users consider it faster than YUM.

Common commands for zyppd.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
1. 安装包
语法: # zypper install 示例:安装Mozilla firefox
# zypper install MozillaFirefox

2. 安装源码包
语法:# zypper source-install 示例:从库中安装 apache
# zypper source-install apache2-mod_nss

3. 更新包
更新某一软件包: # zypper update 更新所有软件包: # zypper update
查看所有可用的更新列表:# zypper list-updates

4. 删除包
语法:# zypper remove 示例:移除Mozilla Firefox
# zypper remove MozillaFirefox

5. 查找包
语法:# zypper search 示例:查找所有usb开头的软件包
# zypper search usb*

6. 查看软件包详情
语法: zypper info 示例:查看usbutils的信息
# zypper info usbutils

7. 打补丁
查看所有可打补丁: zypper patches
安装指定补丁:zypper patch

8. 锁住包

软件包被锁之后将不能被移除或升级,下面演示一下如何加锁
1)加al选项锁住包文件“usbutils”, al 是 add lock的缩写
# zypper al usbutils
Specified lock has been successfully added.

2) 加ll选项查看所有已被锁住的软件包, ll 是 List Locks的缩写
# zypper ll
# | Name            | Type    | Repository
--+-----------------+---------+-----------
1 | usbutils        | package | (any)

9. 解锁包
加rl选项解锁usbutils, rl 是 remove lock的缩写
#  zypper rl usbutils

10. 用zypper添加库
语法:# zypper addrepo
# zypper addrepo --check --refresh --name "Mozilla-repo" 

11. 创建本地库
我们可以使用zypper从本地目录中创建一个包含所有rpm文件的本地库
语法: # zypper addrepo
示例:创建一个名为Linuxprobe_Repo的本地目录,包含所有rpm文件
# zypper addrepo /var/stormgt/dsminst Linuxprobe_Repo

12. 查看库
# zypper lr

13. 在库中搜索包
列出指定库Mozillarepo的所有软件包
# zypper search --repo Mozillarepo

14. 库重命名
重命名库可以用 renamerepo 选项
示例:将库"Linuxprobe_Repo"的名字改成"MyLinuxRepo"
# zypper renamerepo Linuxprobe_Repo MyLinuxRepo

15. 删除库
用removerepo选项来移除库
# zypper removerepo MyLinuxRepo

16. 备份库
用export选项可以备份一系列库文件
# zypper lr --export /var/tmp/backup.repo

17. 从备份文件中添加库
# zypper addrepo /var/tmp/backup.rep

18. 禁用/使用库
示例: 用 modifyrepo 选项的 -d 参数来禁用Mozilla库
# zypper modifyrepo -d Mozillarepo
Repository 'Mozillarepo' has been successfully disabled.
示例: 用 modifyrepo选项 -e 参数来允许使用Mozilla库
# zypper modifyrepo -e Mozillarepo
Repository 'Mozillarepo' has been successfully enabled.

19. 刷新库
示例: 刷新Mozilla库
# zypper refresh Mozillarepo
示例: 自动刷新指定库
# zypper modifyrepo --refresh Linuxprobe_Repo
Autorefresh has been enabled for repository 'Linuxprobe_Repo'.

urpmi

urpmi is a package management system for Mageia/MandrivaLinux and its derivative distributions for installing, removing, upgrading and querying packages locally or remotely (i.e., the server providing the packages). It solves the problem that RPM package administrators tend to make users encounter interdependency hell on a regular basis. It can obtain packages from official or unofficial sources (unofficial sources such as Penguin Liberation Front). It has a graphical front-end: Rpmdrake. Besides being used by MandrivaLinux, it is also used in MageiaLinux (a derivative version based on MandrivaLinux), and ROSALinux (also a branch based on MandrivaLinux).

The urpmi family of commands.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
urpmi  安装或升级
urpme  删除
urpmq  软件包查找
urpmf  文件名查找
urpmi.addmedia 添加源
urpmi.removemedia  删除源
urpmi.update 更新 (升级)
urpmi.update -a 查看所有升级包
urpmi --auto --auto-select 自动升级
urmq --list        列出所有软件包
urpmq --list-media  列出软件源的media
urpmq -d 输出某软件包的依赖信息
urpmq -f 输出某软件包的名字、版本、所属架构
urpmq -i 安装,相当于urpmi
urpmq -y yword> 查找包含某关键字的软件包(或者-a)
urpmf   按某RPM包的准确名字查找

The main urpmi configuration file.

1
2
3
4
5
6
/etc/urpmi/urpmi.cfg   软件源信息
/etc/urpmi/skip.list  非自动升级的软件包列表
/etc/urpmi/inst.list  需安装而非升级的软件包列表
/var/lib/urpmi/list.*  库中所有软件包列表
/var/lib/urpmi/hdlist.* 库中所有软件包的headers
/var/lib/urpmi/synthesis.hdlist.*  软件包的依赖信息

Arch-based package managers

Arch Linux uses a package manager called pacman. Unlike .deb and .rpm, it uses the more traditional LZMA2 package form .tar.xz. This allows Arch Linux packages to have a smaller size than other forms of compression, such as gzip. Since its first release in 2002, pacman has been steadily released and improved. One of the biggest benefits of using it is that it supports the Arch Build System, a build system that builds packages from the source level. The build system relies on a file called PKGBUILD, which contains metadata such as version numbers, release numbers, dependencies, etc., as well as a script with the necessary compilation options needed to compile packages that adhere to Arch Linux requirements. The result of this compilation is the .tar.xz file used by pacman as mentioned earlier.

This system technically led to the creation of the Arch User Respository (AUR), a community-driven software repository that contains PKGBUILD files and support patches or scripts. This has given Arch Linux an endless supply of software resources. The most obvious advantage is that if a user (or developer) wants to make his software available to the general public, he does not have to go through the official route of obtaining a license from a mainstream repository. The downside is that it will have to rely on community processes, similar to Docker Hub, Canonical’s Snap Packages, or other similar mechanisms. There are many AUR-specific package managers that can be used to download, compile, and install PGKBUILD files from the AUR.

Using pacman and official repositories

Arch’s main package manager, pacman, uses identifiers rather than command words like yum or apt. For example, to search for a package, you would use pacman -Ss. As with other commands on Linux, you can find pacman’s manual page and online help. pacman uses the sync (-S) identifier bit for most of its commands.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Pacman 命令详解
    Pacman 是一个命令行工具,这意味着当你执行下面的命令时,必须在终端或控制台中进行。
1、更新系统
    在 Arch Linux 中,使用一条命令即可对整个系统进行更新:
        pacman -Syu
    如果你已经使用 pacman -Sy 将本地的包数据库与远程的仓库进行了同步,也可以只执行:
        pacman -Su
2、安装包
    pacman -S  包名 例如,执行 pacman -S firefox 将安装 Firefox。你也可以同时安装多个包,只需以空格分隔包名即可。
    pacman -Sy 包名 与上面命令不同的是,该命令将在同步包数据库后再执行安装。
    pacman -Sv 包名 在显示一些操作信息后执行安装。
    pacman -U  安装本地包,其扩展名为 pkg.tar.gz。
3、删除包
    pacman -R  包名 该命令将只删除包,不包含该包的依赖。
    pacman -Rs 包名 在删除包的同时,也将删除其依赖。
    pacman -Rd 包名 在删除包时不检查依赖。
4、搜索包
    pacman -Ss 关键字 这将搜索含关键字的包。
    pacman -Qi 包名 查看有关包的信息。
    pacman -Ql 包名 列出该包的文件。
5、其他用法
    pacman -Sw 包名 只下载包,不安装。
    pacman -Sc Pacman 下载的包文件位于 /var/cache/pacman/pkg/ 目录。该命令将清理未安装的包文件。
    pacman -Scc 清理所有的缓存文件。