Skip to Content
实用 Linux 系统管理
book

实用 Linux 系统管理

by Kenneth Hess
May 2025
Intermediate to advanced
248 pages
3h 18m
Chinese
O'Reilly Media, Inc.
Content preview from 实用 Linux 系统管理

第 6 章 安装和卸载软件 安装和卸载软件

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

安装和卸载软件是系统管理员的基本任务。您可能不会每天都执行这些任务,但这些都是您和您的团队要完成的常规任务。最常见的是安装更新,这可以自动完成。您安装的任何新软件都应附有业务理由、变更控制记录以及请求方对安全影响(如有)的书面理解。安装存在已知漏洞的软件是恶意行为者入侵系统的便捷途径。

卸载软件也需要变更控制记录,因为删除其他关键系统或服务功能所需的软件包、目录或库有潜在危险。

有三种软件安装方法:使用软件包管理器从软件源安装、安装下载到本地文件系统的单个软件包以及编译源代码。本章将介绍所有三种方法。卸载软件有两种标准方法:使用软件包管理工具;如果是编译软件,则使用卸载程序。第三种非标准卸载方法是通过删除目录、库和二进制文件手动卸载软件。

手动删除软件是一项繁琐的工作,只有高级别的系统管理员才能胜任。本章各节将教你如何用特定方法安装软件,然后用同样的方法卸载软件。

在讨论安装和卸载软件之前,我将向你介绍如何更新系统。因为更新非常重要,所以值得首先讨论,而且由于更新系统的价值很高,所以应该在执行其他任务之前进行更新。在排除故障时,您应该始终更新系统,以检查简单的更新是否能解决您的问题。快速的系统更新可能会减轻为解决问题而删除或安装新软件的需要。

备注

本章中的所有演示和示例均使用 CentOS 8.3 (server1) 和 Ubuntu Server 20.04 LTS (server2) 。我首先在server1 上执行所有任务,然后在server2 上执行,并注意两个系统之间的任何差异。 示例中使用的软件包是 Lynx,这是一款基于文本的轻量级浏览器。

更新系统

我在本书中多次提到要保持系统更新。 这是一项需要牢记的重要任务。它应该是你的首要任务之一。更新是标准维护的一部分。许多系统管理员每周都会进行更新,这是很好的做法。 但在需要时,也要毫不犹豫地应用补丁、更新和升级,以减少漏洞。安全是重中之重。以下两节将说明如何在系统中应用更新。

应用基于 Red Hat Enterprise Linux 的系统更新

基于 Red Hat Enterprise Linux 的系统使用 YUM/DNF 实用程序来维护更新和软件库中的软件安装。摘自Red Hat 官方文档

YUM/DNF (yum/dnf) 是从 Red Hat 官方软件源以及其他第三方软件源中获取、安装、删除、查询和管理 Red Hat Enterprise Linux RPM 软件包的主要工具。YUM/DNF 用于 Red Hat Enterprise Linux 5 及更新版本。

DNF 是该工具最新的版本,因此我将两者合并在一起。根据文档,DNF 是 YUM 第 4 版,是从 Red Hat EnterpriseLinux 第 8 版开始使用的工具。要开始更新,请执行yumdnf 命令:

 $ sudo yum update Last metadata expiration check: 1:52:37 ago on Sun 07 Nov 2021 07:14:51 PM CST. Dependencies resolved. ================================================================================= Package Architecture ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Linux for IBM eServer zSeries and S/390: Distributions

Linux for IBM eServer zSeries and S/390: Distributions

Michael MacIsaac, Ronald Annuss, Wolfgang Engel, Chris Gombola, Timothy Nunes, Mark Post, Don Stubbs, Egon Terwedow, Craig Vernon
Linux Server Hacks, Volume Two

Linux Server Hacks, Volume Two

William von Hagen, Brian K. Jones

Publisher Resources

ISBN: 9798341658547