Linux 中的软件包的类型
#DEB UBlinux DEBlinux
#RPM redhat centos fadora
#bz2|gz|xz 需要源码安装需要编译
绿色软件,直接可用
注意在rhel8 中只能使用绿色软件,源码编译软件和prm软件
##软件包的名称架构
dhcp-server 4.3.6-30.el8.x86_64.rpm
1 2 3 4 5
1 软件名称
2 软件版本
3 软件的授权协议版本
4 软件架构
5 软件类型后缀
##rpm命令管理软件包
rpm -ivh 安装参数组合
-a 所有
-f 文件
-p 软件包
-q 查询
-l 软件安装文件列表
-e 卸载
-c 配置文件
-d 说明
(以上一般配合q一起使用 eg:-ql)
--info 软件信息
--force 强制
--nodeps 忽略依赖性
--scripts 查询软件在安装或卸载过程中的运行脚本
--Kv 检测软件md5校验码
-V 检测已安装软件在系统中的文件被修改信息
##本地软件仓库的搭建
仓库的作用:
自动解决依赖关系 则需要搭建系统软件仓库
方法:
1在系统中加载安装系统时使用的安装镜像
2编写软件仓库文件
[Appstream] 名称
name=appstream 描述
baseurl=file:///westos/AppStream 地址
gpgcheck=0 不检测gpgkey(跳过授权)
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-redat-release
enabled=1|0
[BaseOS]
name=Baseos
basurl=file:///westos/BaseOS/
gpgcheck=0
测试:
dnf install gcc -y
#dnf软件管理命令
dnf repolist 列出仓库信息
clean all 清除缓存 (var/cache/dnf)
list all
list available 列出未安装软件
list installed
install
remove
reinstall 重新安装
search 搜索
whatprovides 搜索包含文件的软件包
history dnf执行历史
history info 详细
group list 列出软件组
group list --installed
group list --available
group list --hidden 列出隐藏软件组
group install 安装软件组
group info 查看软件组信息
下载安装包
前提:dnf install yum-utils -y 下载此软件
yumdownloader 下载软件包到本机指定位置
yumdownloader httpd 下载仓库中指定软件的安装包到当前目录
yumdownloader --destdir=/mnt 安装到mnt目录
yumdownloader httpd --destdir=/mnt --resolve 下载指定安装包和依赖性到/mnt目录
##网络软件仓库的搭建
方法:
1.利用镜像搭建本地软件仓库
2.安装共享软件
dnf install httpd -y 共享位置(/var/www/html)
3.启用共享软件apache
systemctl disable --now firewalld
systemctl enable --now httpd
4.建立共享目录
mkdir /var/www/html/rhel8.0
5.挂载镜像到共享目录
umount /westos
mount /isos/rhel-8.2-x86_64-dvd.iso /var/www/html/rhel8.0/
vim /etc/rc.d/rc.local 开机时自动挂载
chmod +x或755 /etc/rc.d/rc.local
vim /etc/yum.repos.d/westos.repo
6.远程主机westosa中访问资源并书写repo文件
vim /etc/yum.repos.d/westos.repo
[AppStream]
name=AppStream
baseurl=http://172.25.254.77/rhel8.0/AppStream
gpgcheck=0
[BaseOS]
name=BaseOS
baseurl=http://172.25.254.77/rhel8.0/BaseOS
gpgcheck=0
##第三方软件仓库的搭建方法
可以使用dnf命令管理第三方软件
并使第三方软件在网络中共享
步骤:
1.建立共享目录
mkdir /var/www/html/software
2.将第三方软件存进software中 (只能时rpm,压缩包不能用dnf管理)
wget http://172.25.254.250/software/linuxqq_2.0.0-b2-1084_x86_64.rpm
3.采集第三方软件数据生成repodata目录
cd /var/www/html/software/
dnf install createrepo -y
createrepo .
4.在测试主机中指定第三方共享源
vim /etc/yum.repos.d/westos.repo
##epel源的使用
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
rpm -ivh epel-release-latest-8.noarch.rpm
dnf search flame
dnf install flameshot.x86_64
删除
rpm -qa | grep epel 查找
rpm -e epel-release-8-10.el8.noarch