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

Usage of package management tools rpm and yum

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Usage of package management tools rpm and yum

I. the usage of rpm

Rpm, originally a Rde Hat Linux distribution program designed to manage Linux suites, is popular because it follows GPL rules and is powerful and convenient. Gradually received the adoption of other distributions, the emergence of RPM suite management, making Linux easy to install and upgrade, indirectly improving the applicability of Linux.

Rpm usage: rpm [OPTION...]

1. Rpm installs the package, which needs to follow the absolute or relative path of the package file.

Common options:

-v: displays the execution of the instruction

-vv: displays the execution process of the instruction in detail to facilitate troubleshooting

-h: show the progress of package management execution with the # number

-imam Musi install: installer

Rpm can also use the following options when performing an installation:

-- test: test the installation, but do not actually perform the installation

-- nodeps: sometimes the installed package has dependencies, so you need to install the dependent packages first, and then ignore the dependencies after using this option

-- nodigest: do not check the integrity of the package

-- nosignature: do not check the source validity of the package

-- noscripts: some programs will execute the corresponding script when they are installed. Using this option, the script that comes with the program will not be executed.

-- force: mandatory

(1) rpm installation package, it is possible to install some files in the package may overwrite existing files, there may be warnings or prompts, by default can not be correctly installed, then you can use rpm-- force-I to force the installation.

(2) rpm installation package, it is possible to install some of the software required by the package is not installed, by default can not be correctly installed, then you can use rpm-- nodeps-I to ignore this information, if you use rpm-I-- force-- nodepe can ignore all dependencies and file problems, any package can be installed, but this forced installation of the package can not guarantee full functionality.

2. Rpm2cpio tool, which can extract and install any single file in the rpm package. If a program on the system has been installed, but only a file is missing so that the program cannot be used, in this case, if you run rpm-ivh directly to install, you will be prompted to install it. If you keep up with-- force forced installation, all files of the program will be overwritten. In this case, you can use the rpm2cpio tool to extract and install the program, as follows:

Step 1: rpm2cpio package files | cpio-itv: you can preview the list of files in the package

Step 2: rpm2cpio package file | cpio-idv "a file": release only one file in the package list

Step 3: just copy a released file to the desired directory

3. Rpm upgrade software package, which can be upgraded in two ways:

Rpm {- U |-- upgrade} [install-options] PACKAGE_FILE...

And rpm {- F |-- freshen} [install-options] PACKAGE_FILE...

-U |-- upgrade: when upgrading a package in this way, "upgrade" if an old version of the package is installed, and "install" if the old version of the package does not exist.

-F |-- freshen: when upgrading a package in this way, "upgrade" is performed if an old version of the package is installed, and no upgrade operation is performed if the old version of the package does not exist.

The common syntax is:

Rpm-Uvh PACKAGE_FILE... Install or upgrade packages

Rpm-Fvh PACKAGE_FILE...: only upgrades the package based on the old version

If there is a prompt or warning during the upgrade process that makes it impossible to upgrade, you can also force the upgrade in combination with-- force.

If the software does not work properly after the upgrade, you can use-- oldpackage to downgrade the program when you need to uninstall the upgraded package.

Note: if the configuration file of the original package has been modified after installation, the same configuration file provided by the new version will not directly overwrite the old version of the configuration file, but will be renamed (FILENAME.rpmnew) and retained.

4. Use rpm query package

Syntax: rpm {- Q |-- query} [select-options] [query-options]

If you follow only-Q without any options, you can get the full file name of an installed software package

[root@liang7 Packages] # rpm-Q zipzip-3.0-10.el7.x86_6

[select-options] options are:

-a: all packages, including all installed packages, can be queried against a keyword in combination with grep

[root@liang7 Packages] # rpm-qa... # omitted the listed package [root@liang7 Packages] # rpm-qa | grep zipunzip-6.0-15.el7.x86_64gzip-1.5-8.el7.x86_64zip-3.0-10.el7.x86_64bzip2-libs-1.0.6-13.el7.x86_64bzip2-1.0.6-13.el7.x86_64

-f: check which package installation generates the specified file

[root@liang7 Packages] # rpm-qf / bin/zipzip-3.0-10.el7.x86_64

-p rpmfile: query package files that have not been installed. Use this option with the full file name of the rpm package, and this option needs to be used in conjunction with other [query-options] options, such as rpm-qpl, rpm-qpi, etc.

-- whatprovides CAPABILITY: query which package provides the specified CAPABILITY (function, capability)

[root@fengl Packages] # rpm-Q-- whatprovides bash # query bash function provided by that package bash-4.2.46-19.el7.x86_64 [root@fengl Packages] # rpm-Q-- whatprovides tree # query which package provides the function of tree tree-1.6.0-10.el7.x86_64

-- whatrequires CAPABILITY: query which package the specified CAPAILITY is dependent on

[root@fengl Packages] # rpm-Q-- whatrequires bash # query which packages the bash function depends on, that is, which packages depend on the bash function dracut-033-359.el7.x86_64initscripts-9.49.30-1.el7.x86_64rsyslog-7.4.7-12.el7.x86_64lvm2-2.02.130-5.el7.x86_64kpatch-0.1.10-4.el7.noarchbash-completion-2.1-6.el7.noarch

[query-options] options are

-- changelog: query the version update record of the rpm package

[root@fengl Packages] # rpm-Q-- changelog tree * Fri Jan 24 2014 Daniel Mach-1.6.0-10-Mass rebuild 2014-01-24 * Fri Dec 27 2013 Daniel Mach-1.6.0-9-Mass rebuild 2013-12-27 * Thu Jul 04 2013 Tim Waugh-1.6.0-8-Handle large UID/GID values (bug # 980945). The latter part is omitted

-l: list the files in a software package. To use this option, you only need to specify the package name, not the .rpm suffix. If you are querying the list of files contained in the uninstalled package, you need to follow the-p option. In this case, you need to follow the full name of the uninstalled package, that is, with the .rpm suffix name.

[root@liang7 Packages] # rpm-ql zip/usr/bin/zip / usr/bin/zipcloak... # the latter part omits [root@liang7 Packages] # rpm-qpl tree-1.6.0-10.el7.x86_64.rpm / usr/bin/tree/usr/share/doc/tree-1.6.0/usr/share/doc/tree-1.6.0/LICENSE/usr/share/doc/tree-1.6.0/README/usr/share/man/man1/tree.1.gz

-c: query the configuration file of an installed program, along with the package name

[root@liang7 Packages] # rpm-qc yum/etc/logrotate.d/yum/etc/yum.conf/etc/yum/version-groups.conf

-d: query the relevant documents of a program, follow the package name, or follow-p to query the relevant documents of the uninstalled program.

[root@liang7 Packages] # rpm-qd yum/usr/share/doc/yum-3.4.3/AUTHORS/usr/share/doc/yum-3.4.3/COPYING/usr/share/doc/yum-3.4.3/ChangeLog... # the latter part omits [root@liang7 Packages] # rpm-qpd tree-1.6.0-10.el7.x86_64.rpm / usr/share/doc/tree-1.6.0/LICENSE/usr/share/doc/tree-1.6.0/README/usr/share/man/man1/tree.1.gz

-i:information, which displays the details of a software package, followed by the package name, or you can follow-p to query the details of uninstalled programs.

[root@liang7 Packages] # rpm-qi yumName: yumVersion: 3.4.3Release: 132.el7.centos.0.1Architecture: noarchInstall Date: Thu 21 Jul 2016 02:45:35 AM CST... # the latter part omits [root@liang7 Packages] # rpm-qpi tree-1.6.0-10.el7.x86_64.rpm Name: treeVersion: 1.6.0Release: 10.el7Architecture: x86_64Install Date: (not installed). # the latter part is omitted

-R: displays the CAPABILITY (capability) that the specified package depends on, followed by the package name, or you can follow-p to query the features that the uninstalled package depends on.

[root@liang7 Packages] # rpm-qR ziplibbz2.so.1 () (64bit) libc.so.6 () (64bit) libc.so.6 (GLIBC_2.14) (64bit). # the latter part is omitted

-- provides: lists the CAPABILITY (capabilities) provided by the specified package, followed by the package name, or you can follow-p to query the functions provided by the uninstalled package

[root@fengl Packages] # rpm-Q-- provides zip # to see what features zip provides zip = 3.0-10.el7zip (x86-64) = 3.0-10.el7

-- scripts: query the script that comes with the package, followed by the package name, or-p query the script that comes with the uninstalled package.

[root@fengl Packages] # rpm-Q-- scripts bashpostinstall scriptlet (using): nl ='\ n'sh ='/ bin/sh'..nlbash ='/ bin/bash'..nlf = io.open ('/ etc/shells', 'asides').. # the latter part is omitted

5. Use rpm to uninstall the package. You need to use the-e option when uninstalling the package. The specific usage is as follows:

Rpm {- e |-- erase} [--allmatches] [--nodeps] [--noscripts] [--notriggers] [--test] PACKAGE_NAME...

-- allmatches: uninstall all versions related to the specified program, for example, the old version and the new version of some programs can exist at the same time. Use this option to uninstall both the new version and the old version. By default, you can only uninstall one at a time. An error may be reported when uninstalling, and you do not know which version to uninstall.

-- nodeps: programs are also dependent when they are uninstalled. You need to uninstall programs that depend on them first. Using this option will not consider the dependencies and uninstall them directly.

-- noscripts: some programs will execute the corresponding script when they are uninstalled, but not when they are uninstalled after using this option

-- notriggers: trigger, that is, another action may be triggered when one program is uninstalled, and the triggered action will not be performed when this option is used.

-- test: test the uninstall, but do not actually perform the uninstall

6. Using rpm to verify the package, there are two kinds of verification, one is to verify the validity (signature) and integrity of the source of the package, and the other is to verify what changes have been made after the installation of the program.

(1) the integrity verification algorithm uses SHA256, and the signature verification algorithm uses RSA. If you want to verify the integrity and signature of the package, you need to import the required public key first: rpm-- import KEYFILE (the public key file provided on the Centos installation CD is RPM-GPG-KEY-CentOS-7). By default, the integrity and signature of each package is automatically detected when it is installed, and an alarm is prompted if the public key is not imported. You can also use the rpm-K | checksig RPMFILE command to check the integrity and signature of the package.

Rpm-qa gpg*: you can look up imported public key files

[root@fengl mnt] # rpm-- import RPM-GPG-KEY-CentOS-7 # Import the public key file [root@fengl mnt] # rpm-qa gpg* # query the imported public key file gpgme-1.3.2-5.el7.x86_64gpg-pubkey-f4a80eb5-53a7ff4b # this file is the imported file [root@fengl Packages] # rpm-K tree-1.6.0-10.el7.x86_64.rpm # verify tree package file tree-1.6.0-10.el7.x86_64.rpm: rsa sha1 (md5) pgp md5 OK

(2) check whether the attributes of the related files have been tampered with after the package is installed.

Usage: rpm {- V |-- verify} [select-option] [verify-options]

The verification results may be as follows:

S: file Size differs

M:Mode differs (includes permissions and file type)

5: digest (formerly MD5 sum) differs

D:Device major/minor number mismatch

L:readLink (2) path mismatch

U:User ownership differs

G:Group ownership differs

T:mTime differs

P:capabilities differ

7. Rpm database, all installed programs are recorded in rpm database, rpm checksum query and uninstall depend on rpm database.

Rpm database path: / var/lib/rpm

Rpm-- initdb: initializes the database and creates a new database if it does not already exist, otherwise no action is performed.

Rpm-- rebuilddb: rebuild the database index directory of the installed package header and create only the Packages files in the library directory.

II. The usage of YUM

The full name of YUM is Yellowdog Update Modifier,yum, which is the front-end program of rpm, which is used to solve the dependency of software packages. It can locate software packages among multiple libraries and is an alternative tool for up2date.

Yum repository: a warehouse that stores a large number of rpm packages and related metadata files (placed in a specific directory repodata)

1. Yum client configuration file:

/ etc/yum.conf: provides a common configuration for all warehouses.

/ etc/yum.repos.d/*.repo: provides configuration for the pointing of the warehouse. The pointing path of the warehouse supports the writing of three file server paths, namely ftp://, http:// and file:///, respectively.

The configuration files pointed to by the warehouse all end with ".reop". Multiple repositories can be configured in a configuration file, or a configuration file can be built in a warehouse, but you must ensure that the configuration of each warehouse is correct, otherwise problems with a warehouse will cause the yum feature to be unavailable. The configuration file of the warehouse mainly includes the following items:

[base] # Repository name. The required item name=CentOS-$releasever-Base # describes the path of the warehouse where baseurl= # stores rpm software packages. The required item gpgcheck= {1 | 0} # is enabled by default in the master configuration file, 1 means enabled, 0 means the public key path of gpgkey= # package verification is not enabled, and if verification is enabled, this item must be written enabled= {1 | 0} # whether the warehouse is enabled The main configuration file is enabled by default. 1 means enabled. 0 means failovermethod= {roundrobin | priority} # mode selection is not enabled. The default is roundrobin.

Example 1:

[root@fengl yum.repos.d] # cat base.repo [base] name=CentOS7baseurl= file:///mnt/gpgcheck=1gpgkey=file:///mnt/RPM-GPG-KEY-CentOS-7enable=1

2. The usage of the yum command: yum [options] [command] [package.]

Common command options are:

-- nogpgcheck: gpgcheck is prohibited

-y: automatically answer "yes"

-Q: silent mode

-c: specify the profile

-v: detailed mode

-R: sets the maximum waiting time in seconds for yum to process a command

-- noplugins: disable all plug-ins

-- disablerepo=repoidglob: temporarily disable the repo specified here

-- enablerepo=repoidglob: temporarily enable the repo specified here

Common commands are:

Yum repolist [all]: displays a list of all warehouses

Yum repolist enable: displays only the list of enabled warehouses

Yum repolist disable: displays only the list of warehouses that are not enabled

Yum list [all]: displays a list of packages, including all installed and all lists in the repository

Yum list available: displays a list of available programs

Yum list installed: displays a list of installed programs

Yum list updates: displays a list of programs that can be upgraded

Yum info package name: equivalent to rpm-qi. Check the package information, but the results are different between the two.

Yum provides FEATURE1...: see which package provides the specified feature (which can be a file)

Yum clean [packages | metadata | headers | expire-cache | dbcache | cache | all]: clean the cache

Yum search string1.: search for package name and profile information with specified keywords

Yum deplist PACKAGE1...: displays all dependencies of the specified rpm package

Install the package:

Yum install PACKAGE1 [PACKAGE2]...: install packages using yum

Yum-y install PACKAGE1 [PACKAGE2].: when installing, you will be prompted whether to perform the installation operation. If you add the-y option, you will not have to enter yes manually. It will be installed directly.

Yum reinstall PACKAGE1 [PACKAGE2]...: reinstall

Yum update [PACKAGE1] [PACKAGE2]...: upgrade package

Downgrade PACKAGE1 [PACKAGE2]...: downgrade

Yum check-update: check for available upgrade packs

Yum remove PACKAGE1 [PACKAGE2]...: uninstall the specified package

View yum transaction history:

Yum history: viewing history

Yum history info NUM: view the processing information of the num in yum history

Yum history undo NUM: rollback, that is, undo the NUM package installation in history

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

Database

Wechat

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

12
Report