Explain the use of RPM and Yum commands in Linux system of RedHat system

Time:2020-10-27

rpm
Rpm is a powerful software package management system, which makes it easy to install, upgrade and delete software packages under Linux, and has the function of querying and verifying software packages. Using the command line gives you more flexibility than graphical tools. The following examples use example-1.2.3-1.i386.rpm to represent the name of the object package

Parameters and options

1、 Installation options

Command format:

rpm -i ( or –install) options file1.rpm … fileN.rpm

Parameters:

file1.rpm … fileN.rpm The file name of the RPM package to be installed

Detailed options:

-H (or — hash) when installing, output the hash mark (” ‘)
–Test only tests the installation, not the actual installation.
–Percent outputs the progress of the installation as a percentage.
–Excludedoc does not install the documentation files in the package
–Includedocs installation documentation
–Replacepkgs forces the re installation of installed packages
–Replacefiles replaces files that belong to other packages
–Force ignores conflicts between packages and files
–Noscripts does not run pre install and post install scripts
–Prefix installs the package to the path specified by
–Ignorearch does not verify the structure of the package
–Ignoreos does not check the operating system on which the package is running
–Nodeps does not check for dependencies
–Ftpproxy is used as an FTP proxy
–FTP port specifies that the port number of FTP is

General options

-V display additional information
-VV displays debugging information
–Root lets RPM use the specified path as the “root directory” to pre install the program and post install
The installation program will be installed in this directory
–Rcfile sets the rpmrc file to
–Dbpath sets the path where the RPM data inventory is located

2、 Delete options

Command format:

rpm -e ( or –erase) options pkg1 … pkgN

parameter

Pkg1… Pkgn: package to be removed

Detailed options

–Test only performs deleted tests
–Noscripts does not run pre install and post install scripts
–Nodeps does not check for dependencies

General options

-VV displays debugging information
–Root lets RPM use the specified path as the “root directory” to pre install programs and post install
The program will be installed in this directory
–Rcfile sets the rpmrc file to
–Dbpath sets the path where the RPM data inventory is located

3、 Upgrade options

Command format

rpm -U ( or –upgrade) options file1.rpm … fileN.rpm

parameter

file1.rpm … fileN.rpm The name of the package

Detailed options

-H (or — hash) when installing, output the hash mark (” ‘)
–Oldpack age allows you to “upgrade” to an older version
–Test only performs upgrade testing
–Excludedoc does not install the documentation files in the package
–Includedocs installation documentation
–Replacepkgs forces the re installation of installed packages
–Replacefiles replaces files that belong to other packages
–Force ignores conflicts between packages and files
–Percent outputs the progress of the installation as a percentage.
–Noscripts does not run pre install and post install scripts
–Prefix installs the package to the path specified by
–Ignorearch does not verify the structure of the package
–Ignoreos does not check the operating system on which the package is running
–Nodeps does not check for dependencies
–Ftpproxy is used as an FTP proxy
–FTP port specifies that the port number of FTP is

General options

-V display additional information
-VV displays debugging information
–Root asks rpm to use the specified path as the “root directory” so that both pre – and post – installers will be installed in this directory
–Rcfile sets the rpmrc file to
–Dbpath sets the path where the RPM data inventory is located

4、 Inquiry

Command format:

rpm -q ( or –query) options

Parameters:

Pkg1… Pkgn: query installed packages

Detailed options

-P (or ” ‘-‘)
-F query which software package belongs to
-A query all installed packages
–What services query provides a functional software package
-G queries packages that belong to a group
–Whatrequires queries all packages that need functionality

Information options

Displays the full identification of the package
-I displays a summary of the package
-L displays the list of files in the package
-C displays the list of configuration files
-D displays a list of document files
-S displays a list of files in the package and the status of each file
–Scripts shows the install, uninstall, and verify scripts
–Queryformat (or — QF) displays query information in a user specified manner
–Dump displays all checked information for each file
–Provides shows the functions provided by the package
–Requirements (or – R) displays the required functions of the package

General options

-V display additional information
-VV displays debugging information
–Root asks rpm to use the specified path as the “root directory” so that both pre – and post – installers will be installed in this directory
–Rcfile sets the rpmrc file to
–Dbpath sets the path where the RPM data inventory is located

5、 Verify installed packages

Command format:

rpm -V ( or –verify, or -y) options

parameter

Pkg1… Pkgn package name to be verified

Package options

-p Verify against package file
-F check the software package it belongs to
-Verify all software packages of verify a
-G verify all software packages that belong to the group

Detailed options

–Noscripts does not run validation scripts
–Nodeps does not check dependency
–Nofiles does not verify file properties

General options

-V display additional information
-VV displays debugging information
–Root asks rpm to use the specified path as the “root directory” so that both pre – and post – installers will be installed in this directory
–Rcfile sets the rpmrc file to
–Dbpath sets the path where the RPM data inventory is located

6、 Verify the files in the software package

Grammar:

rpm -K ( or –checksig) options file1.rpm … fileN.rpm

Parameters:

file1.rpm … fileN.rpm The file name of the package

Checksig — detailed options

–Nopgp does not verify GPG signature

General options

-V display additional information
-VV displays debugging information
–Rcfile sets the rpmrc file to

7、 Other RPM options

–Rebuilddb rebuild RPM database
–Initdb creates a new RPM database
–Quiet reduces output as much as possible
–Help displays the help file
–Version displays the current version of the rpm

8、 Examples

Copy code

The code is as follows:

[ [email protected] ~]#RPM – IVH ipchains-1.3.6-1.i386. Rpm ා install the package and show the detailed progress
[ [email protected] ~]# rpm -i ftp://ftp.xxx.xxx # Online installation
[ [email protected] ~]#RPM – VA ා verify all RPM packages and find the missing files
[ [email protected] ~]#RPM – QF / usr / bin / who ා find out which RPM package a file belongs to
[ [email protected] ~]#RPM – QPI mon-0.37j-1.i386. Rpm ා lists the description of an RPM package
[ [email protected] ~]#RPM – QPL mon-0.37j-1.i386. Rpm ා lists the file information of an RPM package
[ [email protected] ~]#RPM – uvh ipchains-1.3.6-1.i386. Rpm ා upgrade package
[ [email protected] ~]#RPM – Q httpd ා view the installation package of httpd
[ [email protected] ~]#RPM – e httpd ා remove installation package
[ [email protected] ~]#RPM – Qi httpd ා get the information of httpd installation package

Name        : httpd                        Relocations: (not relocatable)
Version     : 2.2.3                             Vendor: CentOS
Release: 45.el5.centos.1 build date: Wednesday, May 4, 2011 18:54:56
Install date: Wednesday, June 29, 2011 08:05:34 build host: builder10 centos.org
Group       : System Environment/Daemons    Source RPM: httpd-2.2.3-45.el5.centos.1.src.rpm
Size        : 3281960                          License: Apache Software License
Signature: DSA / SHA1, Wednesday, May 4, 2011, 20:31:28, key ID a8a447dce8562897
URL         : http://httpd.apache.org/
Summary: Apache HTTP server
Description :
The Apache HTTP Server is a powerful, efficient, and extensible
web server.

Copy code

The code is as follows:

[ [email protected] ~]#RPM – QL httpd ා lists which files are in httpd
[ [email protected] ~]#RPM – QA ා lists all installed packages

yum
Yum command: used to add / delete / update RPM packages, automatically solve package dependency problems, and update and upgrade the system

parameter

-E silent execution
-T ignore errors
-R [min] set the waiting time
-Y auto answer yes
–Skip broken ignoring dependency problem
–Nogpgcheck ignores GPG validation

Check update checks for updatable packages
Clear all
Clean packages clear temporary package files (/ var / cache / Yum)
Clear headers clear RPM header file
Clean oldheads clears old RPM header files
Declist lists the dependencies of the package
List installable and updatable RPM packages
List installed packages
List extras packages installed and not in repository
Info installable and updatable RPM package information
Info installed information of installed packages (- QA parameter similar)
Install [RPM package] installation package
Local install installs the local RPM package
Update [RPM package] update package
Upgrade system
Search [keyword] search package
Search for a specific package file name
Re install [RPM package] re install the package
Repolist shows the configuration of the repository
Resolvedep specifies the dependency
Remove [RPM package] uninstall package

For example:
1. Installation

Copy code

The code is as follows:

[ [email protected] ~]#Yum install php53 ා install php5.3
[ [email protected] ~]#Yum groupinstall “MySQL server” ා install MySQL database group

2. Update and upgrade

Copy code

The code is as follows:

[ [email protected] ~]#Yum update ා update all
[ [email protected] ~]#Yum update php53 update PHP
[ [email protected] ~]#Yum check update ා check for updatable programs
[ [email protected] ~]#Yum upgrade php53 ා upgrade php53
[ [email protected] ~]#Yum groupupdate “MySQL server” ා upgrade MySQL service group

3. Search and display

Copy code

The code is as follows:

[ [email protected] ~]#Yum info php53 ා view php53 installation information
[ [email protected] ~]#Yum list ා lists all the packages that can be installed
[ [email protected] ~]#Yum list php53 ා lists all php53 packages
[ [email protected] ~]#Yum groupinfo “MySQL server” ා view the related installation packages of MySQL service group
[ [email protected] ~]#Yum subtract php53 ා view php53 dependency

4. Delete

Copy code

The code is as follows:

[ [email protected] ~]#Yum remove php53
[ [email protected] ~]#Yum groupremove “MySQL server” ා delete MySQL service group

5. Clear the cache

Copy code

The code is as follows:

[ [email protected] ~]#Yum clean packages ා clear packages in cache directory
[ [email protected] ~]#Yum clean headers ා clear the headers in the cache directory
[ [email protected] ~]#Yum clean oldheads ා clear old headers in cache directory
[ [email protected] ~]#Yum clean, yum clean all ා