Linux Admin 简明教程
Linux Admin - Package Management
CentOS 中的软件包管理可以通过两种方式进行:从终端和图形用户界面。
Package management in CentOS can be performed in two ways: from the terminal and from the Graphical User Interface.
大多数情况下,CentOS 管理员的大部分时间都用于终端。更新和安装 CentOS 软件包没有什么不同。考虑到这一点,我们首先将在终端中探讨软件包管理,然后讨论如何使用 CentOS 提供的图形软件包管理工具。
More often than not a majority of a CentOS administrator’s time will be using the terminal. Updating and installing packages for CentOS is no different. With this in mind, we will first explore package management in the terminal, then touch on using the graphical package management tool provided by CentOS.
YUM Package Manager
YUM 是 CentOS 中提供的软件包管理工具。我们已在之前的章节中简要讨论了该主题。在本教程中,我们将从干净的 CentOS 安装开始。我们将首先完全更新我们的安装,然后安装应用程序。
YUM is the tool provided for package management in CentOS. We have briefly touched this topic in previous chapters. In this chapter, we will be working from a clean CentOS install. We will first completely update our installation and then install an application.
YUM 已经极大地促进了 Linux 中的软件安装和管理。除了过时的软件包之外,YUM 还会“自动”检查过时的依赖项。与过去从源代码编译每个应用程序相比,这确实减轻了 CentOS 管理员的负担。
YUM has brought software installation and management in Linux a long way. YUM "automagically” checks for out-of-date dependencies, in addition to out-of-date packages. This has really taken a load off the CentOS administrator compared to the old days of compiling every application from source-code.
yum check-update
用于检查可更新候选软件包的检查。在本教程中,我们将假设此产品系统面向互联网,没有生产应用程序需要在升级软件包之前由 DevOps 测试。接下来,让我们在系统上安装更新后的候选软件包。
Checks for packages that can update candidates. For this tutorial, we will assume this a production system that will be facing the Internet with no production applications that needs to be tested by DevOps before upgrading the packages. Let us now install the updated candidates onto the system.
[root@localhost rdc]# yum check-update
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.scalabledns.com
* extras: mirror.scalabledns.com
* updates: mirror.clarkson.edu
NetworkManager.x86_64 1:1.4.0-19.el7_3 updates
NetworkManager-adsl.x86_64 1:1.4.0-19.el7_3 updates
NetworkManager-glib.x86_64 1:1.4.0-19.el7_3 updates
NetworkManager-libnm.x86_64 1:1.4.0-19.el7_3 updates
NetworkManager-team.x86_64 1:1.4.0-19.el7_3 updates
NetworkManager-tui.x86_64 1:1.4.0-19.el7_3 updates
NetworkManager-wifi.x86_64 1:1.4.0-19.el7_3 updates
audit.x86_64 2.6.5-3.el7_3.1 updates
vim-common.x86_64 2:7.4.160-1.el7_3.1 updates
vim-enhanced.x86_64 2:7.4.160-1.el7_3.1 updates
vim-filesystem.x86_64 2:7.4.160-1.el7_3.1 updates
vim-minimal.x86_64 2:7.4.160-1.el7_3.1 updates
wpa_supplicant.x86_64 1:2.0-21.el7_3 updates
xfsprogs.x86_64 4.5.0-9.el7_3 updates
[root@localhost rdc]#
yum update
这将安装所有更新的候选软件包,从而使您的 CentOS 安装保持最新状态。对于新安装,这可能需要一点时间,具体取决于您的安装和互联网连接速度。
This will install all updated candidates making your CentOS installation current. With a new installation, this can take a little time depending on your installation and your internet connection speed.
[root@localhost rdc]# yum update
vim-minimal x86_64 2:7.4.160-1.el7_3.1 updates 436 k
wpa_supplicant x86_64 1:2.0-21.el7_3 updates 788 k
xfsprogs x86_64 4.5.0-9.el7_3 updates 895 k
Transaction Summary
======================================================================================
Install 2 Packages
Upgrade 156 Packages
Total download size: 371 M
Is this ok [y/d/N]:
Install Software via YUM
除了更新 CentOS 系统之外,YUM 软件包管理器也是我们安装软件的工具。从网络监控工具到视频播放器再到文本编辑器,通过使用 YUM,一切都可从中心存储库安装。
Besides updating the CentOS system, the YUM package manager is our go-to tool for installing the software. Everything from network monitoring tools, video players, to text editors can be installed from a central repository with YUM.
在安装一些软件实用程序之前,让我们先看一下几个 YUM 命令。对于日常工作,90% 的 CentOS 管理员使用 YUM 时都会使用约 7 个命令。我们将在希望熟悉以熟练水平操作 YUM 以供日常使用时逐一加以研究。但是,与大多数 Linux 实用程序一样,YUM 提供了丰富的先进功能,始终值得通过手册页来探讨这些功能。使用 man yum 始终是使用任何 Linux 实用程序执行不熟悉操作的第一步。
Before installing some software utilities, let’s look at few YUM commands. For daily work, 90% of a CentOS Admin’s usage of YUM will be with about 7 commands. We will go over each in the hope of becoming familiar with operating YUM at a proficient level for daily use. However, like most Linux utilities, YUM offers a wealth of advanced features that are always great to explore via the man page. Use man yum will always be the first step to performing unfamiliar operations with any Linux utility.
Most Common YUM Commands
以下是一些常用的 YUM 命令。
Following are the commonly used YUM commands.
Command |
Action |
list installed |
Lists packages installed via YUM |
list all |
Lists all currently available packages |
group list |
Lists grouped packages |
info |
Provides detailed information about a package |
search |
Searches package descriptions and names |
install |
Installs a package |
localinstall |
Installs a local rpm package |
remove |
Removes and installs package |
clean all |
Cleans /var/cache/yum to free disk-space |
man yum |
Like all linux commands, the help file |
Install Software with YUM
现在,我们安装一个基于文本的 Web 浏览器,名为 Lynx 。在安装之前,我们必须首先获取包含 Lynx Web 浏览器在内的软件包名称。我们甚至不能 100% 确定我们的默认 CentOS 存储库是否为 Lynx Web 浏览器提供了一个软件包,所以让我们搜索并查看 −
We will now install a text-based web browser called Lynx. Before installation, we must first get the package name containing the Lynx web browser. We are not even 100% sure our default CentOS repository provides a package for the Lynx web browser, so let’s search and see −
[root@localhost rdc]# yum search web browser
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.scalabledns.com
* extras: mirror.scalabledns.com
* updates: mirror.clarkson.edu
=================================================================
N/S matched: web, browser
==================================================================
icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser
plug-in and Web Start implementation
elinks.x86_64 : A text-mode Web browser
firefox.i686 : Mozilla Firefox Web browser
firefox.x86_64 : Mozilla Firefox Web browser
lynx.x86_64 : A text-based Web browser
Full name and summary matches only, use "search all" for everything.
[root@localhost rdc]#
我们看到,CentOS 确实在存储库中提供了 Lynx Web 浏览器。让我们看看有关该软件包的更多信息。
We see, CentOS does offer the Lynx web browser in the repository. Let’s see some more information about the package.
[root@localhost rdc]# lynx.x86_64
bash: lynx.x86_64: command not found...
[root@localhost rdc]# yum info lynx.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.scalabledns.com
* extras: mirror.scalabledns.com
* updates: mirror.clarkson.edu
Available Packages
Name : lynx
Arch : x86_64
Version : 2.8.8
Release : 0.3.dev15.el7
Size : 1.4 M
Repo : base/7/x86_64
Summary : A text-based Web browser
URL : http://lynx.isc.org/
License : GPLv2
Description : Lynx is a text-based Web browser. Lynx does not display any images,
: but it does support frames, tables, and most other HTML tags. One
: advantage Lynx has over graphical browsers is speed; Lynx starts and
: exits quickly and swiftly displays web pages.
[root@localhost rdc]#
不错!版本 2.8 已经是最新的了,所以让我们安装 Lynx。
Nice! Version 2.8 is current enough so let’s install Lynx.
[root@localhost rdc]# yum install lynx
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.scalabledns.com
* extras: mirror.scalabledns.com
* updates: mirror.clarkson.edu
Resolving Dependencies
--> Running transaction check
---> Package lynx.x86_64 0:2.8.8-0.3.dev15.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================
===============================================================================
Package Arch
Version Repository Size
===============================================================================
===============================================================================
Installing:
lynx x86_64
2.8.80.3.dev15.el7 base 1.4 M
Transaction Summary
===============================================================================
===============================================================================
Install 1 Package
Total download size: 1.4 M
Installed size: 5.4 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for base
lynx-2.8.8-0.3.dev15.el7.x86_64.rpm
| 1.4 MB 00:00:10
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : lynx-2.8.8-0.3.dev15.el7.x86_64
1/1
Verifying : lynx-2.8.8-0.3.dev15.el7.x86_64
1/1
Installed:
lynx.x86_64 0:2.8.8-0.3.dev15.el7
Complete!
[root@localhost rdc]#
接下来,让我们确保 Lynx 确实正确安装了。
Next, let’s make sure Lynx did in fact install correctly.
[root@localhost rdc]# yum list installed | grep -i lynx
lynx.x86_64 2.8.8-0.3.dev15.el7 @base
[root@localhost rdc]#
太棒了!让我们使用 Lynx 来看看没有“喜欢”和漂亮图片的 Web 界面。
Great! Let’s use Lynx to and see what the web looks like without "likes" and pretty pictures.
[root@localhost rdc]# lynx www.tutorialpoint.in

太棒了,现在我们为我们的生产服务器配置了一个 Web 浏览器,无需过分担心通过 Web 发起的远程利用。这对生产服务器来说是一件好事。
Great, now we have a web browser for our production server that can be used without much worry into remote exploits launched over the web. This a good thing for production servers.
我们几乎完成了,然而我们首先需要为开发人员设置该服务器来测试应用程序。因此,让我们确保他们拥有完成工作所需的所有工具。我们可以单独安装所有内容,但是 CentOS 和 YUM 让这个过程快了很多。让我们安装开发群组软件包。
We are almost completed, however first we need to set this server for developers to test applications. Thus, let’s make sure they have all the tools needed for their job. We could install everything individually, but CentOS and YUM have made this a lot faster. Let’s install the Development Group Package.
[root@localhost rdc]# yum groups list
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.scalabledns.com
* extras: mirror.scalabledns.com
* updates: mirror.clarkson.edu
Available Groups:
Compatibility Libraries
Console Internet Tools
Development Tools
Graphical Administration Tools
Legacy UNIX Compatibility
Scientific Support
Security Tools
Smart Card Support
System Administration Tools
System Management
Done
[root@localhost rdc]#
这是 CentOS 提供的较小的一组软件包群组。让我们看看“开发群组”中包含哪些内容。
This is a smaller list of Package Groups provided by CentOS. Let’s see what is included with the "Development Group".
[root@localhost rdc]# yum group info "Development Tools"
Loaded plugins: fastestmirror, langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirror.scalabledns.com
* extras: mirror.scalabledns.com
* updates: mirror.clarkson.edu
Group: Development Tools
Group-Id: development
Description: A basic development environment.
Mandatory Packages:
autoconf
automake
binutils
bison
输出的第一个屏幕类似于上面看到的。这个完整列表包括很多内容。但是,随着时间的推移,通常需要完整安装此群组。让我们安装完整的开发群组。
The first screen of output is as seen above. This entire list is rather comprehensive. However, this group will usually be needed to be installed in its entirety as time goes by. Let’s install the entire Development Group.
[root@localhost rdc]# yum groupinstall "Development Tools"
这将是一个更大的安装。完成后,你的服务器将拥有大多数用于 Perl、Python、C 和 C++ 语言的开发库和编译器。
This will be a larger install. When completed, your server will have most development libraries and compilers for Perl, Python, C, and C++.
Graphical Package Management in CentOS
Gnome 桌面提供了一个称为 Software 的图形化软件包管理工具。它相当简单易用。CentOS 的 Gnome 软件包管理工具软件可以找到这里:应用程序 → 系统工具 → 软件。
Gnome Desktop provides a graphical package management tool called Software. It is fairly simple to use and straightforward. Software, the Gnome package management tool for CentOS can be found by navigating to: Applications → System Tools → Software.
软件包管理工具分为多个群组,允许管理员选择要安装的软件包。虽然这款工具易于使用,并且对最终用户而言非常简单,但是 YUM 更加强大,可能被管理员更多地使用。
The Software Package Management Tool is divided into groups allowing the administrator to select packages for installation. While this tool is great for ease-of-use and simplicity for end-users, YUM is a lot more powerful and will probably be used more by administrators.
以下是软件包管理工具的屏幕截图,该工具并非专门为系统管理员设计。
Following is a screenshot of the Software Package Management Tool, not really designed for System Administrators.
