Linux(四)软件包管理

2023-06-13,,

软件包管理

1 RPM

简介

RPM(RedHat Package Manager),是红帽系linux操作系统的软件包管理工具,类似于windows中的setup.exe能够进行软件包的更新、卸载、安装甚至直接从源码包中build一个软件出来。

非红帽系操作系统如Ubuntu的软件包安装管理就是apt,apt get进行软件暗安装

RPM包的名称格式

如Apache-1.3.23-11.i386.rpm,Apache代表软件名称,1.3.23-11代表版本号,i386表示运行环境为intel64位处理器。

基本命令
rpm -qa 查询所有安装的rpm软件包

选项说明

-q:查询

-a:查询所有的包

-i:查询指定的包的详细信息

[root@hadoop100 ~]# rpm -qa | grep redis
redis-3.2.12-2.el7.x86_64
[root@hadoop100 ~]# rpm -qa | grep firefox
firefox-68.10.0-1.el7.centos.x86_64
[root@hadoop100 ~]# rpm -qi firefox
Name : firefox
Version : 68.10.0
Release : 1.el7.centos
Architecture: x86_64
Install Date: Thu 11 Aug 2022 09:06:35 PM PDT
Group : Unspecified
Size : 241030932
License : MPLv1.1 or GPLv2+ or LGPLv2+
Signature : RSA/SHA256, Wed 08 Jul 2020 09:21:14 AM PDT, Key ID 24c6a8a7f4a80eb5
Source RPM : firefox-68.10.0-1.el7.centos.src.rpm
Build Date : Tue 07 Jul 2020 11:51:10 AM PDT
Build Host : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : https://www.mozilla.org/firefox/
Summary : Mozilla Firefox Web browser
Description :
Mozilla Firefox is an open-source web browser, designed for standards
compliance, performance and portability.
rpm -e 卸载软件

-nodeps:卸载的时候不要考虑安装包之间的依赖关系,直接卸载即可

[root@hadoop100 ~]# rpm -e redis
warning: /etc/redis.conf saved as /etc/redis.conf.rpmsave
rpm-i 安装软件

选项说明

-i:安装

-v:显示详细信息

-h:显示进度条

--nodeps:不检查依赖

npm存在的问题

安装必须要有rpm安装包

安装、卸载都需要考虑软件包之间的依赖关系

2 YUM

简介
基本命令

yum [选项][参数]

-y:一路yes

install:安装rpm软件包

update:更新rpm软件包

check-update:检查更新

remove:删除指定rpm软件包

list:显示软件包信息

clean:清除过期缓存

deplist:显示yum软件包的依赖关系

修改yum源

配置文件

less /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
# [base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

yum会去自动查找IP最近的源,一般情况下不需要修改

想要修改可以先备份一下配置文件,然后使用wget下载repos文件

wget \http://mirrors.ailiyun.com/repo/Centos-7.repo

wget \http://mirrors.163.com/.help/Centos7-Base-163.repo

克隆虚拟机

Linux(四)软件包管理的相关教程结束。

《Linux(四)软件包管理.doc》

下载本文的Word格式文档,以方便收藏与打印。