Linux from getting started to running-rpm, yum, DNF (package management three brothers)

Source: Internet
Author: User
Tags bz2 gpg

Linux from getting started to running-rpm, yum, DNF

(Package management three brothers)

Understanding Package Management

Package management refers to a method of installing and maintaining software in a system. Today, with packages installed from Linux distributions, you can meet the needs of many people with all the software they need. This is different from earlier Linux, where people need to download and edit the source code to install the software. Edit the source code without any problems, in fact, have access to the source code is a great miracle of Linux. In this article, we'll look at some command-line tools for package management (RPM, yum, DNF). While all major Linux distributions provide a powerful and sophisticated graphical management program to maintain the system, learning command-line programs is also important. Because they can accomplish a lot of tasks that make it difficult (or impossible) for the graphical management program to handle them.

Rpm

The rpm command is a management tool for RPM packages. RPM was originally a red Hat Linux distribution program designed to manage Linux packages and is popular because it follows GPL rules and is powerful and convenient. is gradually being adopted by other distributions. The advent of RPM suite management means that Linux is easy to install and upgrade, which indirectly increases the applicability of Linux.

RPM (option) (parameter)

Rpm-i Installation
-IV Display Process
-IVV Show Detailed procedures
-IVH display process and installation progress percentage
--test test only, not really installed
*--nodeps ignore dependencies when installing or uninstalling
--replacepkgs repeatedly installs installed packages, overwriting files
--replacefiles the part of the file that will install the package conflicts with other installed package files, you can continue the installation, the file does not overwrite
--oldpackage has installed a new version and now installs the old version
*--force is equivalent to--replacepkgs,--replacefiles, and--oldpackage.
--noscripts do not execute the script that comes with the package during installation

        *-UVH new version rpm   upgrade RPM package, if older version, remove the old version before installing the new version
                                           If there is no older version, install the specified RPM package directly
          -FVH new version rpm    Upgrade RPM Package, if older version, remove the old version and install the new version
                                          without an older version, the RPM package is not installed
                     When upgrading the kernel, you should install the new kernel using-IVH to ensure that the old kernel still exists.

-Q Package Name query information for installed packages
-qa List all RPM packages that have been installed
-qa "* keyword *" or rpm-qa |grep keyword

-QF file path query specifies which of the installed RPM packages the file is from
-QI Package Name shows the package details
-QP [ilcd ...] rpm path query information data from RPM package
-Q--provides Querying what capabilities a package provides
-qa--provides querying all the capabilities provided by the current system
-Q--whatprovides webserver query for a capability by which RPM package is provided
-Q--whatrequires webserver query which RPM package is dependent on a capability
-Q--changelog httpd querying the update log
-QL httpd list all files provided by the package
-QC httpd list The configuration files provided by the package
-QD httpd list The documentation files provided by the package

RPM {-v|--verify} [select-options] [verify-options]
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 mtimediffers
P capabilities differ

[Email protected] ~]# rpm--import/media/rpm-gpg-key-centos-7

[Email protected] ~]# rpm-k/media/packages/vsftpd-3.0.2-22.el7.x86_64.rpm
/media/packages/vsftpd-3.0.2-22.el7.x86_64.rpm:rsa SHA1 (MD5) PGP MD5 OK

[Email protected] ~]# Rpm-qa "gpg-pubkey*"
gpg-pubkey-f4a80eb5-53a7ff4b


RPM--import/media/rpm-gpg-key-centos-7 Import Public key
Rpm-k vsftpd-3.0.2-22.el7.x86_64.rpm
Rpm-qa "gpg-pubkey*"

[Email protected] ~]# RPM-IVH--nodeps/media/packages/tigervnc-1.8.0-5.el7.x86_64.rpm
In preparation ... ################################# [100%]
Upgrading/installing ...
1:tigervnc-1.8.0-5.el7 ################################# [100%]
[Email protected] ~]# RPM-IVH--force/media/packages/ftp-0.17-67.el7.x86_64.rpm
In preparation ... ################################# [100%]
Upgrading/installing ...
1:ftp-0.17-67.el7 ################################# [100%]
[Email protected] ~]# rpm-ivh/media/packages/ftp-0.17-67.el7.x86_64.rpm
In preparation ... ################################# [100%]
Package ftp-0.17-67.el7.x86_64 already installed


Rpm2cpio initscripts-9.03.58-1.el6.centos.x86_64.rpm |cpio-id



Experiment: Recover files After deleting a file using Rpm2cpio to unlock rpm
1. deleting files
[Email protected] (Nanyibo) ~]# rm-rf/etc/rc.d/init.d/functions
2. query file from which installed RPM package
[Email protected] (Nanyibo) ~]# rpm-qf/etc/rc.d/init.d/functions
Initscripts-9.03.58-1.el6.centos.x86_64
3. Mount the disc
[Email protected] (Nanyibo) ~]# mount/dev/cdrom/media/
Mount:block DEVICE/DEV/SR1 is write-protected, mounting read-only
4. Copy rpm to a temp directory
[Email protected] (Nanyibo) ~]# Cp/media/packages/initscripts-9.03.58-1.el6.centos.x86_64.rpm/app
5. Go to the Temp directory and unpack the RPM package
[Email protected] (Nanyibo) ~]# Cd/app
[Email protected] (Nanyibo) app]# Rpm2cpio initscripts-9.03.58-1.el6.centos.x86_64.rpm |cpio-id
6. Find the required files from the extracted directory and copy them to the relevant original directory.
[Email protected] (Nanyibo) app]# CP etc/rc.d/init.d/functions/etc/rc.d/init.d/

[Email protected] ~]# rm-rf/etc/rc.d/init.d/functions
[Email protected] ~]# rpm-qf/etc/rc.d/init.d/functions
Initscripts-9.49.41-1.el7.x86_64
[Email protected] ~]# mount/dev/cdrom/media/
Mount:/dev/sr0 write protection, will be mounted as read-only
Mount:/dev/sr0 already mounted or/media busy
/DEV/SR0 has been mounted on/run/media/root/centos 7 x86_64.
/DEV/SR0 has been mounted on the/media.
[Email protected] ~]# Cp/media/packages/initscripts-9.03.58-1.el6.centos.x86_64.rpm/app
CP: Unable to get "/media/packages/initscripts-9.03.58-1.el6.centos.x86_64.rpm" File Status (STAT): No file or directory
[Email protected] ~]# Cp/media/packages/initscripts-9.03.58-1.el6.centos.x86_64.rpm/app
CP: Unable to get "/media/packages/initscripts-9.03.58-1.el6.centos.x86_64.rpm" File Status (STAT): No file or directory
[Email protected] ~]# Cp/media/packages/initscripts-9.49.41-1.el7.x86_64.rpm/app
[Email protected] ~]# Cd/app
[Email protected] app]# Rpm2cpio initscripts-9.49.41-1.el7.x86_64.rpm |cpio-id
3039 Bucks.
[email protected] app]# CP ETC/RC
rc0.d/rc1.d/rc2.d/rc3.d/rc4.d/rc5.d/rc6.d/rc.d/
[email protected] app]# CP ETC/RC
rc0.d/rc1.d/rc2.d/rc3.d/rc4.d/rc5.d/rc6.d/rc.d/
[email protected] app]# CP etc/rc.d/init.d/functions/etc/rc.d/init.d/


Yum

The Yum command is the RPM-based package manager in Fedora and Redhat and SuSE, which enables system managers to interact and automate the finer and more granular management of RPM packages, automatically downloading RPM packets from specified servers and installing them, Dependency relationships can be automatically handled and all dependent software packages are installed at once, without the hassle of downloading and installing them over and over again.

Yum provides commands to find, install, and delete one, a group, or even all of the packages, and the commands are concise and well-remembered.

Difference from RPM only RPM packages that have been downloaded to the local machine can be installed. Yum can download and install RPM packages online, update the system, and automatically handle dependencies between packages and packages

Yum
/etc/yum.repos.d/*.repo Warehouse Path
[Repoid] The name of the warehouse, cannot be duplicated
Name= Warehouse Description, can not write, will use Repoid as name
Enabled=1|0 activates or disables the warehouse, which is enabled by default if the row is not written
Gpgcheck=1|0 whether the installation package is detection GPG signature, default detection, that is, 1
Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7 specifying the path to GPG KEY


Yum Install package Name
repolist [enabled] defaults to show only the activated warehouses
Disabled only the disabled warehouses are displayed
All Show All warehouses


[Base]
name=red Hat Enterprise Linux $releasever Repo
baseurl=http://172.18.0.1/centos/$releasever
Enabled=1
Gpgcheck=0
[Epel]
Name=mage Epel $releasever
baseurl=http://172.18.0.1/fedora-epel/$releasever/$basearch
Enabled=1
Gpgcheck=0


Use online Epel
[Epel]
Name=mage Epel
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/
Enabled=1
Gpgcheck=0


Yum-config-manager--add https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/

Yum Clean all empties the Yum cache
Yum Makecache rebuilds the cache (any command that uses Yum for the first time will be rebuilt automatically without caching)


Yum List
Base not installed package, from base
Epel packages not installed, from Epel
@base the package is installed and is installed from base
@anaconda the package is installed and is installed from the operating system installer Anaconda

All default indicates that all packages are listed
Updates lists the packages that are updatable
Installed list of installed packages
@repoid indicates that the package is installed from the specified warehouse
Installed indicates that the package is manually installed by the RPM command

Install package Name 1 [* Package name *] [package Name 2 ...]
-Y Auto Answer
Reinstall Package name to reinstall the specified package

Update package
Remove Uninstall package does not unload with dependent packages

Yum Info Package Name View detailed information for a specified package


Yum provides "*/rz" searches for a file from which RPM package, which can be a package that is not installed

Yum Search keyword Fuzzy searching package and description

Yum deplist PHP Lists all packages that the specified package depends on

Yum history lists all the Yum histories
Info # View details about a history
Redo # Redo a piece of history
Undo # Undoing a piece of history
If the history is install, Undo is the Remove
If this history is remove, then undo is the install

Install a local package
Yum [local]install/path/*.rpm

Yum Grouplist lists all the package group names
Yum GroupInfo ' package group name ' to see which package is included in the specified package group
Yum Groupinstall ' package group name '
Yum Groupupdate ' package group name '
Yum Groupremove ' package group name '

-Q Silence, try to use &>/dev/null

Yum Reinstall bind--downloadonly--downloaddir=/app download package only, do not install


Createrepo RPM Package directory path creation Repodata

Yum

***
Experiment: Install httpd2.4 (CENTOS7) using the source package
1. Download the source website, the classroom server
Lftp 172.18.0.1
User Thirty-three Pass:thirty-three
Get files/httpd-2.4.27.tar.bz2
Exit
Tar xvf httpd-2.4.27.tar.bz2
2. Installing Development Tools
3. Check the Readme INSTALL
4../configure--help
./configure--prefix=/app/apache24--sysconfdir=/etc/apache24
Dnf|yum install-y apr-devel apr-util-devel pcre-devel
5.make-j 4
6.make Install
7.export path= $PATH:/app/apache24/bin can write this line to/etc/profile.d/*.sh, and then source the file
8.apachectl Start Service
9.vim/app/apache24/htdocs/index.html
10.iptables-f
11. Browser Access


Lab 2: Installing httpd2.2 (CENTOS6) using the source package

Dnf

DNF is a new generation of RPM Package manager. He first appeared in the release of Fedora 18. Recently, it replaced Yum, officially becoming the Package manager for Fedora 22.

The DNF Package Manager overcomes some of the bottlenecks of the Yum Package Manager and improves content including user experience, memory footprint, dependency analysis, and run speed. DNF uses RPM, LIBSOLV and Hawkey libraries for package management operations. Although it is not pre-installed in CentOS and RHEL 7, you can use DNF while using YUM. You can get more information about DNF here: "DNF instead of YUM, the reason you don't know"

DNF's latest stable release version number is 1.0 and the release date is May 11, 2015. Most of this version of the DNF Package Manager (including all previous versions of him) is written in Python and is licensed under the GPL v2.

Linux from getting started to running-rpm, yum, DNF (package management three brothers)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.