第八单元 Linux系统中的软件管理

本文详细介绍了Linux中软件包的类型,包括DEB和RPM,以及需要编译的源码包。讲解了软件包名称结构及其含义,并重点阐述了rpm命令的使用方法。此外,还详细讲解了如何搭建本地和网络软件仓库,以及如何解决软件依赖关系。最后,通过实例演示了第三方仓库的搭建和软件的安装流程。
摘要由CSDN通过智能技术生成

Linux中软件包的类型

(1) DEB               UBlinux DEBlinux

(2) RPM              redhat centOS fadora
(3) bz2|gz|xz      1.需要源码安装需要编译
                           2.绿色软件,直接可用
                        ntfs-3g_ntfsprogs-2017.3.23.tgz     需要编译 "configure"
                        Firefox - latest - x86_64.tar.bz2          绿色
"注意在rhel8中只能使用绿色软件,源码编译软件和rpm软件"

软件包的名称结构

[dhcp-server]-[4.3.6-30].[el8].[x86_64].[rpm]
1                          2           3         4          5
1.软件名称
2.软件版本
3.软件的授权协议版本
4.软件架构
5.软件类型后缀

rpm命令管理软件包 

rpm       -ivh         安装参数组合 -i install -v verbose -h hash
             -a            所有
             -f             文件
             -p            软件包
             -q            查询
             -l             软件安装文件列表
             -e            卸载
             -c            配置文件
             -d            说明
             --info       软件信息
             --force     强制
             --nodeps 忽略依赖性
             --script     查询软件在安装或卸载过程中的运行脚本
             -Kv           检测软件md5校验码
             -V               检测已安装软件在系统中的文件被修改信息

本地软件仓库的搭建

系统软件仓库的作用
在系统中对软件进行管理 ,rpm命令是不能解决依赖关系的
如果需要软件在安装过程中自动解决依赖关系 需要大家系统软件仓库
搭建方法
1. wget /iso/ois/rhel_8.2_x86_64_dvd.iso
2. mount /iso/rhel_8.2_x86_64_dvd.iso /westos   (出现read-only 挂载成功)
3.cd /etc/yum.repos.d/
4.vim westos.repo
编辑内容:
[AppStream]
name=westos AppStream
baseurl=file:///westos/AppStream
gpgcheck=0   不检测
(gpgcheck=1   gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-REDHAT-release)
enabled=1|0  系统默认为1
[BaseOS]
name=westos BaseOS
baseurl=file:///westos/BaseOS/
gpgcheck=0
gpgcheck=1   gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-REDHAT-release)
enabled=1|0  系统默认为1
dnf repolist  列出仓库信息
df 列出挂载信息
5.vim /etc/rc.d/rc.local   (重启之后镜像仍然挂载)
编辑内容:
touch  /var/lock/subsys/local
mount /iso/rhel_8.2_x86_64_dvd.iso /westos 
6.chmod +x /etc/rc.d/rc.local
检测:
unmount /westos
reboot 重启之后/westos中内容仍然在

  

 网络仓库搭建

1.systemctl enable --now httpd     设定开机时启动并当前不启动httpd

2.systemctl disable --now firewalld    设定开机时不启动并当前不启动firewalld

3.mkdir  /var/www/html/westos       /var/www/html/为远程系统识别的目录

4.umount  /westos    卸载/westos中的挂载

5.mount  /iso/rhel_8.2_x86_64_dvd.iso  /var/www/html/westos

6.cd /etc/yum.repos.d/

7.vim westos.repo

编辑内容:

[AppStream]

name=westos AppStream

baseurl=http://172.25.254.12/westos/AppStream/

gpgcheck=0 

[BaseOS]

name=westos BaseOS

baseurl=http://172.25.254.12/westos/BaseOS/

gpgcheck=0

8.vim /etc/rc.d/rc.local     (重启之后镜像仍然挂载)

编辑内容:

touch  /var/lock/subsys/local

mount /iso/rhel_8.2_x86_64_dvd.iso /var/www/html/westos

8.chmod +x /etc/rc.d/rc.local

   

 虚拟机连接网络

真机中操作:

systemctl enable --now firewalled

firewall-cmd --permanent --add-masquender

firewall-cmd --permanent --add-service=http

firewall-cmd --enable

虚拟机操作:

IP route add default via 172.25.25.73(真机IP)

echo nameserver 114.114.114.114 > /etc/relove.conf

检测网络是否连接好

ping www.baidu.co

  

 第三方仓库搭建

安装 epel 配置包

yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm

将 repo 配置中的地址替换为阿里云镜像站地址

sed  -i 's|^\#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|g' /etc/yum.repos.d/epel*    sed -i 's|^metalink|\#metalink|g' /etc/yum.repos.d/epel* 将其保存到westos文件中

执行文件中命令 sh westos

 dnf install yum-utils -y   安装好插件之后系统会出现yumdownloader

yumdownloader --destdir=/mnt/kolourpaint.x86_64   将软件包下载到指定位置

yumdownloader --resolve --destdir=/mnt/westos/kolourpaint.x86_64  将软件包和软件包的依赖性下载到指定目录

以下步骤在虚拟机中操作

dnf install httpd -y

systemctl enable --now httpd

systemctl disable --now firewalld

cp -r /mnt/westos /var/www/html

dnf install createrepo -y

createrepo -v /var/www/html/westos

以下操作在真机中操作

dnf remove kolourpaint

cd /etc/yum.repos.d/

vim westos.repo

编辑内容:

[kolourpaint]

name = kolourpaint

baseurl = http://172.25.254.173/westos 虚拟机的ip

gpgcheck = 0

dnf list kolourpaint

dnf install kolourpaint -y

  

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值