redhat:rpm文件,rpm管理器,使用yum、dnf包管理器 debian:deb文件,dpkg管理器,使用apt包管理器 ## 1、rpm详解 rpm 用的很少,都是用的dnf管理器管理 1.1 包查询 ```shell rpm -q 参数1、 参数: -a:所有包 -f:查看指定的文件由哪个包安装生成 -l:查看指定的程序包安装后生成的所有文件 ``` ## 2、dnf详解 现在是dnf的天下,yum代码维护困难,速度差 ```shell /etc/dnf/dnf.conf #为所有仓库提供的公共配置文件 /etc/yum.repos.d/*.repo #每个仓库的配置文件 ``` ```shell gpgcheck=1 #安装包前要做包的合法性和完整性校验 installonly_limit=3 #同事可以安装3个包,最小值为2,如果设置0或1,则不限制 clean_requirements_on_remove=True #删除包的时候是否将不再使用的包删除 bast=True #升级时,自动选择安装最新版,即使缺少包的依赖 ``` ```shell [仓库名] name=仓库名 baseurl=仓库位置 enabled={1|0} gpgcheck={1|0} gpgkey=URL ``` ## 3、dnf 常用命令 ##### 3.1 显示仓库列表 ```shell dnf repolist [all|enbaled|disabled] dnf repolist -v #显示详细仓库列表 ``` ##### 3.2 显示程序包 ```shell dnf list [available|installd|updates] dnf list 包名 ``` ##### 3.3 安装程序包 ```shell dnf install 包名 dnf reinstall 包名 ``` ##### 3.4 只下载相关依赖的包,而不安装 ```shell dnf install nginx --downloadonly --downloaddir=/保存文件夹 ``` ##### 3.5 卸载程序包 ```shell dnf remove 包名 dnf remove 包名 --purge #删除配置文件 ``` ##### 3.6 查询 ```shell dnf info 包名 ``` ```shell dnf search 包名 ``` ## 4、apt包管理器 ```shell install:安装 remove:卸载 purge:卸载并删除配置文件 update:刷新存储库索引 uograde:升级所有包 autoremove:自动删除不需要的包 search:搜索 show:显示软件包细节 list:查看包 --installed:已安装 --available:可获得 --updates:可升级 ```