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

Linux package Management-rpm

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

1. Package management

Function: package the component files of the compiled application into one or more package files, so as to realize the management operations such as package installation, upgrade, uninstallation and query more conveniently and quickly.

1 component manifest of packages (each package is implemented separately)

List of documents

Installing or uninstalling is a running script

2 Database part (public)

Package name and version

Dependency relationship

Function description

Install and generate the file location path and check code information

Where did we get the package?

1) CD or official file server or mirror site issued by the system:

The most commonly used ones, such as

Http://mirrors.aliyun.com

Http://mirrors.souhu.com

Http://mirrors.163.com

2) download the official site of the program

3) rpm packages of third-party organizations

(a) EPEL: the forum organization of the Red Hat site to provide efficient yum originals

(B) search engine search

Pkgs.org

Rpmfind.net

Rpm.pbone.net

4) do it yourself

Ps: pay attention to its legality and source when downloading

Rpm: readhat package manager; rpm is package manager

2.rpm package naming format

Tree-1.5.3-3.el6.x86_64.rpm

Name-version-release.arch.rpm

Versiom: refers to the source code version

Release number of the release.arch:rpm package

Archetecture: architecture number: i386 dint x64 (amd64)..

E16 applicable platform 6

3.rpm characteristics

1pr rpm subcontracting mechanism

Split the function of a package into n different function subpackages

Main package: name-version-release.arch.rpm

Subcontractor: name-function-version-release.arch.rpm

Function: function for example: devel development function

Untils tool program

Libs library files, etc.

2, dependency relationship

Dependencies: because linux programs are short and exquisite, programs rely on functions provided by other programs before they can run, resulting in complex dependencies between packages and packages

3. Solve the dependence

The emergence of front-end tools automatically solves the dependencies between packages.

Yum: the front-end tool for the rpm package manager

The front-end tool for apt-get (apt-cache) deb package Manager is for debian

Zypper: suse's rpm Manager front-end tool

Front-end tools for rpm package manager on dnf:fedora-22+ systems

4.rpm Command Management package:

Installation, upgrade, uninstall, query, validation, database maintenance, help

Usage

Rpm [OPTION] [PACKAGE_FILE]

Installation

Rpm {- I |-- install} [install-options] PACKAGE_FILE...

[GENERAL OPTIONS]: general option-v detail output-vv more detail output

[install-options]: installation option-h shows output progress bar yum-ivh--test test installation with hash tag (not actual installation, only testing, checking for dependencies and conflicts);-- nodeps ignores dependency installation;-- replacepkgs reinstallation Ps:rpm can come with scripts-noscripts four categories: prelnstall: scripts run before the installation process% pre-- nopre postinstall: scripts run after the installation process is completed,% pot-- post preuninstall: scripts run before the uninstall process actually starts execution% preun-- nopreun postuninstall: run scripts after the uninstall process is complete% postun-- nopostun--nosignature: do not check package signature information, do not check source validity -- nodigest: do not check package integrity information

For example: install the tree package

[root@localhost Packages] # rpm-ivh tree-1.6.0-10.el7.x86_64.rpm warning: tree-1.6.0-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... # # [100%] package tree-1.6.0-10.el7.x86_64 is already installed

Upgrade

Rpm {- U |-- upgrade} [install-options] PACKAGE_FILE... Rpm {- F |-- freshen} [install-options] PACKAGE_FILE.-U upgrade or install-F upgrade rpm-Uvh rpm-Fvh--oldpackage: downgrade;-- force: mandatory upgrade; upgrade may affect dependencies # ps:1) do not upgrade the kernel; linux supports multiple kernels, just install a new version of the kernel # 2) if the original package configuration file is modified after installation, the upgrade is that the same configuration file provided by the new version of the program will not overwrite the original version of the configuration file and will be renamed and retained

For example: verify that if the original package configuration file is modified after installation, the upgrade is that the same configuration file provided by the new version of the program will not overwrite the original version of the configuration file, and the new file will be renamed and retained

[root@localhost Packages] # rpm-ivh vsftpd-3.0.2-10.el7.x86_64.rpm warning: vsftpd-3.0.2-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... # # [100%] Updating / installing... 1:vsftpd-3.0.2-10.el7 # # [root@localhost Packages] # # install vsftp [root @ localhost vsftpd] # cat vsftpd.conf | wc-L127 [root@localhost vsftpd] # vim vsftpd.conf [root@localhost vsftpd] # cat vsftpd.conf | wc-l27# modify its configuration file (delete file) ) [root@localhost Packages] # rpm-Uvh vsftpd-3.0.2-10.el7.x86_64.rpm-- forcewarning: vsftpd-3.0.2-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature Key ID f4a80eb5: NOKEYPreparing... # # [100%] Updating / installing... 1:vsftpd-3.0.2-10.el7 # # [100%] # upgrade installation vsftpd [root@localhost vsftpd] # cat vsftpd.conf | the number of lines of wc-l27# configuration file is the same as the number of lines modified before installation

Unloading

Rpm {- e |-- erase} [--allmatches] [--nodeps] [--noscripts] [--notriggers] [--test] PACKAGE_NAME...-- allmatches: delete all package versions that match the specified name-- nodeps: ignore dependencies-- test test uninstall, do not actually perform the uninstall.

For example: uninstall vsftpd

[root@localhost Packages] # rpm-e-- nodeps vsftpd warning: / etc/vsftpd/vsftpd.conf saved as / etc/vsftpd/vsftpd.conf.rpmsave# Uninstall the vsftpd package [root@localhost ~] # ll / etc/vsftpd/total 4Murray. 1 root root 1127 Aug 23 21:10 vsftpd.conf.rpmsave [root@localhost ~] # cat / etc/vsftpd/vsftpd.conf.rpmsave | ec-lbash: ec: command not found... [root@localhost ~] # cat / etc/vsftpd/vsftpd.conf.rpmsave | wc-l27# uninstall and back up the configuration file as a new file

Query

Rpm {- Q |-- query} [select-options] [query-options] 1) select-options:PACKAGE_NAME directly gives the package name to check whether it has been installed-aQuery Liaall queries all installed packages rpm-qa [root@localhost ~] # rpm-qa | grep http-f -- file query file generation installation package [root@localhost ~] # rpm-qf / etc/fstab setup-2.8.71-6.el7.noarch-p-- pachage searches for uninstalled packages-- whatprovides CAPABILITY: query specified CAPABILITY installation packages-- whatrequires CAPABILITY: query specified CAPABILITY installation packages 2) query-options:--changelog view rpm improvement log-l -- files generated by list installation rpm-ql to see which files are generated after installing this package-- I-- info query package related information (version Size, package group) rpm-qi program name-c,-- configfiles query the configuration file provided by the specified package-d,-- docfiles query the documentation provided by the specified package-- provides lists the CAPABTLITY provided by the program-- scripts view the script after the specified program is installed

Examples of enquiries:

# multiple methods to query whether a package has been installed [root@localhost vsftpd] # rpm-q vsftpdpackage vsftpd is not installed [root@localhost vsftpd] # rpm-qa vsftpd [root@localhost vsftpd] # rpm-qa | grep vsftpd [root@localhost vsftpd] # rpm-Q vsftpdvsftpd-3.0.2-10.el7.x86_64 [root@localhost vsftpd] # rpm-qa | grep vsftpdvsftpd-3.0.2-10.el7.x86_64

.

# query which installation package generated a file [root@localhost vsftpd] # rpm-qf / etc/vsftpd/vsftpd-3.0.2-10.el7.x86_64

.

# View the file generated after a package is installed [root@localhost vsftpd] # rpm-ql vsftpd/etc/ logrotate.d/vsftpd/etc/pam.d/vsftpd/etc/vsftpd/etc/vsftpd/ftpusers/etc/vsftpd/user_list/etc/vsftpd/vsftpd.conf/etc/vsftpd/vsftpd_conf_migrate.sh/usr/lib/systemd/system-generators/vsftpd-generator/usr/lib/systemd/system/vsftpd.service/usr/lib/systemd/system/vsftpd.target/usr / lib/systemd/system/vsftpd@.service/usr/sbin/vsftpd/usr/share/doc/vsftpd-3.0.2/usr/share/doc/vsftpd-3.0.2/AUDIT/usr/share/doc/vsftpd-3.0.2/BENCHMARKS/usr/share/doc/vsftpd-3.0.2/BUGS/usr/share/doc/vsftpd-3.0.2/COPYING/usr/share/doc/vsftpd-3.0.2/Changelog/usr/share/doc/vsftpd- 3.0.2/EXAMPLE/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README.configuration/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.conf/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd. Xinetd/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_ CONFIG/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README.configuration/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/hosts.allow/usr/share/doc/vsftpd-3.0.2/EXAMPLE/README/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS/usr/share/ Doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS/README/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README.configuration/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/logins.txt/usr/share/doc/vsftpd-3.0. 2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2/README/usr/share/doc/vsftpd-3.0.2/FAQ/usr/share/doc/vsftpd-3.0.2/INSTALL/usr/share/doc/ Vsftpd-3.0.2/LICENSE/usr/share/doc/vsftpd-3.0.2/README/usr/share/doc/vsftpd-3.0.2/README.security/usr/share/doc/vsftpd-3.0.2/REWARD/usr/share/doc/vsftpd-3.0.2/SECURITY/usr/share/doc/vsftpd-3.0.2/SECURITY/DESIGN/usr/share/doc/vsftpd-3.0.2/SECURITY/IMPLEMENTATION/usr/share/doc/vsftpd- 3.0.2/SECURITY/OVERVIEW/usr/share/doc/vsftpd-3.0.2/SECURITY/TRUST/usr/share/doc/vsftpd-3.0.2/SIZE/usr/share/doc/vsftpd-3.0.2/SPEED/usr/share/doc/vsftpd-3.0.2/TODO/usr/share/doc/vsftpd-3.0.2/TUNING/usr/share/doc/vsftpd-3.0.2/vsftpd.xinetd/usr/share/man/man5/vsftpd. Conf.5.gz/usr/share/man/man8/vsftpd.8.gz/var/ftp/var/ftp/pub

.

# query the configuration file contained in the specified package [root@localhost Packages] # rpm-qc vsftpd/etc/logrotate.d/vsftpd/etc/pam.d/vsftpd/etc/vsftpd/ftpusers/etc/vsftpd/user_list/etc/vsftpd/vsftpd.conf

.

# query the documents provided by the specified package [root@localhost Packages] # rpm-qd vsftpd/usr/share/doc/vsftpd-3.0.2/AUDIT/usr/share/doc/vsftpd-3.0.2/BENCHMARKS/usr/share/doc/vsftpd-3.0.2/BUGS/usr/share/doc/vsftpd-3.0.2/COPYING/usr/share/doc/vsftpd-3.0.2/Changelog/usr/share/doc/vsftpd-3.0.2/EXAMPLE / INTERNET_SITE/README/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README.configuration/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.conf/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET _ SITE_NOINETD/README.configuration/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README.configuration/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/hosts.allow/usr/share/doc/vsftpd-3 . 0.2/EXAMPLE/README/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS/README/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README.configuration/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/logins.txt/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS / vsftpd.conf/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2/README/usr/share/doc/vsftpd-3.0.2/FAQ/usr/share/doc/vsftpd-3.0.2/INSTALL/usr/share/doc/vsftpd-3.0.2/LICENSE/usr/share/doc/vsftpd-3.0.2/README/usr/share / doc/vsftpd-3.0.2/README.security/usr/share/doc/vsftpd-3.0.2/REWARD/usr/share/doc/vsftpd-3.0.2/SECURITY/DESIGN/usr/share/doc/vsftpd-3.0.2/SECURITY/IMPLEMENTATION/usr/share/doc/vsftpd-3.0.2/SECURITY/OVERVIEW/usr/share/doc/vsftpd-3.0.2/SECURITY/TRUST/usr/share/doc/vsftpd-3.0.2/SIZE/usr / share/doc/vsftpd-3.0.2/SPEED/usr/share/doc/vsftpd-3.0.2/TODO/usr/share/doc/vsftpd-3.0.2/TUNING/usr/share/doc/vsftpd-3.0.2/vsftpd.xinetd/usr/share/man/man5/vsftpd.conf.5.gz/usr/share/man/man8/vsftpd.8.gz

Effectiveness

Rpm {- V |-- verify} [select-options] [verify-options]-- nodeps Don't verify dependencies of packages. -- nodigest Don't verify package or header digests when read ing. -- nofiles Don't verify any attributes of package files. -noscripts Don't execute the% verifyscript scriptlet (if any). 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 does not add any parameters and defaults to check all parameters rpm-V-- nodeps

Validation of the package:

Legal source: provided by the producer and dependent on the producer's digital signature, which is carried out by the author using the characteristic code of his own private key encryption package

Legal content: the package has not been modified twice and depends on the program signature provided by the producer

Correction method: the installer uses the same signature extraction algorithm to extract the signature of the package and compares it with the one provided by the original author

For example:

Rpm-import / misc/cd/RPM-GPG-KEY-CentOS-6 rpm-K vsftpd-3.0.2-10.el7.x86_64.rpm vsftpd-3.0.2-10.el7.x86_64.rpm: rsa sha1 (md5) pgp md5 OK

Database maintenance

Rpm Manager Database: / var/lib/rpmrpmdb {--initdb |-- rebuilddb} [- v] [--dbpath DIRECTORY]-- initdb: create a new database only if the database does not exist;-- rebuilddb: this library will be rebuilt directly regardless of whether the current database exists or not

For example:

# Delete the library [root@localhost rpm] # lsBasenames _ db.001 _ db.003 Group Name Packages Requirename Sigmd5Conflictname _ db.002 Dirnames Installtid Obsoletename Providename Sha1header Triggername [root@localhost rpm] # rm-fr * [root@localhost rpm] # ls# use query to rebuild the library [root@localhost rpm] # rpm-qa vsftpd [root@localhost rpm] # lsBasenames _ db.001 _ _ db.003 Group Name Packages Requirename Sigmd5Conflictname _ _ db.002 Dirnames Installtid Obsoletename Providename Sha1header Triggername [root@localhost rpm] # # use the command rpmdb-- initdb to generate the library [root@localhost rpm] # rm-fr * [root@localhost rpm] # lltotal 0 [root@localhost rpm] # rpmdb-- initdb [root@localhost rpm] # lltotal 388 RW Murray. 1 root root 8192 Aug 23 22:19 Basenames-rw-r--r--. 1 root root 8192 Aug 23 22:19 Conflictname-rw-r--r--. 1 root root 270336 Aug 23 22:19 _ _ db.001-rw-r--r--. 1 root root 81920 Aug 23 22:19 _ _ db.002-rw-r--r--. 1 root root 107048 Aug 23 22:19 _ _ db.003-rw-r--r--. 1 root root 8192 Aug 23 22:19 Dirnames-rw-r--r--. 1 root root 8192 Aug 23 22:19 Group-rw-r--r--. 1 root root 8192 Aug 23 22:19 Installtid-rw-r--r--. 1 root root 8192 Aug 23 22:19 Name-rw-r--r--. 1 root root 8192 Aug 23 22:19 Obsoletename-rw-r--r--. 1 root root 12288 Aug 23 22:19 Packages-rw-r--r--. 1 root root 8192 Aug 23 22:19 Providename-rw-r--r--. 1 root root 8192 Aug 23 22:19 Requirename-rw-r--r--. 1 root root 8192 Aug 23 22:19 Sha1header-rw-r--r--. 1 root root 8192 Aug 23 22:19 Sigmd5-rw-r--r--. 1 root root 8192 Aug 23 22:19 Triggername

Help

1. Man rpm

2. Man rpmdb

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