Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use rpm command in Linux operating system

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use the rpm command in the Linux operating system, the article is very detailed, has a certain reference value, interested friends must read it!

In the Linux operating system, there is a system software package whose function is similar to "add / remove programs" in Windows, but its function is much stronger than "add / remove programs". It is Red Hat Package Manager (RPM for short). This toolkit was first launched by Red Hat and later borrowed by other Linux developers. Because it saves a lot of time for Linux users, it is widely used to install and delete software under Linux. Next, I will introduce to you how to use it.

The rpm command is an administrative tool for RPM software packages. Rpm, originally a Red Hat Linux distribution program designed to manage Linux suites, is popular because it follows GPL rules and is powerful and convenient. Gradually adopted by other distributions. The emergence of RPM suite management makes Linux easy to install and upgrade, which indirectly improves the applicability of Linux.

Grammar

Rpm (option) (parameter) option

-a: query all packages;-b + or-t +: set the completion phase of the package and specify the file name of the package file;-c: list only the configuration file, this parameter should be used with the "- l" parameter;-d: list only the text file, this parameter should be used with the "- l" parameter;-e or-- erase: delete the specified package;-fallow: query the package with the specified file -h or-- hash: list tags during package installation;-I: display information about the package;-I or-- install: install the specified package file;-l: display the file list of the suite;-pause: query the specified RPM file;-Q: use the query mode, when any questions are encountered, the rpm instruction will ask the user first;-R: display the relevance information of the suite -s: display the file status, this parameter should be used with the "- l" parameter;-U or-- upgrade: upgrade the specified package file;-v: display the instruction execution process;-vv: show the instruction execution process in detail, easy to debug. Parameters.

Package: specifies the rpm package to manipulate.

Example

How to install the rpm package

The installation of the rpm package can be done using the program rpm. Execute the following command:

Rpm-ivh your-package.rpm

Where your-package.rpm is the file name of the rpm package you want to install, which is usually placed in the current directory.

The following warnings or prompts may appear during installation:

... Conflict with...

It is possible that some files in the package to be installed may overwrite existing files, which cannot be installed correctly by default. You can use rpm-- force-I to force the installation.

... Is needed by. Is not installed...

You can use rpm-- nodeps-I to ignore this information if you do not install some of the software required by this package, that is, rpm-I-- force-- nodeps can ignore all dependencies and file problems, and any package can be installed, but this forced installation of the package is not guaranteed to be fully functional.

How to install the .src.rpm package

Some packages end in .src.rpm, which are rpm packages that contain source code and need to be compiled at installation time. There are two ways to install such packages:

Method 1:

Rpm-I your-package.src.rpmcd / usr/src/redhat/SPECSrpmbuild-bp your-package.specs # A specs file cd / usr/src/redhat/BUILD/your-package/ # with the same name as your software package and a directory with the same name as your software package. / configure # this step is the same as compiling ordinary source software, with the parameter makemake install

Method 2:

Rpm-I you-package.src.rpmcd / usr/src/redhat/SPECS

The first two steps are the same as method one.

Rpmbuild-bb your-package.specs # an specs file with the same name as your software package

At this point in / usr/src/redhat/RPM/i386/ (depending on the package, it could be i686 no arch, etc.) in this directory, there is a new rpm package, which is a compiled binary.

Execute rpm-I new-package.rpm to complete the installation.

How to uninstall the rpm package

Use the command rpm-e package name, which can contain information such as the version number, but cannot have the suffix .rpm, such as uninstalling the package proftpd-1.2.8-1. You can use the following format:

Rpm-e proftpd-1.2.8-1rpm-e proftpd-1.2.8rpm-e proftpd-rpm-e proftpd

Cannot be in the following format:

Rpm-e proftpd-1.2.8-1.i386.rpmrpm-e proftpd-1.2.8-1.i386rpm-e proftpd-1.2rpm-e proftpd-1

Sometimes there are errors or warnings:

... Is needed by...

This shows that this software is needed by other software and cannot be uninstalled casually. It can be forced to be uninstalled with rpm-e-nodeps.

How to get the files in the rpm package without installing

Use the tools rpm2cpio and cpio

Rpm2cpio xxx.rpm | cpio-virpm2cpio xxx.rpm | cpio-idmvrpm2cpio xxx.rpm | cpio-- extract-- make-directories

The parameter I is the same as extract, which indicates that the file is extracted. V indicates the execution process, d is the same as make-directory, indicates that the directory is established according to the original path of the file in the package, and m indicates the update time of the file.

How to view files and other information related to rpm packages

All of the following examples assume the use of the package mysql-3.23.54a-11

1. Those rpm packages are installed on my system.

Rpm-qa will list all installed packages

If you want to find all installed packages that contain a string sql

Rpm-qa | grep sql

2. How to get the full file name of a software package.

Rpm-Q mysql

You can get the full name of the mysql package installed on the system, from which you can get information such as the version of the current package. In this example, you can get the information mysql-3.23.54a-11.

3. Where are the files in a rpm package installed?

Rpm-ql package name

Note that here is the name of the package that does not include the .rpm suffix, which means 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 is put, you can also use which, such as:

Which mysql

4. A rpm package contains those files.

An uninstalled software package, using rpm-qlp *. Rpm

A software package that has already been installed can also be used with rpm-ql *. Rpm

5. How to get information about the version and purpose of a software package?

An uninstalled software package, using rpm-qip *. Rpm

A software package that has already been installed can also be used with rpm-qi *. Rpm

6. Which package installed a program, or which package contains the 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 package

Notice that this is not the quotation mark, but `, the key in the upper left corner of the keyboard. You can also use rpm-qilf to output package information and a list of files.

7. Which package installed a file, or which package contains the file.

Note that the method in the previous question applies only to executable programs, while the following methods can be used not only for executable programs, but also for any ordinary file. As long as you know the file name. First get the full path to the program, using whereis or which, and then use rpm-qf for example:

Whereis ftptopftptop: / usr/bin/ftptop / usr/share/man/man1/ftptop.1.gzrpm-qf / usr/bin/ftptopproftpd-1.2.8-1rpm-qf / usr/share/doc/proftpd-1.2.8/rfc/rfc0959.txtproftpd-1.2.8-1

1. We get a new software. Before installing it, we usually have to check what is in the package. Suppose the file is: Linux-1.4-6.i368.rpm, we can check it with this command:

Rpm-qpi Linux-1.4-6.i368.rpm

The system will list the details of the package, including how many files, each file name, file size, creation time, compilation date, and so on.

two。 All the files listed above may not be installed during installation. Just as the installation methods of programs under Windows are typical, complete, and custom, Linux also allows you to choose the installation method. At this time, we can use the following command to check which parts of the package will be installed in the system to facilitate our choice:

Rpm-qpl Linux-1.4-6.i368.rpm

3. After selecting the installation method, start the installation. We can install this software with the rpm-ivh Linux-1.4-6.i368.rpm command. During the installation process, if the system prompts that the software has been installed or cannot continue for other reasons, but if we do want to execute the installation command, we can add a parameter "- replacepkgs" after-ivh:

Rpm-ivh-replacepkgs Linux-1.4-6.i368.rpm

4. Sometimes when we uninstall some installed software, we just need to execute the rpm-e command.

5. Upgrading the lower version of the software is a good way to improve its functionality, which saves us the trouble of uninstalling and then installing the new software. to upgrade a software, simply execute the following command: rpm-uvh, note: the file name must be the upgrade patch  of the software to be upgraded

6. Another way to install software is the uniqueness of Linux and a manifestation of the power of RMP: install the software directly online through the FTP site. When you find a site that contains the software you need and connect to it, execute the following command to install online, such as Linux-1.4-6.i368.rpm, with the command:

Rpm-I ftp://ftp.pht.com/pub/linux/redhat/...-1.4-6.i368.rpm

7. In the process of using the computer, there will inevitably be misoperation, if we mistakenly delete several files and affect the performance of the system, how to find which files are missing? RPM software package provides a function to find damaged files, execute this command: rpm-Va, Linux will list all the damaged files for you. You can fix it from the installation CD of Linux.

There are many files in the 8.Linux system. In the process of using them, we will inevitably encounter files that we do not know. Under Windows, we can use the "start / find" menu to quickly determine which folder a file belongs to. In Linux, the following command line can help us quickly determine which software package a file belongs to:

Rpm-qf

9. When each software package is installed on the Linux system, the installation files are "checked in" to the RPM database, so when we want to query the properties of an installed software, we only need to look in this database. Note: the query command at this time is different from the query introduced in 1 and 8, and this method applies only to installed software packages! Command format:

Rpm-Parameter

Under the Linux operating system, almost all software is installed, uninstalled and managed through RPM. The full name of RPM is Redhat Package Manager, which is proposed by Redhat Company to manage software packages under Linux. When Linux is installed, except for a few core modules, almost all the other modules are installed through RPM. RPM has five modes of operation: install, uninstall, upgrade, query, and verify.

RPM installation operation

Command:

Rpm-I package filename that needs to be installed

Examples are as follows:

Rpm-I example.rpm install example.rpm package

Rpm-iv example.rpm installs the example.rpm package and displays information about the files being installed during installation

Rpm-ivh example.rpm installs the example.rpm package and displays the information about the files being installed and the installation progress during the installation process

RPM query operation

Command:

Rpm-Q...

Additional query commands:

A query all installed packages the following two additional commands are used to query the information of the installation package

I display information about the installation package

L shows the directories to which all the files in the installation package are installed

S shows the status of all files in the installation version and the directories to which they are installed; the following two additional commands are used to specify whether to query the installation package or the installed files

P queries the information about the installation package

F queries the information of a file that has been installed

Examples are as follows:

Rpm-qa | grep tomcat4 to see if tomcat4 is installed

Rpm-qip example.rpm to view information about the example.rpm installation package

Rpm-qif / bin/df View the information of the installation package where the / bin/df file is located

Rpm-qlf / bin/df View the directory to which each file in the installation package of the / bin/df file is installed

RPM uninstall operation

Command:

Rpm-e installation packages that need to be uninstalled

Before uninstalling, you usually need to use rpm-Q … Command to find out the name of the installation package that needs to be uninstalled.

Examples are as follows:

Rpm-e tomcat4 Uninstalls the tomcat4 package

RPM upgrade operation

Command:

Rpm-U packages that need to be upgraded

Examples are as follows:

Rpm-Uvh example.rpm upgrade example.rpm package

RPM authentication operation

Command:

Rpm-V packages that need to be verified

Examples are as follows:

Rpm-Vf / etc/tomcat4/tomcat4.conf

The output information is similar to the following:

S.5....T c/ etc/tomcat4/tomcat4.conf

Where S indicates that the file size has been modified and T indicates that the file date has been modified. For more verification information, please refer to the rpm help file: man rpm

Other additional commands for RPM

-- force mandatory actions such as forced installation and deletion, etc.

-- requires shows the package's dependencies

-- nodeps ignores dependencies and continues

The above is all the contents of the article "how to use rpm commands in the Linux operating system". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report