8.Linux系统中的软件管理

1.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软件"

2.软件包的名称结构

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

 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.本地软件仓库的搭建 

# 系统软件仓库的作用
# 在系统中对软件进行管理
#rpm 命令是不能解决依赖关系的
# 如果需要软件在安装过程中自动解决依赖关系 ,需要大家系统软件仓库
##搭建方法##
1.在系统中加载安装系统时使用的安装镜像
mount /xxxx/rhel8.2-xxxxxxxx.iso /xxxx

本地软件仓库搭建
 mkdir /iso
 cd /iso
  wget http://172.25.254.250/isos/rhel-8.2-x86_64-dvd.iso镜像
  ls /iso/
  mkdir /westos
  ls /westos/
  mount /iso/rhel-8.2-x86_64-dvd.iso /westos/

 

 df
 cd /etc/yum.repos.d/
 rm -fr redhat.repo westos.repo 
 ls
 vim  chen.repo

[AppStream]
name = AppStream
baseurl = file:///westos/AppStream
gpgcheck = 1
enabled = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[BaseOS]
name = BaseOS
baseurl = file:///westos/BaseOS
gpgcheck = 1
enabled = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


 dnf install httpd -y  下载httpd

实验二
(真机)
  cd /var/www/html/
  systemctl enable --now httpd打开httpd服务
  systemctl disable --now firewalld关闭防火墙
  ls
  rm -fr *
  mkdir westos
  mount /iso/rhel-8.2-x86_64-dvd.iso  /var/www/html/westos/


(虚拟机)
cd /etc/yum.repos.d/
vim westos.repo
[AppStream]
name = AppStream
baseurl =http://172.25.254.19/westos/AppStream/
gpgcheck = 0

[BaseOS]
name = BaseOS
baseurl =http://172.25.254.19/westos/BaseOS/
gpgcheck = 0

dnf install httpd -y
 

5.dnf 软件管理命令

# 安装管理包 #
dnf
        repolist ##列出仓库信息
        clean all ##清除系统中已经加载的仓库缓存信息 / var / cache / dnf
 
        list all ##列出所有软件
        list available ##列出未安装软件
        list installed ##列出已安装软件
        install ##安装
        remove ##卸载
        reinstall ##重新安装
          dnf reinstall httpd 正常卸载不能用reinstall重新安装
         dnf reinstall httpd 文件出现错误,可删除后重新安装
        search ##搜索
        whatprovides ##搜索包含文件的软件包
         dnf whatprovides /bin/ls通过文件搜索软件包
         dnf search /bin/ls 不能搜索文件
            search 通过软件搜索软件安装包
        history ##dnf执行历史
        history info ##dnf执行历史详细信息
 
        group list ##列出软件组
        group list -- installed ## 列出已安装软件组
        group list -- available ## 列出未安装软件组
        group list -- hidden ## 列出隐藏软件案组
        group install ##安装软件组
        group info ##查看软件组信息

 

#下载安装包#
yumdownloader #下载软件包到本机指定位置
yumdownloader httpd #下载仓库中指定软件的安装包到当前目录
yumdownloader -- destdir =/ mnt #下载仓库中指定软件的安装包到指定 / mnt 目录
yumdownloader httpd -- destdir =/ mnt -- resolve # 下载仓库中指定软件安装包和软件依赖性到 / mnt目录

 

系统之外的安装
联网
ip route add default via 172.25.254.250
echo nameserver 114.114.114.114 > /etc/resolv.conf 

 yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
安装 epel 配置包

将 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* 

dnf install kolourpaint -y

下载安装包及依赖性(虚拟机实验)
 cd /mnt
 mkdir westos
 ls
 yumdownloader --resolve --destdir=/mnt/westos kolourpaint

 

第三方软件仓库搭建
(虚拟机)
 dnf install httpd -y
 systemctl enable --now httpd
 systemctl disable --now firewalld 
 cp -r westos /var/www/html
 dnf install createrepo -y
 createrepo -v /var/www/html/westos


 (真机)
dnf remove kolourpaint
vim /etc/yum.repos.d/chen.repo
[westos]
name = westos
baseurl = http://172.25.254.119/westos
gpgcheck = 0

dnf list kolourpaint

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值