Linux下的软件管理

1 Linux中软件包的类型

1 DEB #UBlinux DEBlinux
2 RPM #redhat centOS fadore
3 bz2|gz|xz

  • 需要源码安装需要编译
  • 绿色软件,直接可用
  • ntfs-3g_ntfsprogs-2017.3.23.tgz 需要编译“configure”
    *Firefox-latest-x86_64.tar.bz2 绿色
    安装包类型
  • “注意在rhell8中能使用绿色软件,源码编译软件和rpm软件”

2 软件包的名称结构

[dhcp-server]-[4.3.6-30].[el8].[x86_64].[rpm]

  • 解释:
    [dhcp-server]: 软件名称
    [4.3.6-30]: 件版本
    [el8]: 软件的授权协议**版本
    [x86_64]: 软件架构
    [rpm]: 软件类型后缀

3 rpm命令管理软件包

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

4 解决依赖性

  • 搭建本地的软件仓库
  • 镜像提供大多数软件的依赖性
    (有网络时可以用阿里云,但是没有网络的时候需要搭建本地的软件仓库)

本地仓库的搭建:

(1) 手动挂载镜像

[1] 挂载镜像

[root@westos_student1 dnf]# ls /iso/rhel-8.2-x86_64-dvd.iso #查看镜像文件
[root@westos_student1 dnf]# mkdir /westos #创建一个将镜像挂载的目录
[root@westos_student1 dnf]# mount /iso/rhel-8.2-x86_64-dvd.iso /westos/ #挂载镜像到/westos/目录中
[root@westos_student100 dnf]# df #查看是否挂载成功
挂载成功

[2] 编辑文件配置仓库(告知系统挂载在哪)

[root@westos_student1 dnf]# cd /etc/yum.repos.d/ #切换目录
[root@westos_student1 dnf]# vim westos.repo #编辑文件
文件内容>[root@westos_student1 yum.repos.d]# cd /var/cache/dnf #切换目录至/var/cache/dnf

[3] 清除dnf之前读取的数据

[root@westos_student1 dnf]# dnf clear all #清除dnf之前读取的数据

[4] 即可运用dnf install 解决依赖性

[root@westos_student1 dnf]# dnf install gcc -y #测试是否可以用dnf解决依赖性
安装完成

(2)自动挂载镜像
  • 在超级用户下进行操作:
    [1] 编辑 /etc/rc.d/re.local脚本文件

[root@westos_student1 westos]# vim /etc/rc.d/rc.local
编写脚本文件挂载

[2]运行脚本文件

[root@westos_student1 westos]# sh /etc/rc.d/rc.local #运行后可测试已经挂载成功
显示挂载成功

[3]修改文件权限

[root@westos_student1 westos]# chmod +x /etc/rc.d/rc.local

[4]重启系统显示依旧挂载成功
重启挂载依旧成功

5 共享挂载镜像

[1] 首先需要搭建本地源
前面已经搭建过
[2] 安装 dnf httpd -y

[root@westos_student1 ~]# dnf install httpd -y

[3] 关火墙

[root@westos_student1 Desktop]# systemctl disable --now firewalld

[4] 开启共享服务,只共享/var/www/html里面的文件,所以要把需要共享的内容放在该文件中

[root@westos_student1 Desktop]# systemctl enable --now httpd
[root@westos_student1 Desktop]# mkdir /var/www/html/westos

[5] 将镜像挂载到共享文件中,网址就变成了一个软件仓库

[root@westos_student1 Desktop]# mount /iso/rhel-8.2-x86_64-dvd.iso /var/www/html/westos

[6] 编写/etc/yum.repos.d/westos.repo 配置文件

[root@westos_student1 Desktop]# cd /etc/yum.repos.d/
[root@westos_student1 Desktop]# cd /etc/yum.repos.d/
[root@westos_student1 yum.repos.d]# vim westos.repo
编写配置文件

[7] 开启自动挂载,修改开机时的权限

[root@westos_student1 yum.repos.d]# vim /etc/rc.d/rc.local #编写脚本文件
[root@westos_student1 yum.repos.d]# chmod +x /etc/rc.d/rc.local #修改权限
[root@westos_student1 yum.repos.d]# reboot #重启主机
写如自动挂载

  • 测试:
    在虚拟机node1上
    在浏览器上输入主机ip地址以及目录:172.25.254.1/westos/
    可以登录到该界面说明配置成功:
    共享成功

6 dnf软件管理命令

(1)针对软件

dnf

  • repolist #列出仓库信息
    1

  • clean all #清除系统中已经加载的仓库缓存信息
    2

  • list all #列出所有软件
    3

  • list available #列出未安装软件
    4

  • list install #列出已安装软件
    5

  • install#安装
    6

  • remove #卸载
    7

  • reinstall #重新安装
    8

  • search #搜索
    9

  • whatprovides #搜索包含文件的软件包

  • history #dnf执行历史
    10

  • history info #dnf执行历史详细信息
    11

(2) 针对组件

  • group list #列出软件组
    1

  • group list --installed #列出已安装软件组
    2

  • group list --available #列出未安装软件组
    3

  • group list --hidden #列出隐藏软件组
    4

  • group install #安装软件组
    5

  • group info #查看软件组信息
    6

(3)下载安装包

  • 首先需要安装yumdownloader命令:
    在这里插入图片描述

  • 用法:

  • yumdownloader
    #下载软件包到本机指定位置

  • yumdownloader httpd XXX(软件)
    #下载仓库中指定软件的安装包到当前目录

  • yumdownloader XXX(软件) --destdir=/mnt
    #下载仓库中指定软件的安装包到指定的目录

  • yumdownloader httpd --destdir=/mnt --resolve
    #下载仓库中指定软件安装包和软件依赖性到/mnt目录

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值