Linux入门(12)——软件管理

Linux入门(12)——软件管理


1. Linux中软件格式

- 安装包格式

	DEB 			#	UBlinux DEBlinux
	RPM 			#	redhat centOS fadora 

- 压缩包格式

	bz2|gz|xz		#	1.解压后直接运行
					#	2.解压,编译后才可运行

- 安装包信息

	[http-server]-[6.3.6-29].[el8].[x86_64].[rpm]
		 a		  	  b		   c	  d	      e
	a.软件名
	b.版本
	c.授权协议版本
	d.运行平台架构
	e.后缀

2. rpm命令管理软件

[root@rhclient Desktop]# rpm -[options]	software	# 安装管理软件
options功能
-i安装该软件包
-v显示指令执行过程
-h显示安装进度
-a查询所有已安装的
-f文件
-p软件包
-q查询
-l软件安装文件列表
-e卸载软件包
-c配置文件
-d说明
–info软件信息
–force强制安装
–nodeps忽略依赖性
–script显示在安装或卸载过程中的运行脚本
-Kv检测md5校验码
-V检测已安装软件的文件被修改信息

rpm命令安装软件时无法解决依赖关系,需要配置软件仓库。

3. dnf 软件管理命令

[root@rhclient Desktop]# dnf -[options]	software	# 管理软件
options功能
dnf repolist列出仓库的信息
clean all清除系统中已经加载的仓库缓存信息
list all列出所有软件
list available列出未安装软件
list installed列出已安装软件
install安装某软件
remove卸载某软件
reinstall重新安装某软件
search搜索包含关键词的软件包
whatprovides搜索包含文件的软件包
historydnf成功执行历史
history infodnf执行历史详细信息
group list列出软件组
group list --installed列出已安装软件组
group list --available列出未安装软件组
group list --hidden列出隐藏软件案组
group install安装软件组
group info查看软件组信息
[root@rhclient Desktop]# yumdownloader 			#下载软件包到本机指定位置
[root@rhclient Desktop]# yumdownloader httpd --destdir=/mnt --resolve #下载httpd 安装包和软件依赖性到/mnt目 录

4. 软件仓库配置

- 本地软件仓库

  • 首先,挂载镜像文件至指定目录。
[root@rhclient Desktop]# mount rhel8.2.iso /dir
  • 然后,修改软件源配置文件指向该目录。
[root@rhclient Desktop]# vim /etc/yum.repos.d/xxx.repo 
	[AppStream] 									#仓库名称
	name=AppStream 									#描述
	baseurl=file:///dir/AppStream 					#地址
	gpgcheck=0 										#不检测gpgkey (跳过授权检测)
	gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-REDHAT-release	#授权文件目录
	enabled=1|0 									#是否开启该软件仓库
	
	[BaseOS]
	name=BaseOS
	baseurl=file:///dir/BaseOS/
	gpgcheck=0
  • 清除dnf缓存,重新加载软件仓库。
[root@rhclient Desktop]# dnf clean all
[root@rhclient Desktop]# dnf repolist

- 本地第三方软件仓库

  • 首先,将需要安装的第三方rpm软件存放在同一目录下。
  • 在目录下生成repodate目录文件。
[root@rhclient Desktop]# dnf install createrepo -y 		# 安装采集工具
[root@rhclient Desktop]# cd /dir/software 				# 进入到共享目录
[root@rhclient Desktop]# createrepo . 		# 扫描目录生成repodate数据目录
  • 修改软件仓库配置文件,指向该目录。
[root@rhclient Desktop]# vim /etc/yum.repos.d/xxx.repo
 [software]
 name=software
 baseurl=///dir/software
 gpgcheck=0
  • 清除dnf缓存,重新加载软件仓库。
[root@rhclient Desktop]# dnf clean all
[root@rhclient Desktop]# dnf repolist

- 网络软件仓库

客户端主机IP为192.168.158.128
服务端主机IP为192.168.158.129

  • 在服务端安装并启用Apache服务器
[root@rhserver Desktop]# dnf install httpd -y		# 安装Apache
[root@rhserver Desktop]# systemctl stop firewalld 	 # 关闭防火墙
[root@rhserver Desktop]# systemctl disable firewalld 	# 停止启用防火墙
[root@rhserver Desktop]# systemctl enable --now httpd 	# 开启Apache
  • 在服务端挂载软件镜像至Apache共享目录,并设置开机自动挂载
[root@rhserver Desktop]# mkdir /var/www/html/dir
[root@rhserver Desktop]# mount /xxxxxxx.iso /var/www/html/dir #挂载

[root@rhserver Desktop]# vim /etc/rc.d/rc.local  # 在开机时自动挂载
mount /xxxx.iso /var/www/html/dir  # 在rc.local 中增加内容
[root@rhserver Desktop]# chmod 755 /etc/rc.d/rc.local
  • 在客户端修改软件仓库配置文件
[root@rhclient Desktop]#vim /etc/yum.repos.d/xxx.repo
	[AppStream]
	name=AppStream
	baseurl=http://192.168.158.129/dir/AppStream/
	gpgcheck=0
	
	[BaseOS]
	name=BaseOS
	baseurl=http://192.168.158.129/dir/BaseOS/
	gpgcheck=0
	
#	第三方软件仓库也可以共享。
#	只需要将软件包放在服务端Apache共享目录下并生成repo数据。
#	在客户端指定服务端目录即可。		
 
	[software]
	name=software
	baseurl=http://192.168.158.129/dir/software
	gpgcheck=0

5. 配置练习

  • 本地仓库
    开机挂载在这里插入图片描述
    在这里插入图片描述在这里插入图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值