Detailed explanation of rpm yum and dnf in Linux environment

Table of contents

1.rpm tool

1.1 Introduction

1.2 Parameter introduction

1.3 Common scenario commands

2. The yum tool

2.1 Introduction

2.2 Common commands

Three.dnf tool

3.1 Introduction

3.2 Common commands

This article mainly introduces the three tools of rpm/yum and dnf under Linux from the perspective of use, and explains common commands. In general: rpm installs a single package without considering dependencies, yum and dnf can automatically handle package dependencies to install a series of packages.

1.rpm tool

1.1 Introduction

Rpm is a set of management programs that install the required packages on the Linux host in a database-recorded manner. There is an rpm database in the Linux system (generally the path /var/lib/rpm in Linux), which records the dependencies between installed packages.

1.2 Parameter introduction

The commonly used parameters when using the rpm command are as follows:

rpm -i : --install install

rpm -U : --update update

rpm -e :--erase uninstall

rpm -q : --query query

rpm -V : --verify verification

1.3 Common scenario commands

-v: 显示安装详细信息
-vv:显示更详细的信息
-h: 显示安装进度条,一个#代表2%
--force:有的时候安装包会提示与其它包及文件冲突,此时可以用此参数忽略冲突
--nodeps:若想不考虑依赖性关系单独安装或卸载一个包,使用此参数

1.安装一个包( rpm -ivh <packet name> )
 
2.更新一个包(rpm -Uvh <packet name>)

3.卸载一个包(rpm -e <packet name>)

4.查询一个包(rpm -q <packet name>)

rpm -q:查询一个包是否被安装
rpm -qa:查询所有被安装的包,可结合管道命令使用(例rpm -qa|grep httpd:查询所有包名中包含httpd的已安装的包)
rpm -qi:查询安装包的详细信息
rpm -ql:查看安装包中的文件列表

2. The yum tool

2.1 Introduction

The yum tool is better than the rpm tool. It is based on RPM package management and can automatically handle dependencies. When you install a software package, you don’t need to consider the dependencies. It can automatically analyze the dependencies, download the rpm package from the specified installation source (the path of the installation source configuration file under linux: /etc/yum.repos.d/), and then install a series of dependent packages that you need to install the software package in order, and finally complete the installation of the target software package.

2.2 Common commands

yum install -y <packet name>    //安装软件包

yum search <packet name>        //搜索软件包

yum info  <packet name>         //查看软件包的详细信息

yum remove <packet name>        //卸载软件包

yum update <packet name>        //更新软件包

yum upgrade <packet name>       //升级软件包

PS:update与upgrade区别:update会保留旧的软件包,upgrade会删除旧的软件包

yum check-update                //查看可更新的软件包

yum deplist                     //查看依赖关系

yum list installed              //查看已安装的软件包

yum list all                    //查看所有软件包

yum repolist                    //列出仓库信息

yum clean packets               //清除缓存目录下所有软件包

yum clean headers/oldheaders    //清除缓存目录下所有headers/oldheaders

yum clean all                   //等同于yum clean packets命令加yum clean oldheaders



Three.dnf tool

3.1 Introduction

The dnf tool is an upgraded version of the yum tool. In order to solve some problems that have existed in the yum tool for a long time, such as poor performance, large memory usage, dependency analysis, and slow running speed, etc.

3.2 Common commands

The common commands of the dnf tool are basically the same as those of the yum tool, as follows

dnf distro-sync                 //将所有已安装软件包更新至最新版本

dnf install -y <packet name>    //安装软件包

dnf search <packet name>        //搜索软件包

dnf info  <packet name>         //查看软件包的详细信息

dnf remove <packet name>        //卸载软件包

dnf update <packet name>        //更新软件包

dnf check-update                //查看可更新的软件包

dnf deplist                     //查看依赖关系

dnf list installed              //查看已安装的软件包

dnf repolist                    //列出仓库信息

dnf clean packets               //清除缓存目录下所有软件包

dnf clean headers/oldheaders    //清除缓存目录下所有headers/oldheaders

dnf clean all                   //等同于yum clean packets命令加yum clean oldheaders



Guess you like

Origin blog.csdn.net/m0_64496909/article/details/124769360