0Pricing
Linux Command Line Mastery · 课时

软件包管理(CentOS/Fedora):`yum`、`dnf`、`rpm`

了解如何在基于 Red Hat 的系统上使用 `yum`、`dnf` 和 `rpm` 管理软件包。

软件包管理(CentOS/Fedora):`yum`、`dnf`、`rpm` 是 CoddyKit 上的免费 Linux Command Line Mastery 课时。 这是第 3 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Linux Command Line Mastery 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Linux Command Line Mastery 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

Intro to Package Management

Welcome to package management on CentOS/Fedora! Software on Linux systems is often distributed in 'packages'.

A package manager helps you install, update, configure, and remove software packages, as well as manage their dependencies (other software they rely on).

On Red Hat-based systems like CentOS and Fedora, we primarily use three tools: rpm, yum, and dnf.

RPM: The Foundation

At its core, all Red Hat-based systems use the Red Hat Package Manager (RPM). Think of rpm as the low-level tool.

It directly handles .rpm files, which contain compiled software and metadata. However, rpm doesn't automatically resolve dependencies.

  • Install: rpm -i package.rpm
  • Query: rpm -q package_name
  • Remove: rpm -e package_name

Querying Packages with RPM

Let's see how to query information about an installed package using rpm. The -q flag is for querying.

rpm -q bash checks if the 'bash' shell is installed. rpm -qi bash gives more detailed information.

rpm -q bash
rpm -qi bash

YUM: Solving Dependencies

Manually managing dependencies with rpm can be tedious. This is where YUM (Yellowdog Updater, Modified) came in.

yum is a higher-level tool built on top of rpm. It automatically searches repositories, resolves dependencies, and installs all necessary packages.

For many years, yum was the standard package manager for CentOS and older Fedora versions.

Installing Software with YUM

Using yum is much simpler for everyday tasks. To install a package, you just need its name.

Let's try installing a simple text editor like nano. You'll often need sudo for installation commands.

sudo yum install nano

Updating & Removing with YUM

yum makes it easy to keep your system updated and manage installed software.

  • Update all: sudo yum update
  • Update specific: sudo yum update package_name
  • Remove: sudo yum remove package_name
  • Search: yum search keyword

These commands handle all dependencies for you!

DNF: The Modern Standard

DNF (Dandified YUM) is the next-generation package manager, now standard in modern Fedora and CentOS Stream/8+.

It's an improved version of yum, offering better performance, more robust dependency resolution, and a cleaner codebase.

The good news? Most yum commands work almost identically with dnf!

DNF Basic Operations

Let's see dnf in action. Its syntax is very similar to yum.

We can use dnf to list available or installed packages, or to install new ones. Try listing all installed packages that include 'nano' in their name.

sudo dnf install nano
dnf list installed | grep nano

Managing Software Groups with DNF

One powerful feature of dnf (and yum) is the ability to manage software groups. These are collections of related packages for common tasks.

For example, you can install a 'Development Tools' group which includes compilers, debuggers, and other utilities.

dnf group list

Package Manager Quiz

Test your knowledge on CentOS/Fedora package managers!

Recap: CentOS/Fedora PM

You've explored the essential package managers for CentOS/Fedora:

  • rpm: The low-level foundation, handles individual .rpm files.
  • yum: The classic high-level manager, resolves dependencies automatically.
  • dnf: The modern, faster, and more robust successor to yum.

Mastering these tools is key to managing software effectively on Red Hat-based Linux systems. Keep practicing!

常见问题解答

「软件包管理(CentOS/Fedora):`yum`、`dnf`、`rpm`」课时是免费的吗?

是的 — 「软件包管理(CentOS/Fedora):`yum`、`dnf`、`rpm`」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Linux Command Line Mastery 课程的其余内容,请升级到 CoddyKit PRO。 Linux Command Line Mastery 课程共包含 4 节课。

「软件包管理(CentOS/Fedora):`yum`、`dnf`、`rpm`」这节课中我会学到什么?

了解如何在基于 Red Hat 的系统上使用 `yum`、`dnf` 和 `rpm` 管理软件包。 你通过在浏览器中直接运行的动手代码来练习 Linux Command Line Mastery,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Linux Command Line Mastery 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Linux Command Line Mastery 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 3 节课,共 4 节。

「软件包管理(CentOS/Fedora):`yum`、`dnf`、`rpm`」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Linux Command Line Mastery 课中编写并运行代码吗?

能。每节 Linux Command Line Mastery 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 归档与压缩:`tar`、`gzip`、`bzip2`
  2. 软件包管理(Debian/Ubuntu):`apt`、`dpkg`
  3. 软件包管理(CentOS/Fedora):`yum`、`dnf`、`rpm`
  4. 从源代码构建:configure、make 与 make install
← 返回 Linux Command Line Mastery