Mastering Linux System Administration. Richard BlumЧитать онлайн книгу.
Then try to use the upgrade
option in the dnf
command. Sometimes, just cleaning up any misplaced files can help.
If that doesn't solve the problem, try the following command:
dnf repoquery --deplist package_name
This command displays all the package's library dependencies and what software package provides them. Once you know the libraries required for a package, you can then install them. Here's an example of determining the dependencies for the zsh package:
# dnf repoquery --deplist zsh CentOS Linux 8 - AppStream 1.3 MB/s | 6.2 MB 00:04 CentOS Linux 8 - BaseOS 867 kB/s | 2.3 MB 00:02 package: zsh-5.5.1-6.el8_1.2.x86_64 dependency: /bin/sh provider: bash-4.4.19-12.el8.x86_64 dependency: coreutils provider: coreutils-8.30-8.el8.x86_64 dependency: grep provider: grep-3.1-6.el8.x86_64 dependency: info provider: info-6.5-6.el8.x86_64 dependency: libc.so.6(GLIBC_2.15)(64bit) provider: glibc-2.28-127.el8.x86_64 dependency: libdl.so.2()(64bit) provider: glibc-2.28-127.el8.x86_64 dependency: libdl.so.2(GLIBC_2.2.5)(64bit) provider: glibc-2.28-127.el8.x86_64 dependency: libgdbm.so.6()(64bit) provider: gdbm-libs-1:1.18-1.el8.x86_64 dependency: libm.so.6()(64bit) provider: glibc-2.28-127.el8.x86_64 dependency: libm.so.6(GLIBC_2.2.5)(64bit) provider: glibc-2.28-127.el8.x86_64 dependency: libm.so.6(GLIBC_2.23)(64bit) provider: glibc-2.28-127.el8.x86_64 dependency: libncursesw.so.6()(64bit) provider: ncurses-libs-6.1-7.20180224.el8.x86_64 dependency: libpcre.so.1()(64bit) provider: pcre-8.42-4.el8.x86_64 dependency: librt.so.1()(64bit) provider: glibc-2.28-127.el8.x86_64 dependency: librt.so.1(GLIBC_2.2.5)(64bit) provider: glibc-2.28-127.el8.x86_64 dependency: libtinfo.so.6()(64bit) provider: ncurses-libs-6.1-7.20180224.el8.x86_64 dependency: rtld(GNU_HASH) provider: glibc-2.28-127.el8.i686 provider: glibc-2.28-127.el8.x86_64 #
As you can see from the output, there are lots of different packages that must be installed for the Z shell to work properly. Good thing dnf
ensured they were all installed for us!
Working with RPM Repositories
Just like the apt
systems, dnf
has its software repositories set up at installation. For most purposes, these preinstalled repositories will work just fine for your needs. But if and when the time comes that you need to install software from a different repository, here are some things you will need to know.
ROGUE REPOSITORIES
These days, it's always a good idea to stick with approved repositories. An approved repository is one that is sanctioned by the distribution's official site. If you start adding unapproved repositories, you lose the guarantee of stability. And you will be heading into broken dependencies territory.
To see what repositories you are currently pulling software from, use the repolist
option.
# dnf repolist repo id repo name appstream CentOS Linux 8 - AppStream baseos CentOS Linux 8 - BaseOS extras CentOS Linux 8 - Extras #
If you don't find a repository you need software from, then you will need to do a little configuration file editing. There are two places where the dnf
repository definitions can be located.
In the /etc/dnf/dnf.conf configuration file
As separate files in the /etc/yum.repos.d directory
Good repository sites such as rpmfusion.org will lay out all the steps necessary to use them. Sometimes these repository sites will offer an RPM file that you can download and install. The installation of the RPM file will do all the repository setup work for you!
Working Directly with Packages
There may be some environments where your Linux server won't have Internet access to contact the repository to automatically download packages. For example, often high‐security environments block all network traffic except internal traffic. In these environments, you'll need a way to manually install or update software packages.
The main tool for working with .rpm
files is the rpm
program. The rpm
utility is a command‐line program to install, modify, and remove .rpm
software packages. Its basic format is as follows:
rpm action [OPTION] package
Table 5.1 describes the actions for the rpm
command.
TABLE 5.1: The rpm
Command Actions
SHORT | LONG | DESCRIPTION |
---|---|---|
‐e
|
‐‐erase
|
Removes the specified package |
‐F
|
‐‐freshen
|
Upgrades a package only if an earlier version already exists |
‐i
|
‐‐install
|
Installs the specified package |
‐q
|
‐‐query
|
Queries if the specified package is installed |
‐U
|
‐‐upgrade
|
Installs or upgrades the specified package |
‐V
|
‐‐verify
|
Verifies if the package files are present and the package's integrity |
The following sections show how to use the rpm
command to manually manage software packages.
Finding Package Files
If you need to obtain copies of RPM files on a Red Hat–based distro, such as CentOS or Fedora, you have a few different options. If you have a separate Linux system connected to the Internet, use the yumdownloader
utility. This downloads a specified rpm package file directly from the repository. The yumdownloader
tool is part of the yum‐utils
package, which you'll most likely need to install first; then you can download any rpm package from the repository.
$ yumdownloader zsh Last metadata expiration check: 0:21:30 ago on Sat 05 Dec 2020 08:49:35 AM EST. zsh-5.5.1-6.el8_1.2.x86_64.rpm 1.1 MB/s | 2.9 MB 00:02 $ ls -l zsh* -rw-r--r--. 1 root root 3039264 Dec 5 09:11 zsh-5.5.1-6.el8_1.2.x86_64.rpm $
The other method for obtaining rpm package files is using the distribution website. Most Linux distributions provide direct access to RPM files used in the distribution via a download site. For CentOS, click the RPMs
link on the Download page (mirror.centos.org/centos/8 /
at the time of this writing), next to the distribution version you have installed on the server. This takes you to a repository of all the current rpm packages for that distribution.
Inspecting Package Files
Use the ‐q
action to perform a simple query on the package management database