Linux package management-RPM

Advanced linux articles

One, the way to obtain the package

1. CD or official server of the system release

2. The official site of the project

3. Third-party organizations

  • a, fedora-EPEL (recommended)
  • b, search engine:

pkgs
rpmfind
pbone

4. Make your own unique package.

5. Mount the system CD.

  • Mount the system CD to get the source code of the rpm package and install it

    mount /dev/cdrom /mnt
    mount: /mnt: WARNING: device write-protected, mounted read-only.
    取消挂载
    [root@Eryuege ~]# umount /mnt


Second, the responsibilities of the package manager

  • 1. Pack the binary program, library file, configuration file, and help file into one file;
  • 2. When installing the software, you need to put the binary files, library files, configuration files, and help files in the corresponding locations.
  • 3. Generate a database to track every file installed
  • 4. When the software is uninstalled, the files corresponding to the database generated during installation are deleted.

Third, the core functions of the package manager

  • 1. Make a software package
  • 2. Install the software
  • 3. Uninstall the software
  • 4. Upgrade software
  • 5. Query software
  • 6. Calibration software
  • The software package is divided into executable programs, library files, configuration files, help files, and header files.

Fourth, package management

1. Program composition list (unique to each package)

  • List of Documents
  • Script file to be run during installation or uninstallation

2. Database (public)

  • Package name and version
  • Dependency
  • Function Description
  • File path and check code information of each file generated by installation

The improper source of the software package or the source code package of a malicious attacker will cause the computer to be hijacked as a broiler and perform tool man behavior.
May cause Ddos attacks (denial of service attacks) on the local server


Five, software package classification

1. Binary format (initially compiled, ready to use after installation)

  • The author of the rpm package downloads the source program, after the compilation and configuration are completed, make the rpm package
  • why would we do that? because:

    Some features are selected at compile time. If this feature is not selected at compile time,
    the version of the rom package that cannot be used will lag behind the source code package, or even a lot.

2. Source code format (need to compile, also called self-customization)

  • Naming method: name-version.tar.gz

Such as a file: apache-tomact-9.0.37.tar.gz (software name. major version number. minor version number. release number. file format)


Six, software package management tools

1. Classification

  • Front-end tools, commonly used front-end tools are:
    • yum
    • apt-get
    • zypper (rpm front-end management tool on suse)
    • dnf (Fedora22+rpm front-end management tool)
  • Back-end management tools, commonly used tools are:
    • rpm
    • can

2. Attention

  • Front-end tools are dependent on back-end tools
  • The front-end tools exist to automatically resolve the dependencies of the back-end tools.

Seven, software installation method

  • 1. Install through front-end tools
  • 2. Install through back-end tools
  • 3. Compile and install

Eight, RPM package command specification

Insert picture description here
The meaning of el7 (Enterprise Linux 7 Enterprise Linux version 7)

1. The composition of the package

  • Main package: bind-9.7.1-1.el5.i586.rpm
  • Subpackage: bind-libs-9.7.1-1.el5.i586.rpm
  • Subpackage: bind-utils-9.7.1-1.el5.i586.rpm

2. Package name format

  • name-version-release-arch.rpm

name: name
version:: version (major version and minor version number)
release: release number
arch: operating system version

3. Description of package name format:

  • major (major version number): Generally, it is a major improvement-such as: mysql was 5.7 version before being acquired by Oracle, and mysql8 was released directly after being acquired by Oracle
  • minor (minor version number): a major change in a sub-function (even-numbered versions are relatively stable versions, odd-numbered versions are generally development versions)
  • release (release number): fixed some bugs, adjusted and optimized the package

4. Common Arch

  • x86:i386,i486,i586,i686
  • x86_64:x64,x84_64,amd64
  • Platform has nothing to do: noarch

Nine, RPM package management

1. What is RPM and its role.

  • rpm is the abbreviation of Redhat Package Manager, used to manage software packages. Red Hat Package Manager. -
  • rpm has a powerful database /var/lib/rpm. /var/lib/rpm/Sigmd5 This file (signature) MD5 stores signature fingerprint information;
  • The management of rpm includes software installation, uninstallation, upgrade, query, verification, rebuilding the database, verifying the legality of the source of the software package, and so on. Installation, upgrade, query, uninstall, and verification can be installed through the yum back-end tool for testing.

2. RPM package installation

  • Syntax: rpm -ivh /PATH/package_file …etc, can install multiple
  • Common options
-i: installation
-v: Show details
-h: Show installation progress bar
–test: Test the installation, but do not actually perform the installation process
–nodeps: Ignore dependencies
–replacepkgs: Reinstall, replace the original installation
–oldpackage: Downgrade
–force: Forced installation, can be reinstalled or downgraded
–Needest: Do not check package integrity
–nosignature: Do not check the legality of the source of the package
–noscripts: Do not execute package script fragments
%pre: pre-installation script--nopre
%post: post-installation script--nopost
%preun: pre-uninstall script--nopreun
%postun: post uninstall script--nopostun
  • //To install the package, you need to specify the absolute path of the package

    [root@localhost ~]# rpm -ivh /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm
    [root@localhost ~]# rpm -ivh /mnt/Packages/vsftpd-3.0.2-22.el7.x86_64.rpm

  • //It is not necessary to specify an absolute path in the directory where the software package is located

    [root@localhost ~]# cd /mnt/Packages/
    [root@localhost Packages]# rpm -ivh zsh-5.0.2-28.el7.x86_64.rpm

  • //Test whether a package can be installed on the system

    [root@localhost ~]# rpm -ivh --test /mnt/Packages/vsftpd-3.0.2-22.el7.x86_64.rpm

  • //If the package exists, it is mandatory to install again

    [root@localhost ~]# rpm -ivh --force /mnt/Packages/tree-1.5.3-3.el6.x86_64.rpm

  • //Installing the samba service needs to rely on other components, use --nodeps to force the installation again

    [root@localhost ~]# rpm -ivh --nodeps /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm

3 RPM package query

rpm -q PACKAGE_NAME //Query whether the specified package has been installed
rpm -qa //Query all installed packages
rpm -qi PACKAGE_NAME //Query the description information of the specified package
rpm -ql PACKAGE_NAME //Query the file list generated after the specified software package is installed
rpm -qf /path/to/somefile //Query which rpm package installation generated the specified file
rpm -qc PACKAGE_NAME //Query the configuration file installed by the specified package
rpm -qd PACKAGE_NAME //Query the help file of the specified package installation
rpm -q --scripts PACKAGE_NAME //Query the script contained in the specified package
rpm -q --whatprovides CAPABILITY //Query which package provides the specified CAPABILITY
Such as: rpm -q --whatprovides /bin/cat
rpm -q --whatrequires CAPABILITY //Query which package depends on the specified CAPABILITY
rpm -q --changelog COMMAND //Query the production log of COMMAND
rpm -q --scripts PACKAGE_NAME //Query all script files contained in the specified software package
rpm -qR PACKAGE_NAME //Query the CAPABILITY that the specified software package depends on
rpm -q --provides PACKAGE_NAME //List the CAPABILITY provided by the specified package
rpm -qpi /PATH/TO/PACKAGE_FILE //Query the description information of the specified uninstalled package
rpm -qpl /PATH/TO/PACKAGE_FILE //Query which files will be generated by uninstalled packages
  • //Query whether the rpm package of vsftpd is installed

    [root@localhost ~]# rpm -q vsftpd

  • //Fuzzy search for rpm packages installed in the system

    [root@localhost ~]# rpm -qa |grep ftp

  • //Query information about the vsftpd software package

    [root@localhost ~]# rpm -qi vsftpd

  • //Query the files installed by the rpm package

    [root@localhost ~]# rpm -ql vsftpd

  • //Query configuration files related to rpm package

    [root@localhost ~]# rpm -qc vsftpd

  • //Query which rpm package the configuration file or command comes from

    [root@localhost ~]# rpm -qf /etc/vsftpd/vsftpd.conf
    [root@localhost ~]# rpm -qf /usr/sbin/vsftpd

  • //查询未安装的软件包会产生哪些文件

    [root@localhost ~]# rpm -qlp /mnt/Packages/samba-3.6.23-41.el6.x86_64.rpm

  • //查询未安装的软件包会产生哪些文件

    [root@localhost ~]# rpm -qip /mnt/Packages/samba-3.6.23-41.el6.x86_64.rpm

4 RPM包升级

  • 语法:

    rpm -Uvh /PATH/TO/NEW_PACKAGE_FILE //如果装有老版本的,则升级;否则,则安装
    rpm -Fvh /PATH/TO/NEW_PACKAGE_FILE //如果装有老版本的,则升级;否则,退出
    –oldpackage:降级
    [root@localhost ~]# rpm -Uvh /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm

    • 升级注意事项:

    不要对内核做升级操作
    Linux支持多内核版本并存,因此,可直接安装新版本内核(仅仅是安装最新版本的包或者内核,切记不可对内核进行升级,一旦出现故障可能导致系统不可用)
    如果原程序包的配置文件安装后曾被修改,升级时,新版本提供的同一个配置文件并不会直接覆盖老版本的配置文件,而把新版本的文件重命名(FILENAME.rpmnew)后保留

5 RPM包卸载

  • //语法:rpm -e PACKAGE_NAME
  • //先查询, 然后卸载

[root@localhost ~]# rpm -qa |grep vsftpd
[root@localhost ~]# rpm -e vsftpd
注意:如果其他包依赖于要卸载的包,这个被依赖的包是无法卸载的,除非强制卸载,强制卸载后依赖于这个包的其他程序将无法正常工作

十,关于rpm的练习

  • 如何查询 util-linux 软件包安装了哪些文件?

    [root@Eryuege ~]# rpm -ql util-linux
    /etc/adjtime
    /etc/mtab
    /etc/pam.d/login
    /etc/pam.d/remote
    /etc/pam.d/runuser
    /etc/pam.d/runuser-l
    /etc/pam.d/su
    /etc/pam.d/su-l
    /usr/bin/cal
    /usr/bin/chmem
    /usr/bin/chrt
    /usr/bin/col
    /usr/bin/colcrt
    /usr/bin/colrm

  • 如何查询 mkdir 命令是由哪个 RPM 软件包安装的?

    [root@Eryuege ~]# which mkdir
    /usr/bin/mkdir
    [root@Eryuege ~]# rpm -qf /usr/bin/mkdir
    coreutils-8.30-6.el8_1.1.x86_64

  • 升级软件包时,-F、-U选项有何区别?

    -F:是安装升级,如果有老版本的就升级安装,如果没有老版本就直接安装现有的版本
    -U:是升级,如果没有老版本的则安装失败,有老版本的则进行软件升级。

  • 如何检查vsftpd软件包是否安装?

    [root@Eryuege ~]# rpm -qa|grep vsftpd
    vsftpd-3.0.3-31.el8.x86_64

  • 如何检查vsftpd软件包所有的文件存放目录?

    [root@Eryuege ~]# rpm -qc vsftpd
    /etc/logrotate.d/vsftpd
    /etc/pam.d/vsftpd
    /etc/vsftpd/ftpusers
    /etc/vsftpd/user_list
    /etc/vsftpd/vsftpd.conf
    [root@Eryuege ~]#

  • 如何检查vsftpd软件包的配置文件?

  • 如何使用rpm安装vsftpd服务?

    [root@Eryuege ~]# rpm -ivh /mnt/AppStream/Packages/vsftpd-3.0.3-31.el8.x86_64.rpm
    警告:/mnt/AppStream/Packages/vsftpd-3.0.3-31.el8.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 8483c65d: NOKEY
    Verifying… ################################# [100%]
    准备中… ################################# [100%]
    软件包 vsftpd-3.0.3-31.el8.x86_64 已经安装
    [root@Eryuege ~]#

  • 如何使用rpm强制安装依赖包?

    [root@Eryuege ~]# rpm -ivh --force vsftpd-3.0.2-27.el7.x86_64.rpm
    警告:vsftpd-3.0.2-27.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
    错误:依赖检测失败:
    libcrypto.so.10()(64bit) 被 vsftpd-3.0.2-27.el7.x86_64 需要
    libcrypto.so.10(OPENSSL_1.0.1_EC)(64bit) 被 vsftpd-3.0.2-27.el7.x86_64 需要
    libcrypto.so.10(libcrypto.so.10)(64bit) 被 vsftpd-3.0.2-27.el7.x86_64 需要
    libnsl.so.1()(64bit) 被 vsftpd-3.0.2-27.el7.x86_64 需要
    libssl.so.10()(64bit) 被 vsftpd-3.0.2-27.el7.x86_64 需要
    libssl.so.10(libssl.so.10)(64bit) 被 vsftpd-3.0.2-27.el7.x86_64 需要
    libwrap.so.0()(64bit) 被 vsftpd-3.0.2-27.el7.x86_64 需要
    [root@Eryuege ~]# rpm -ivh --force /mnt/AppStream/Packages/vsftpd-3.0.3-31.el8.x86_64.rpm
    Warning: /mnt/AppStream/Packages/vsftpd-3.0.3-31.el8.x86_64.rpm: header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
    Verifying... ############ ##################### [100%] In
    preparation... ###################### ########### [100%]
    Upgrading/installing...
    1:vsftpd-3.0.3-31.el8 ################## ############## [100%]

  • How to uninstall vsftpd package using rpm?

    [root@Eryuege ~]# rpm -e vsftpd

Guess you like

Origin blog.csdn.net/LBJ19224/article/details/109224419