1.How to install rpm package
Installation of the rmp package can be done using the program rpm. Execute the following command rpm -i package_name.rpm (package_name.rpm is the file name of the rpm package you want to install, usually placed in the current directory) The following prompt may appear during the installation process: ... conflict with ... possible There are some files in the package to be installed that may overwrite existing files. In this case, it cannot be installed correctly by default. You can use rpm --force -i to force the installation.... is needed by .. . ... is not installed ... This package requires some software that you have not installed. You can use rpm --nodeps -i to ignore this information. In other words, rpm -i --force --nodeps can ignore all dependencies and File problems, any package can be installed, but this forced installation of software packages cannot guarantee full functionality
2. How to install the .src.rpm package
Some software packages end with .src.rpm. This type of software package is an rpm package containing source code and needs to be compiled during installation. There are two ways to install this type of software package:
Method one:
1).Execute rpm -i your-package.src.rpm
2). cd /usr/src/redhat/SPECS
3). rpmbuild -bp your-package.specs A specs file with the same name as your package
4). cd /usr/src/redhat/BUILD/your-package/ A directory with the same name as your package
5). ./configure This step is the same as compiling ordinary source code software. You can add parameters.
6).make
7). make install
Method two:
1).Execute rpm -i you-package.src.rpm
2). cd /usr/src/redhat/SPECS
The first two steps are the same as method one
3). rpmbuild -bb your-package.specs A specs file with the same name as your software package is now in /usr/src/redhat/RPM/i386/ (depending on the specific package, it may also be i686, noarch, etc. etc.) In this directory, there is a new rpm package, which is a compiled binary file. Execute rpm -i new-package.rpm to complete the installation.
3. How to uninstall rpm packages
Use the command rpm -e package name. The package name can contain version number and other information, but cannot have the suffix .rpm.
For example, to uninstall the software package proftpd-1.2.8-1, you can use the following format:
rpm -e proftpd-1.2.8-1
Instead of: pm -e proftpd-1.2.8-1.i386.rpm
If you are not sure what the name of the installed package is, but just remember part of the name (such as: ftp), you can use: rpm -qa | grep ftp to query the exact name
Sometimes some errors or warnings may appear:
... is needed by ... This means that this software is needed by other software and cannot be uninstalled casually. You can use rpm -e --nodeps to force uninstall.
4. How to obtain the files in the rpm package without installing it
Using the tools rpm2cpio and cpio
rpm2cpio xxx.rpm | cpio -vi
rpm2cpio xxx.rpm | cpio -idmv
rpm2cpio xxx.rpm | cpio --extract --make-directories
The parameter i is the same as extract, which means extracting the file. v means to indicate the execution process, d is the same as make-directory, which means to create a directory based on the original path of the file in the package, and m means to keep the update time of the file.
5. How to view files and other information related to rpm packages
All examples below assume the use of package mysql-3.23.54a-11
a. What rpm packages are installed in my system?
rpm -qa lists all installed packages
If you want to find all installed software packages containing a certain string sql
rpm -qa |grep sql
b. How to obtain the full file name of a certain software package
rpm -q mysql can obtain the full name of the mysql package installed in the system, from which
Information such as the version of the current software package. In this example, the information mysql-3.23.54a-11 can be obtained
c. Where are the files in an rpm package installed?
rpm -ql package name Note that the name here is the name of the software package that does not include the .rpm suffix, which means that you can only use mysql or mysql-3.23.54a-11 instead of mysql-3.23.54a -11.rpm. If you just want to know where the executable program is, you can also use which, such as which mysql, or whereis, such as: whereis mysql.
d. What files are included in an rpm package?
For a software package that has not been installed, use rpm -qlp ****.rpm: For a software package that has been installed, you can also use rpm -ql ****.rpm
e. How to obtain relevant information about a software package’s version, purpose, etc.?
For a software package that has not been installed, use rpm -qip ****.rpm; for a software package that has been installed, use rpm -qi ****.rpm.
f. Which software package is installed for a certain program, or which software package contains this program?
rpm -qf `which program name` returns the full name of the software package; rpm -qif `which program name` returns information about the software package; rpm -qlf `which program name` returns the file list of the software package. Note that there are no quotation marks here , but `, which is the key in the upper left corner of the keyboard. You can also use rpm -qilf to output package information and file list at the same time
g. Which software package is installed for a certain file, or which software package contains this file?
Note that the method in the previous question only applies to executable programs, while the following method can be used not only for executable programs, but also for any ordinary file. The premise is to know the file name. First get the full path of this program, you can use whereis or which, and then use rpm -qf for example: # whereis ftptop (the result is ftptop: /usr/bin/ftptop /usr/share/man/man1/ftptop.1.gz)
# rpm -qf /usr/bin/ftptop
proftpd-1.2.8-1
# rpm -qf /usr/share/doc/proftpd-1.2.8/rfc/rfc0959.txt
proftpd-1.2.8-1