Management of rpm command

Posted by Graeme1972 on Fri, 13 Dec 2019 18:22:17 +0100

1. Difference between Yum and rpm
 The yum command will find the dependency from the image itself when installing the software, and then resolve it. If it fails to resolve it, an error will be reported
 The rpm command does not solve the dependency when installing the software. It is applicable to the installation of all software packages

2. Details of rpm package name (take rpm package of wps as an example)

wps-office-10.1.0.5672-1.a21.x86_64.rpm
Software name version No. applicable system architecture applicable rpm system software

3.rpm command details

rpm   -ivh   name.rpm        # install      
	-i       # install      
	-v       # Display process      
	-h       # hash encryption
rpm  -e    name.rpm          # uninstall
rpm  -p    name              # The specified query is software, which has been installed
rpm  -qp   name.rpm          # Specify the package to query. This software can not be installed
rpm  -ql    name             # Query all file names generated when installing the software (the software must have been installed)
rpm  -qlp   name.rpm         # Query what files will be generated after software installation (software may not be installed)
rpm  -qc   name              # Query the name of the profile generated when installing the software   
rpm  -qd   name              # Query the name of the instruction file generated when installing the software   
rpm  -qa                     # Query all software installed in the system     
     -q        # See      
     -a        # All
rpm  -qf   filename             # Query which installation package a file belongs to
rpm  -ivh   name.rpm --nodeps   # Ignore dependency
rpm  -ivh   name.rpm --force    # Forced installation, dependency cannot be ignored
rpm  -Kv    name.rpm            # Detect whether the package has been tampered with
rpm  -qp   name.rpm   --scripts # Detect actions performed by software during installation or uninstallation 
rpm  -qi    name                # View software information 
rpm  -qa  | grep name           # Check whether the software is installed (the software name can be incomplete)

[root@localhost Desktop]# cd /root/Downloads/
[root@localhost Downloads]# ls
FluffyMcAwesome-A-6.4.0-11.r19335.x86_64.rpm
FluffyMcAwesome-B-6.4.0-11.r19335.x86_64.rpm
kolourpaint-4.10.5-4.el7.x86_64.rpm
kolourpaint-libs-4.10.5-4.el7.x86_64.rpm
wps-office-10.1.0.5672-1.a21.x86_64.rpm
[root@localhost Downloads]# rpm -q wps-office-10.1.0.5672-1.a21.x86_64.rpmpackage 
wps-office-10.1.0.5672-1.a21.x86_64.rpm is not installed	
[root@localhost Downloads]# rpm -pq wps-office-10.1.0.5672-1.a21.x86_64.rpm
wps-office-10.1.0.5672-1.a21.x86_64 

[root@localhost Downloads]# rpm -ql httpd   # Only a few are listed here
/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
[root@localhost Downloads]# rpm -qc httpd

[root@localhost Downloads]# rpm -qd httpd   # Only a few are listed here
/usr/share/doc/httpd-2.4.6/ABOUT_APACHE
/usr/share/doc/httpd-2.4.6/CHANGES
/usr/share/doc/httpd-2.4.6/LICENSE
/usr/share/doc/httpd-2.4.6/NOTICE
/usr/share/doc/httpd-2.4.6/README
[root@localhost Downloads]# rpm -qa      # View all software installed in the system
[root@localhost Downloads]# rpm -qf /etc/httpd   # Check which installation package / etc/httpd belongs to
httpd-2.4.6-40.el7.x86_64
[root@localhost Downloads]# cp  kolourpaint-4.10.5-4.el7.x86_64.rpm kolourpaint-4.10.5-4.el7.x86_641.rpm  # Back up the software
[root@localhost Downloads]# rpm -Kv kolourpaint-4.10.5-4.el7.x86_641.rpm   # Check the status of the original software, ok means normal 
[root@localhost Downloads]# echo hello >>  kolourpaint-4.10.5-4.el7.x86_641.rpm  # Change software content
[root@localhost Downloads]# rpm -Kv kolourpaint-4.10.5-4.el7.x86_641.rpm  # Once detected again, tampering will be detected


Check the actions performed by the software during installation or uninstallation to ensure the safety of the software

[root@localhost Downloads]# rpm -qp FluffyMcAwesome-A-6.4.0-11.r19335.x86_64.rpm --scripts 
[root@localhost Downloads]# rpm -qp FluffyMcAwesome-B-6.4.0-11.r19335.x86_64.rpm --scripts

4. Disassembly of RPM package

rpm2cpio ා collect data
[root@localhost Desktop]# kolourpaint    # Call command to open drawing software



Simulate the configuration file where the delete command is located

[root@localhost Desktop]# which kolourpaint   # Check the directory where the kolourpaint process is located. It is convenient to recover later
/usr/bin/kolourpaint
[root@localhost Desktop]# rm -fr /usr/bin/kolourpaint
[root@localhost Desktop]#  kolourpaint    # Call the command again and it will fail
bash: /usr/bin/kolourpaint: No such file or directory
Reinstallation can solve this problem, but reinstallation will overwrite all the original files. Now you can solve this problem by splitting the rpm package
[root@localhost software]# cp kolourpaint-4.10.5-4.el7.x86_64.rpm /mnt  # Back up the software package to / mnt, and do experiments in / mnt
[root@localhost software]# cd /mnt
[root@localhost mnt]# rpm2cpio kolourpaint-4.10.5-4.el7.x86_64.rpm | cpio -id   #Collect the file contents of rpm to the / mnt directory
3861 blocks 
[root@localhost mnt]# ls
kolourpaint-4.10.5-4.el7.x86_64.rpm  usr
[root@localhost mnt]# cd usr/
[root@localhost usr]# ls
bin  share
[root@localhost usr]# cd bin/
[root@localhost bin]# ls  
 Kolourpaint
[root@localhost bin]# pwd    # Find the location of Kolourpaint
/mnt/usr/bin
[root@localhost bin]# cp kolourpaint /usr/bin/   # Restore to the default directory of Kolourpaint
[root@localhost bin]# kolourpaint   # Call the command again and it will be restored 

Topics: Operation & Maintenance RPM yum