Linux下的软件管理

#####1.软件安装包格式类型###################

rpm:redhat linux(suse centos redhat) 

deb:ub deb

tar:绿色软件     源码编译

#####2.rmp包名称分析#####################

<dhcp>-<4.2.5-68>.<el7_5.1>.<x86_64>.<rpm>

Linux下的软件管理

1.软件名称      2.软件版本     3.软件授权     4.软件多少位     5.软件后缀表示软件包是rpm类型的

##在管理rpm软件包时用rpm命令

 

#####3.rpm命令################

一.rpm 管理命令:

-ivh 安装
-v 显示过程
-h hash检测查看团建中的hash值是否有改变
-i install安装
-e 卸载
-q 查看
-a 所有
-qa 查看所有安装过的软件
-l 列出安装然后在系统中生成的文件
-p 操作对象为软件包
--scripts 查看团建在安装或卸载时在系统中执行的脚本
--force 强制安装
-nodeps 忽略软件依赖性的软件
-K 检测软件是否是原版软件

 

 

 

 

 

 

 

 

 

 

 

 

 

 

设定实验环境:

1.mkdir /westos

[[email protected] ~]# mkdir /westos

2.在虚拟机光驱中添加系统匹配景象

3.挂在景象到 /westos

[[email protected] ~]# mount /dev/cdrom /westos/

Linux下的软件管理

4.ls /westos

Linux下的软件管理

实验:

[[email protected] ~]# cd /westos   ##进入根目录westos

[[email protected] westos]# cd Packages/  ##进入目录

Linux下的软件管理

[[email protected] Packages]# rpm -qa | grep dhcp  ##查看安装

Linux下的软件管理

[[email protected] Packages]# rpm -ivh dhcp-4.2.5-68.el7_5.1.x86_64.rpm

Linux下的软件管理

[[email protected] Packages]# rpm -e dhcp-4.2.5-68.el7_5.1.x86_64

Linux下的软件管理

[[email protected] Packages]# rpm -qp dhcp-4.2.5-68.el7_5.1.x86_64.rpm

Linux下的软件管理

[[email protected] Packages]# rpm -qlp dhcp-4.2.5-68.el7_5.1.x86_64.rpm

Linux下的软件管理

[[email protected] Packages]# rpm -qp dhcp-4.2.5-68.el7_5.1.x86_64.rpm --scripts

Linux下的软件管理

[[email protected] Packages]# rpm -ivh dhcp-4.2.5-68.el7_5.1.x86_64.rpm --force

Linux下的软件管理

Linux下的软件管理

-K:

先篡改软件包内容

Linux下的软件管理

[[email protected] mnt]# rpm -Kv dhcp-4.2.5-68.el7_5.1.x86_64.rpm

Linux下的软件管理

对比:

Linux下的软件管理

二.软件包如何拆解

[[email protected] mnt]# rpm2cpio dhcp-4.2.5-68.el7_5.1.x86_64.rpm | cpio -id

Linux下的软件管理

#####4.yum软件仓库##################

一.软件仓库搭建的目的:

rpm不能自动解决软件依赖关系

yum仓库可以解决此问题

二.搭建软件仓库步骤

1.得到与当前系统匹配的系统安装景象文件

2.建立系统安装景象挂载点:

[[email protected] ~]# mkdir /softwaresource

3.挂载景象到景象挂载点:

[[email protected] yum.repos.d]# mount /dev/cdrom /softwaresource/

4.配置系统访问软件路径(yum仓库指向文件)

[[email protected] ~]# cd /etc/yum.repos.d/

 

实验:

在rhel7中

[[email protected] yum.repos.d]# rm -fr *    ##清空系统环境

Linux下的软件管理

[[email protected] yum.repos.d]# vim westos.repo   ##编写文件

Linux下的软件管理

[westosrhel7]                                 ##仓库名称
name=westos rhel7 source           ##仓库描述
baseurl=file:///softwaresource       ##资源路径
gpgcheck=0|1                               ##软件包授权检测开关
enabled=1                                     ## 仓库启用开关

[[email protected] yum.repos.d]# yum repolist    ##查看

Linux下的软件管理

注意:

[[email protected] yum.repos.d]# vim westos.repo

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release   ##软件包授权码

Linux下的软件管理

[[email protected] yum.repos.d]# yum install httpd  ##安装   (3个y)

Linux下的软件管理

[[email protected] yum.repos.d]# yum remove httpd   ##卸载

[[email protected] yum.repos.d]# vim westos.repo   ##编辑文件(不检测)

Linux下的软件管理

[[email protected] ~]# yum install httpd   ##安装

Linux下的软件管理

rhel8中:

[[email protected] ~]# mkdir /softwaresource  ##建立根目录

Linux下的软件管理

[[email protected] yum.repos.d]# vim westos.repo   ##编写文件

Linux下的软件管理

 

5.清空yum缓存识别新文件案内容

rhel7:yum clean all

rhel8:dnf clean all

#####5.yum命令################

yum install 安装
yum remove 卸载
yum reinstall 重新安装
yum list installed|available|all|软件名称 列出
yum update 更新
yum repolist 列出仓库信息
yum history 查看yum历史
yum info 查看软件包信息
yum clean all 清除yum缓存
yum search 根据软件信息搜索
yum whatprovides 根据软件包含文件搜索
yum groups install 组安装
yum groups remove 组卸载
yum groups info 组信息

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[[email protected] ~]# yum search dhcp

Linux下的软件管理

[[email protected] ~]# yum install dhcp.x86_64

Linux下的软件管理

[[email protected] ~]# yum reinstall dhcp.x86_64 -y    ##-y 不提示直接安装

Linux下的软件管理

[[email protected] ~]# yum remove dhcp

Linux下的软件管理

[[email protected] ~]# yum list dhcp

Linux下的软件管理

[[email protected] ~]# yum list all

Linux下的软件管理

[[email protected] ~]# yum update dhcp

Linux下的软件管理

[[email protected] ~]# yum repolist

Linux下的软件管理

[[email protected] ~]# yum history

Linux下的软件管理

[[email protected] ~]# yum  info dhcp

Linux下的软件管理

[[email protected] ~]# yum search web

Linux下的软件管理

[[email protected] ~]# yum whatprovides date

Linux下的软件管理

Linux下的软件管理

[[email protected] ~]# yum reinstall coreutils-8.22-23.el7.x86_64   ##安装删除项

Linux下的软件管理

[[email protected] ~]# yum groups info Virtualization\ Client

Linux下的软件管理

[[email protected] ~]# yum groups install "Virtualization Client"

Linux下的软件管理

注意:rhel8中用dnf  (yum 也可用)

#####6.第三方软件仓库#####################

把所有rpm结尾的软件包存放到一个目录 /software 中

[[email protected] ~]# mkdir /software

[[email protected] ~]# cd /root/Downloads/

[[email protected] Downloads]# mv /root/Downloads/kolourpaint-* /software

Linux下的软件管理

[[email protected] software]# vim /etc/yum.repos.d/westos.repo   ##编写指定文件

Linux下的软件管理

[[email protected] software]# yum clean all

Linux下的软件管理

[[email protected] software]# createrepo -v /software  ##生成软件数据库存放软件属性

Linux下的软件管理

[[email protected] software]# yum search kolourpaint     ##检测

Linux下的软件管理