The use of RPM tools in Linux: RPM installation / query / view / uninstall / upgrade software package

Philosophy of life 2020-11-09 16:55:35
use rpm tools linux rpm


One . About software packages

​ stay linux Installation package is required for software installation in , There are various types of software packages :.zip,.rar,.rpm,.tar.gz,.tar. Software package can also be divided into source code package and binary

package , A source code package is a package that has not been compiled , Need to go through GCC、C++ Compiler environment compiles to run . Binary packages do not need to be compiled , It can be installed and used directly . Distinguish whether it is

The source code package or binary package has to be judged based on the files in the software package , contain .h、.c、.cpp、.cc Wait for the end of the source file , Call it a source code package , And the software package contains

stay bin Catalog (bin There are executable files in the directory ), Call it binary package . Source packages are highly customizable , You can freely choose the function you need .

Two .RPM software package

​ RPM yes RPM Package Manager(RPM Package manager ) Abbreviation , Although the name of this file format is marked RedHat The logo of , But the original design idea is

Open style , Now it includes OpenLinux、SUSE as well as Turbo Linux etc. Linux The distribution versions of are all adopted , It can be regarded as a recognized industry standard .RPM Packages are binary packages

You can use it directly .

​ rpm How to get packages :Centos System image disc ; Website http://rpmfind.net/; Download all kinds of software from the official website .

3、 ... and .RPM The general naming rules for packages

RPM The general naming rule for packages is :name-version-arch.rpm perhaps name-version-arch.src.rpm.

  • ​ name It's the name of the package
  • ​ version It's the version number of the software , The format of the version number is usually “ The major version number . Sub version number . Amendment number ”, There's also a release number , Express this RPM How many times is the package compiled
  • ​ arch Indicates the hardware platform for which the software package is applicable , at present RPM Supported platforms are :i386,i586,i686、sparc,alpha,x86_64 wait
  • ​ .rpm or .src.rpm, yes RPM Suffix for package type ,.rpm It's a compiled binary package , You can use rpm Command direct installation ;.src.rpm Represents a source code package , It needs to be compiled before it can be used
  • ​ el* Indicates the publisher version of this package ,el7 This software package is in RHEL 7.x/CentOS 7.x Next use
  • ​ devel: Express this RPM A package is a software development package
  • ​ noarch: Explain that such a package can be installed on any platform , No specific hardware platform is required . It can run on any hardware platform
  • ​ manual Manual documentation
httpd-2.2.3-29.el5.i386.rpm
Software name httpd| Software version number 2.2.3| Release No 29|el5 The software package is in RHEL 7.x/CentOS 7.x Next use | The suitable hardware platform is included i386|RPM Packet type

Four .RPM Tool use

RPM Tools can be installed 、 Inquire about 、 verification 、 to update 、 Delete and other operations .

4.1 rpm The function of installing software

1.RPM Command format for :rpm [ Parameters ] software package ,rpm The installation parameters are :

  • ​ -i yes install It means , Install package
  • ​ -v Show additional information , Provide more details
  • ​ -V check , Verify the installed software
  • ​ -h --hash Output during installation #### Mark

2. Use rpm when , When to use the full package name , When the package name is used ?

answer :1. Use full name when installing and updating upgrades ;2. When operating on an already installed package , For example, find a package that has been installed , Unload packages, etc , Use the package name .

3. When we use rpm Look for a rpm When installing package information , Default to directory /var/lib/rpm Here's a search . When one rpm After the package is installed on the system , Installation information is usually

It will be kept locally /var/lib/rpm/ Under the table of contents .

[root@node5 ~]# ls /var/lib/rpm
Basenames Conflictname __db.001 __db.002 __db.003 Dirnames Group Installtid Name Obsoletename Packages Providename Requirename Sha1header Sigmd5 Triggername

4. Install locally rpm Installation package

[root@node5 ~]# rpm -ivh telnet-0.17-64.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:telnet-1:0.17-64.el7 ################################# [100%]

5. Download from the Internet centos epel Extended source , Then install

# notes :epel The source is right centos7 The system comes with base Source extension .
[root@node5 ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:epel-release-7-12 ################################# [100%]

6. install rpm When the package , Sometimes you need to resolve dependencies , At this time, according to the prompt , Install dependency packages first , Just install it again .

[root@node5 ~]# rpm -ivh mariadb-server-5.5.56-2.el7.x86_64.rpm
Warning :/mnt/Packages/mariadb-server-5.5.56-2.el7.x86_64.rpm: head V3 RSA/SHA256 Signature, secret key ID f4a80eb5: NOKEY
error : Dependency detection failed :
mariadb(x86-64) = 1:5.5.56-2.el7 By mariadb-server-1:5.5.56-2.el7.x86_64 need
perl-DBD-MySQL By mariadb-server-1:5.5.56-2.el7.x86_64 need
solve :
[root@node5 ~]# rpm -ivh /mnt/Packages/mariadb-5.5.56-2.el7.x86_64.rpm
[root@node5 ~]# rpm -ivh /mnt/Packages/perl-DBD-MySQL-4.023-5.el7.x86_64.rpm
[root@node5 ~]# rpm -ivh /mnt/Packages/mariadb-server-5.5.56-2.el7.x86_64.rpm

4.2 rpm Query function

1.rpm The query syntax :rpm -q(query), It is often used in combination with the following parameters

  • ​ -a(all) Query all installed packages
  • ​ -f(file) Query system file name ( Query which software package the system file belongs to ), Reverse query
  • ​ -i Show installed rpm Package information , The name of the bag is directly in the back
  • ​ -l(list) Query the installation location of the files in the package
  • ​ -p Query for information about packages that are not installed , The full name of the software should be followed
  • ​ -R Query package dependencies
# Inquire about zsh Is the package installed
[root@node5 ~]# rpm -q zsh
zsh-5.0.2-34.el7_8.2.x86_64
# Query all installed packages
[root@node5 ~]# rpm -qa
......
libX11-1.6.7-2.el7.x86_64
kernel-3.10.0-693.el7.x86_64
setup-2.8.71-7.el7.noarch
......
# Query all installed packages with rest Keyword package
[root@node5 ~]# rpm -qa | grep rest
rest-0.8.1-2.el7.x86_64
# see find Path to command
[root@node5 ~]# which find
/usr/bin/find
# see find Path to command
[root@node5 ~]# whereis find
find: /usr/bin/find /usr/share/man/man1/find.1.gz
# Query which installation package the file or command belongs to
[root@node5 ~]# rpm -qf /usr/bin/find
findutils-4.5.11-5.el7.x86_64
# Query the installed rpm Details or functions of a package
[root@node5 ~]# rpm -qi hardlink
Name : hardlink
Epoch : 1
Version : 1.0
Release : 19.el7
Architecture: x86_64
Install Date: Fri 26 Apr 2019 05:10:21 PM CST
Group : System Environment/Base
Size : 16545
License : GPL+
Signature : RSA/SHA256, Fri 04 Jul 2014 09:53:40 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : hardlink-1.0-19.el7.src.rpm
Build Date : Tue 10 Jun 2014 02:26:04 PM CST
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://pkgs.fedoraproject.org/gitweb/?p=hardlink.git
Summary : Create a tree of hardlinks
Description :
hardlink is used to create a tree of hard links.
It's used by kernel installation to dramatically reduce the
amount of diskspace used by each kernel package installed.
# Query not installed rpm Details or functions of a package
[root@node5 ~]# rpm -qpi telnet-0.17-64.el7.x86_64.rpm
Name : telnet
Epoch : 1
Version : 0.17
Release : 64.el7
Architecture: x86_64
Install Date: (not installed)
Group : Applications/Internet
Size : 115888
License : BSD
Signature : RSA/SHA256, Fri 11 Aug 2017 04:04:43 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : telnet-0.17-64.el7.src.rpm
Build Date : Fri 04 Aug 2017 04:00:38 AM CST
Build Host : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://web.archive.org/web/20070819111735/www.hcs.harvard.edu/~dholland/computers/old-netkit.html
Summary : The client program for the Telnet remote login protocol
Description :
Telnet is a popular protocol for logging into remote systems over the
Internet. The package provides a command line Telnet client
# see rpm After installation , What files will be generated
[root@node5 ~]# rpm -qpl telnet-0.17-64.el7.x86_64.rpm
/usr/bin/telnet
/usr/share/doc/telnet-0.17
/usr/share/doc/telnet-0.17/README
/usr/share/man/man1/telnet.1.gz
# View installed commands , What files have been generated
[root@node5 ~]# rpm -ql telnet
/usr/bin/telnet
/usr/share/doc/telnet-0.17
/usr/share/doc/telnet-0.17/README
/usr/share/man/man1/telnet.1.gz

4.3 rpm Check to see if the content of the package has been modified

1. grammar :rpm -V Package name perhaps rpm -Vf File path

[root@node5 ~]# which telnet
/usr/bin/telnet
[root@node5 ~]# rpm -qf /usr/bin/telnet
telnet-0.17-64.el7.x86_64
# see telnet Whether the content of the command has been modified , No output , It has not been modified
[root@node5 ~]# rpm -Vf /usr/bin/telnet
[root@node5 ~]# echo aaa >> /usr/bin/telnet
[root@node5 ~]# rpm -Vf /usr/bin/telnet
S.5....T. /usr/bin/telnet
[root@node5 ~]# rpm -V telnet
S.5....T. /usr/bin/telnet
# notes : If you execute rpm -V Package name It's all a little bit , Means the test passed , The content of the command has not been modified
# The following characters appear to represent a test failure , That is, the content of the command is modified
5 — MD5 Is the checksum changed , You also see whether the contents of the document have changed
S — file length , Whether the size changes
L — A symbolic link , Whether the file path changes
T — Whether the modification date of the document has changed
D — equipment
U — user , Owner of document
G — User group
M — Pattern ( Contains permissions and file types )
? — Unreadable files
# file type
c The configuration file
d Ordinary documents
g Files that shouldn't have appeared , This means that this file should not be included in this package
l Authorization documents (license file)
r Description file

2. Look at all the... In the system rpm Whether the package and installation files have been modified by hackers ?

# notes : Check with reference to /var/lib/rpm In the catalog rpm database information
[root@node5 ~]# rpm -Va > rpm_check.txt
[root@node5 ~]# ll rpm_check.txt -h
-rw-r--r-- 1 root root 629 Oct 19 21:34 rpm_check.txt
[root@node5 ~]# cat rpm_check.txt
.......T. c /etc/httpd/conf/httpd.conf
S.5....T. c /etc/sysconfig/authconfig
....L.... c /etc/pam.d/fingerprint-auth
....L.... c /etc/pam.d/password-auth
....L.... c /etc/pam.d/postlogin
....L.... c /etc/pam.d/smartcard-auth
....L.... c /etc/pam.d/system-auth
S.5....T. c /etc/security/limits.conf
missing /var/run/wpa_supplicant
S.5....T. c /etc/vsftpd/vsftpd.conf
.....UG.. /var/ftp/pub
S.5....T. c /etc/sysconfig/iptables
.......T. /usr/aarch64-linux-gnu/include/rpc/netdb.h
S.5....T. /usr/bin/telnet
S.5....T. c /etc/rc.d/rc.local
.M....... /etc/rc.d/init.d/functions
S.5....T. c /etc/sysctl.conf

4.4 rpm The function of unloading Software

1. Syntax to uninstall software :rpm -e(erase) Package name

[root@node5 ~]# rpm -q telnet
telnet-0.17-64.el7.x86_64
[root@node5 ~]# rpm -e telnet
[root@node5 ~]# rpm -q telnet
package telnet is not installed
# Sometimes an unloaded package has dependencies , So add --nodeps Force uninstall software
[root@node5 ~]# rpm -e --nodeps lrzsz

4.5 rpm Upgrade the function of the software

1. grammar :rpm -Uvh Package name

[root@node5 ~]# rpm -Uvh telnet-0.17-64.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:telnet-1:0.17-64.el7 ################################# [100%]
版权声明
本文为[Philosophy of life]所创,转载请带上原文链接,感谢

  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云