当前位置:网站首页>RPM package management

RPM package management

2022-04-23 18:41:00 Shi Ying

RPM Package Overview

What is? rpm package

Software developed by red hat 、 upgrade 、 install 、 uninstall 、 Query tools

Why use rpm

As in the windows Same in the system , If you want to install one QQ, Install a wechat , Install a game , First, go to the official website of the software to download the relevant software package , Is usually .exe Installation package . And that green package , Once downloaded , Unpack it and you can use it without installation .

that Linux There are also many kinds of installation packages , We are Linux You also need to install software on the , There are many kinds of software packages , But the most convenient , The most simple , The easiest , The fastest , That is to say rpm It's packed .

rpm Package naming rules

      
      
## tree-1.6.0-10.el7.x86_64.rpm
tree: Software name
1.6.0: Version number
10: The number of releases of this version
el7: Applicable system version (RedHat7,CentOS7) Backwards compatible
x86_64: system platform 64 x86:32 position i386
rpm: Package suffix
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

Linux How to install the software in

      
      
rpm install : The compiled source code package , After downloading , Use it directly rpm Command installation The version will be lower than the official version
Source code installation : To compile the first , Translate the source code into software recognized by the system , Install again The steps are complicated
Binary installation : Green software ( Installation free ) Not all programs have binary packages
  • 1.
  • 2.
  • 3.

RPM Package access

  • System CD image /CentOS Official website : TP

1. Check whether the disc is in the optical drive

mount mount uninstall umount grammar

      
      
# Mount Syntax
mount Source device file The target path
[[email protected] ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only

# View disk information
df -h Check the disk partition , Disk usage , You can also view the mounted equipment and directory
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 980M 0 980M 0% /dev
tmpfs 991M 0 991M 0% /dev/shm
tmpfs 991M 9.6M 981M 1% /run
tmpfs 991M 0 991M 0% /sys/fs/cgroup
/dev/sda3 18G 1.6G 16G 10% /
/dev/sda1 497M 125M 373M 25% /boot
tmpfs 199M 0 199M 0% /run/user/0
/dev/sr0 4.4G 4.4G 0 100% /mnt

# Uninstall Syntax
umount The target path
umount /mnt
[[email protected] ~]# umount /mnt

## Mount error report [[email protected] yjc ~ ] # mount /dev/cdrom /mnt
mount: no medium found on /dev/sr0
reason : The device file is empty , There's nothing in it , The optical drive is not connected

## Unloading error
[[email protected] mnt]# umount /mnt
umount: /mnt: target is busy.
(In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))
[[email protected] mnt]# cd
[[email protected] ~]# umount /mnt
reason : Device busy


## View mount results

[[email protected] ~]# ll /mnt
total 696
-rw-r--r--. 3 root root 14 Oct 30 2020 CentOS_BuildTag
drwxr-xr-x. 3 root root 2048 Oct 27 2020 EFI
-rw-rw-r--. 21 root root 227 Aug 30 2017 EULA
-rw-rw-r--. 21 root root 18009 Dec 10 2015 GPL
drwxr-xr-x. 3 root root 2048 Oct 27 2020 images
drwxr-xr-x. 2 root root 2048 Nov 3 2020 isolinux
drwxr-xr-x. 2 root root 2048 Oct 27 2020 LiveOS
drwxr-xr-x. 2 root root 673792 Nov 4 2020 Packages
drwxr-xr-x. 2 root root 4096 Nov 4 2020 repodata
-rw-rw-r--. 21 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 21 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2883 Nov 4 2020 TRANS.TBL

If it's unloaded zip file
[[email protected] ~]# yum remove zip -y

Switch to /mnt/Packages/ Under the table of contents
[[email protected] ~]# /mnt/Packages/
[[email protected] ~]# cd /mnt/Packages/
rpm Package installation
[[email protected] Packages]# rpm -ivh zip-3.0-11.el7.x86_64.rpm

/mnt/Packages There's a lot in it rpm package
[[email protected] Packages]# ls -l |wc -l
4072
[[email protected] Packages]# ll /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.

rpm Command to use - install

      
      
# grammar :
rpm [ Options ] rpm Package name
rpm Package name :
- Local package name : In a directory in the system rpm package
- Remote package name : Don't download , Directly use the... On the website rpm package
# Options :
-i:install install
-v: Show the installation process
-h: Display the progress bar of the installation
--test: Test only , Not to install
--force: Mandatory installation
--nodeps: Ignore dependencies

give an example :
# Local package name -i rpm Specify the path to install
[[email protected] Packages]# yum remove tree -y
[[email protected] Packages]# cd
[[email protected] ~]# rpm -i /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm
[[email protected] ~]# echo $?
0
[[email protected] ~]# tree
.
├── 111
├── 123tar.gz
├── 1.txt
├── 2.txt
├── 3.txt
└── tmp

## -v
[[email protected] ~]# rpm -iv /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm
Preparing packages...
tree-1.6.0-10.el7.x86_64

## -h
[[email protected] ~]# rpm -ivh /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:tree-1.6.0-10.el7 ################################# [100%]

## --test Just a test
[[email protected] ~]# cd /mnt/Packages/
[[email protected] Packages]# rpm -ivh --test tree-1.6.0-10.el7.x86_64.rpm
Preparing... ################################# [100%]
package tree-1.6.0-10.el7.x86_64 is already installed

## --force --nodeps In combination with Enforce installation Ignoring dependencies are bug

If zip uninstall It can be remotely aliyun The mirror station cannot find the package name Copy the URL and install
[[email protected] ~]# rpm -ivh https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/zip-3.0-11.el7.x86

## Be careful :rpm Command management rpm Disadvantages of package , Can't resolve dependencies https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/zip-3.0-11.el7.x86
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • RPM Package query official website : tp
  • Other official software websites

rpm Command to use - Inquire about

      
      
# grammar
rpm [ Options ] rpm Package name
# Options
-q: Check whether the specified installation package is installed query Inquire about

--- The following options should be matched -q Use ---
-a: All installed packages all
-i: Details infor
-l: List rpm Package related configuration files and directories
-c: View only the configuration files related to the package
-d: Only view the help document file of the software
-f: Reverse lookup , According to the configuration file , Catalog , Help document , Find out which package the file belongs to
--scripts: Check out the installation package , Before and after installation , And scripts to be executed before and after uninstallation

----- Use with the above options
-p: Query for packages that are not installed

-qip: No package installation details ( Specify an existing full package name or remote package name )
-qlp: Check which files will be generated if there is no installation package ( Specify an existing full package name or remote package name )
-qcp: Check which configuration files will be generated if there is no package installed ( Specify an existing full package name or remote package name )
-qdp: Check what help files will be generated if there is no package installed ( Specify an existing full package name or remote package name

## give an example :
## -q
[[email protected] Packages]# rpm -q tree
tree-1.6.0-10.el7.x86_64
[[email protected] Packages]# rpm -q vim-common
vim-common-7.4.629-8.el7_9.x86_64

## -q -a View contains net Installed packages
[[email protected] Packages]# rpm -q net
package net is not installed
[[email protected] Packages]# rpm -qa |grep 'net'
libnfnetlink-1.0.1-4.el7.x86_64
libnetfilter_conntrack-1.0.6-1.el7_3.x86_64
dracut-network-033-572.el7.x86_64

No package name after it View all
[[email protected] Packages]# rpm -qa

## -i Followed by the complete package name
[[email protected] Packages]# rpm -qi net-tools

[[email protected] Packages]# rpm -qa |grep 'net'|xargs rpm qi
[[email protected] Packages]# rpm -qi `rpm -qa | grep 'net'`
[[email protected] Packages]# rpm -qi $(rpm -qa | grep 'net')

## -l
[[email protected] Packages]# rpm -ql zip
/usr/bin/zip
/usr/bin/zipcloak
/usr/bin/zipnote

[[email protected] Packages]# rpm -ql tree
/usr/bin/tree
/usr/share/doc/tree-1.6.0
## -c Client configuration file
[[email protected] Packages]# rpm -qc mariadb
/etc/my.cnf.d/client.cnf
Server profile
[[email protected] Packages]# rpm -qc mariadb-server
/etc/logrotate.d/mariadb
/etc/my.cnf.d/server.cnf
/var/log/mariadb/mariadb.log
## -d Only view help
[[email protected] Packages]# rpm -qd zip
/usr/share/doc/zip-3.0/CHANGES
/usr/share/doc/zip-3.0/LICENSE
/usr/share/doc/zip-3.0/README
/usr/share/doc/zip-3.0/README.CR

## -f Reverse search for which package
[[email protected] Packages]# rpm -qf /etc/passwd
setup-2.8.71-11.el7.noarch

[[email protected] Packages]# rpm -qf /etc/hostname
systemd-219-78.el7.x86_64

[[email protected] Packages]# rpm -ql setup
/etc/aliases
/etc/bashrc
/etc/csh.cshrc
/etc/csh.login
# Find which package it belongs to
[[email protected] Packages]# rpm -qf /etc/hostname
systemd-219-78.el7.x86_64
# What configuration files and directories are in the package
[[email protected] ~]# rpm -ql systemd
# Filter contains bin The file of
[[email protected] ~]# rpm -ql systemd |grep 'bin'

rpm -ql $(rpm -qf /etc/hostname)

[[email protected] Packages]# ll /etc/hostname
-rw-r--r--. 1 root root 22 Mar 14 22:34 /etc/hostname
[[email protected] Packages]# cat /etc/hostname
localhost.localdomain
rename user
[[email protected] Packages]# hostnamectl set-hostname shiying
[[email protected] ~]# cat /etc/hostname
shiying

## --scripts
[[email protected] ~]# rpm -q --scripts mariadb-server


## -p qip View not installed nginx Details
[[email protected] ~]# rpm -qip https://mirrors.aliyun.com/epel/7/x86_64/Packages/n/nginx-1.20.1-9.el7.x86_64.rpm
warning: https://mirrors.aliyun.com/epel/7/x86_64/Packages/n/nginx-1.20.1-9.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Name : nginx
Epoch : 1
Version : 1.20.1
Release : 9.el7
Architecture: x86_64

#-qlp See which bags to pack
[[email protected] ~]# rpm -qlp https://mirrors.aliyun.com/epel/7/x86_64/Packages/n/nginx-1.20.1-9.el7.x86_64.rpm
warning: https://mirrors.aliyun.com/epel/7/x86_64/Packages/n/nginx-1.20.1-9.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
/etc/logrotate.d/nginx
/etc/nginx/fastcgi.conf
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.

rpm Command to use - upgrade

      
      
Options :
-U:update upgrade , If the old version doesn't exist , Install , If the old version exists, upgrade
-f: You must have an old version to upgrade

##-U

[[email protected] Packages]# rpm -qip tree-1.6.0-10.el7.x86_64.rpm
Name : tree
Version : 1.6.0
Release : 10.el7
Architecture: x86_64
Install Date: (not installed)
Group : Applications/File
Size : 89505

[[email protected] Packages]# rpm -Uvh tree-1.6.0-10.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:tree-1.6.0-10.el7 ################################# [100%]

## download nginx package
[[email protected] ]# wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.10.0-1.el7.ngx.x86_64.rpm

[[email protected] ]# wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.12.0-1.el7.ngx.x86_64.rpm

## upgrade installation nginx My bag
[[email protected] ~]# rpm -Uvh nginx-1.10.0-1.el7.ngx.x86_64.rpm
warning: nginx-1.10.0-1.el7.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:nginx-1:1.10.0-1.el7.ngx ################################# [100%]
------------------------------------------------------
## Query the installed in the current system nginx My bag (1.10 edition
[[email protected] ~]# rpm -qa |grep nginx
nginx-1.10.0-1.el7.ngx.x86_64


## Use ivh install nginx 1.12 Version of the package
[[email protected] ~]# rpm -ivh nginx-1.12.0-1.el7.ngx.x86_64.rpm

warning: nginx-1.12.0-1.el7.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Preparing... ################################# [100%]
file /etc/logrotate.d/nginx from install of nginx-1:1.12.0-1.el7.ngx.x86_64 conflicts with file from package nginx-1:1.10.0-1.el7.ngx.x86_64
file /usr/sbin/nginx from install of nginx-1:1.12.0-1.el7.ngx.x86_64 conflicts with file from package nginx-1:1.10.0-1.el7.ngx.x86_64
file /usr/sbin/nginx-debug from install of nginx-1:1.12.0-1.el7.ngx.x86_64 conflicts with file from package nginx-1:1.10.0-1.el7.ngx.x86_64
file /usr/lib/systemd/system/nginx.service from install of nginx-1:1.12.0-1.el7.ngx.x86_64 conflicts with file from package nginx-1:1.10.0-1.el7.ngx.x86_64
file /usr/libexec/initscripts/legacy-actions/nginx/upgrade from install of nginx-1:1.12.0-1.el7.ngx.x86_64 conflicts with file from package nginx-1:1.10.0-1.el7.ngx.x86_64

# The above report is wrong : Because... Already exists in the system 1.10 Version of nginx So it can't be used ivh install

## -Uvh upgrade Old version uninstall
[[email protected] ~]# rpm -Uvh nginx-1.12.0-1.el7.ngx.x86_64.rpm
warning: nginx-1.12.0-1.el7.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:nginx-1:1.12.0-1.el7.ngx ################################# [ 50%]
Cleaning up / removing...
2:nginx-1:1.10.0-1.el7.ngx ################################# [100%]

[[email protected] ~]# rpm -qa nginx
nginx-1.12.0-1.el7.ngx.x86_64

## -f The old version can only be upgraded if it exists
[[email protected] ~]# rpm -fvh nginx-1.12.0-1.el7.ngx.x86_64.rpm
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.

rpm Command to use - uninstall

      
      
# Options
-e: Just follow the uninstalled package name
[[email protected] ~]# rpm -qa|grep nginx
nginx-1.12.0-1.el7.ngx.x86_64
[[email protected] ~]# rpm -e nginx
[[email protected] ~]# rpm -qa |grep nginx

Batch deletion If there is a dependency, the uninstall is unsuccessful
[[email protected] ~]# rpm -qa|grep mariadb
mariadb-server-5.5.68-1.el7.x86_64
mariadb-5.5.68-1.el7.x86_64
mariadb-libs-5.5.68-1.el7.x86_64
[[email protected] ~]# rpm -e $(rpm -qa|grep mariadb)
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.

yum Report errors

      
      
## 1. Report errors
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/Packages/python-srpm-macros-3-34.el7.noarch.rpm: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com;Unknown error

as a result of aliyun Of Base There are two other sources baseurl= Those two websites are not used by us , You can delete

## 2. Report errors
[[email protected] ~]# yum install -y tr
Loaded plugins: fastestmirror
Existing lock /var/run/yum.pid:
another copy is running as pid 37209.Another app is currently holding the yum lock; waiting for it to exit...
The other application is: yum Memory : 24 M RSS (769 MB VSZ)
Started: Thu Apr 2121:33:34 2022-00:06 ago
State : Sleeping, pid: 37209

reason : There are already yum The process is installing Services , Or wait until the installation is over , or kill PID

## 3. Network fluctuations
Do it a few more times

## 4. The environment variable is corrupted baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/

$releasever:7
$basearch: x86_64
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.


版权声明
本文为[Shi Ying]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231832386451.html