[Linux] software package management super detailed notes

Posted by direwolf on Thu, 10 Feb 2022 13:04:36 +0100

Introduction to software package management

Software package classification

  • Source package

    The source package needs to be compiled into binary package before installation, so the installation is slow.

    There is also a special package called script installation package in the source package. This package does not need to be installed manually, but there are not many such packages.

  • Binary package (RPM package, system default package)

    The binary package is generated after compiling the source package. It is installed quickly, but the source code cannot be seen.

Comparison of two software packages

Source package

  • advantage

    • Open source, you can modify the source code.
    • The source package is compiled before installation, which is more suitable for your own system, more stable and more efficient.
    • You can freely choose the required functions.
    • It is easy to uninstall and will not leave garbage files.
  • shortcoming

    • There are many installation steps. If a large software collection is installed, spelling errors are easy to occur.
    • Long installation time.
    • Because it is a compilation and installation, if an error is reported in the installation process, it is difficult for novices to solve it.

RPM package

  • advantage

    • The package management system is simple. You can install, upgrade, query and uninstall packages through only a few commands.
    • The installation speed is fast.
  • shortcoming

    • Unable to see the source code.
    • The function selection is not as flexible as the source package.
    • Dependent.

rpm package management - rpm command management

RPM package naming rules


httpd package name

2.2.15 software package version

15 software release times

el6.centos suitable Linux platform

i686 suitable hardware platform

RPM package extension

RPM package dependency

  • Tree dependency: a → b → c

    Generally speaking, it is to install software package a, first install software package b, and then install software package c.

  • Circular dependence: a → b → c → a

    The way to solve the ring dependency is to install a, b and c at the same time.

  • Module dependency: Module dependent query website

Package full name and package name

  • Full package name: when the operating package is a software package that is not installed, use the full package name (such as installation and update), and pay attention to the path.
  • Package name: httpd in the above naming rules. When operating the installed software package, use the package name to search the database in / var/lib/rpm /.

RPM installation command

rpm -ivh Package full name
	-i(install)		install
	-v(verbose)		Show details
	-h(hash)		Show progress
	--nodeps		Do not detect dependencies

Now install an Apache software package to demonstrate it
First create a mount point, mount it, and then enter the CD Directory:

[root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# mount /dev/sr0 /mnt/cdrom
mount: /dev/sr0 Write protected, will mount as read-only
[root@localhost ~]# cd /mnt/cdrom
[root@localhost cdrom]# ls
CentOS_BuildTag  images    repodata
EFI              isolinux  RPM-GPG-KEY-CentOS-7
EULA             LiveOS    RPM-GPG-KEY-CentOS-Testing-7
GPL              Packages  TRANS.TBL

Then enter the Packages Directory:

[root@localhost ~]# mkdir /mnt/cdrom/Packages

Since the operation is an uninstalled package, we use the full name of the package. Also note that if you do not enter the Packages directory, you need to specify the path during installation.

We first enter the package name httpd - and then press Tab to list all the installation packages with * * httpd - * * in the directory.

[root@localhost Packages]# rpm -ivh httpd-

These four packages are required for Apache. Generally, install the main package first and then the additional package.

Then let's load the main package first.

[root@localhost Packages]# rpm -ivh httpd-2.4.6-95.el7.centos.x86_64.rpm

At this time, a dependency error will be reported and the missing packages will be prompted.

Then let's install the missing packages first.

Write down the suggestive information first, and then press Tab to complete it automatically.

[root@localhost Packages]# rpm -ivh httpd-tools-2.4.6-95.el7.centos.x86_64.rpm

Then a dependency error is reported.

And it depends on the module here. I don't know what package to install.

Then we need what we mentioned above Module dependent query website Make a query.

My is CentOS 7 9. Go back to the terminal and install the corresponding package.

[root@localhost Packages]# rpm -ivh apr-1.4.8-7.el7.x86_64.rpm

Similarly, the second module dependency is solved in the same way.

After that, install httpd-tools-2.4.6-95 el7. centos. x86_ 64.rpm will not report an error.

[root@localhost Packages]# rpm -ivh httpd-tools-2.4.6-95.el7.centos.x86_64.rpm

Well, the dependent packages have been installed, and then we can successfully install the main package.

[root@localhost Packages]# rpm -ivh httpd-2.4.6-95.el7.centos.x86_64.rpm

Unfortunately, after this operation, we only installed the main package, and three additional packages have not been installed.

After the same operation, we installed three additional packages.

RPM package upgrade

rpm -Uvh Package full name

Note: U is uppercase.


rpm -e Package name
	-e	uninstall
	--nodeps	Do not check dependencies

Note: it does not have to be executed under the Packages directory, and only the package name is required, and the full package name is not required.

For example, I just uninstalled Apache:

[root@localhost cdrom]# rpm -e httpd

However, a dependency error is reported, as shown in the following figure:

At this time, we can uninstall the two dependent packages first, and then uninstall httpd later.

Query whether to install

rpm -q Package name
rpm -qa (Query all installed rpm (package)

Query package details

rpm -qi Package name
	-i	Query software information
	-p	Query package information not installed

Query the installation location of files in the package

rpm -ql Package name
	-l	List( list)
	-p	Query package information not installed

Query which RPM package the system files belong to

rpm -qf	System file name
	-f	Query which software package the system file belongs to

Query package dependencies

rpm -qR	Package name
rpm -qRp Full package name (query the dependencies of packages not installed)

RPM package verification

rpm -V Package name

The meaning of 8 information in the verification content:

S file size changed

Is the type of M file or the permission (rwx) of the file changed

5. Whether the MD5 checksum of the file is changed (it can be regarded as whether the content of the file is changed)

Whether the slave code is changed in the of D equipment

Whether the L file path has changed

Is the owner of the U file changed

Is the group of G file changed

Whether the modification time of T file has changed

File extraction in RPM package

rpm2cpio route+Package full name | cpio -idv .Absolute path

#Command to convert rpm package to cpio format

#Is a standard tool for creating software archives and extracting files from archives

RPM package management - yum online management

IP address configuration

First use the command ifconfig to check the gateway, my is ens33, and then execute the following command. Note that the last one is changed to your own gateway:

vi /etc/sysconfig/network-scripts/ifcfg-ens33

Then change the OMBOOT = "no" in the file to OMBOOT = "yes", save and exit.

Restart the network service with the following command:

service network restart

Now you can ping Baidu.

If you can't ping, you can refer to the following article:

Configure static ip for centos7 under VMware and solve the problem of unable to ping Baidu

Network yum source

The network yum source itself has been configured. We don't need to configure it. Let's take a look at the meaning of its configuration file.

Open the configuration file first:

vi /etc/yum.repos.d/CentOS-Base.repo

Let's explain what the things in the red box mean:

[base] container description, to be placed in []

name container description, which can be written freely

mirrorlist is a mirror site, which can be commented out

Baseurl the address of the yum source server. The default is the official Yum source server of CentOS, which can be changed to other Yum source addresses

enable is not written or written as

yum command


yum list 		#Query the list of all available packages
yum search keyword	#Search all keyword related packages on the server


yum -y install Package name


yum -y update Package name


yum -y remove Package name

yum software group management commands

yum grouplist  #List all available software groups
yum groupinstall Software name    #Install the specified software group, indicating that it can be queried by the grouplist
yum groupremove Software group name	#Uninstall the specified software group

CD source setup

First mount the disc:

mount /dev/cdrom /mnt/cdrom

Enter Directory:

cd /etc/yum.repos.d/

Then make the network yum source file invalid. Only the network yum source file invalid CD-ROM yum source file will work.

Note that only the CD-ROM yum source is circled in the red box in the figure below, that is, the other seven are network yum source files.

At this time, we can disable the network yum source by changing its name.

mv CentOS-Base.repo CentOS-Base.repo.bak
mv CentOS-Vault.repo CentOS-Vault.repo.bak
mv CentOS-fasttrack.repo CentOS-fasttrack.repo.bak
mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.bak
mv CentOS-CR.repo CentOS-CR.repo.bak
mv CentOS-Sources.repo CentOS-Sources.repo.bak
mv CentOS-x86_64-kernel.repo CentOS-x86_64-kernel.repo.bak

Next, modify the CD yum source file:

vim CentOS-Media.repo

In this way, the CD-ROM yum source is built. The advantage of using the CD-ROM yum source is that it can be downloaded offline and faster.

However, the version will not be updated automatically, that is, the downloaded version may not be the latest version.

Source package management

Difference between source package and RPM package (installation location)

RPM package installation location

Install in default location

Source package installation location

Install in the specified location, usually * * / usr/local / software name/**

Impact of different installation positions

  • The services installed by the RPM package can be managed using the system service management command. For example, there are two ways to start Apache installed with RPM package:
#Start the service directly through the absolute path
/etc/rc.d/init.d/httd start
#Use the systemctl service management command to start the service. Using systemctl will automatically go to the absolute path to find httpd
systemctl start httpd
  • The services installed in the source package cannot be managed by the service management command, because they are not installed in the default path and can only be managed through the absolute path.

Source package installation process

Installation preparation

  • Install C language compiler
rpm -q gcc
  • Download source package

Installation precautions

  • Source code saving location: / usr/local/src/
  • Software installation location: / usr/local/

Source package installation process

  • Download source package

    I'm from Official website Download, and then transfer the installation package to Linux through the software WinSCP.

    Then there is the installation package in the home directory of Linux.

  • Extract the downloaded source package.

tar -zxvf httpd-2.4.52.tar.gz
  • Enter the decompression directory.
cd httpd-2.4.52/

There is a file called ISTALL in the directory. We open it and there are installation steps in it. We can just follow it.

  • . / configure software configuration and inspection
  1. Define the required function options.
  2. Check whether the system environment meets the installation requirements.
  3. Write the defined function options and the information of the detection system environment into the Makefile file for subsequent editing.
./configure --prefix=/usr/local/apache2
  • make compilation

    • If there is an error in the front, use the command make clean to empty the temporary file generated by compilation
  • make install compile install

  • After installation, start

/usr/local/apache2/bin/apachectl start

At this time, an error will be reported, but it will not affect the use.

Then enter the ip address of our virtual machine in the browser to display It works!

Uninstallation of source package

You do not need to uninstall the command. You can directly delete the installation directory without leaving any garbage files.

rm -rf /usr/local/apache2/

Source package installation and RPM package selection

To provide more efficient access to the source code, select the package according to the purpose of the compiled package.

If you do not provide external access, you can install with RPM package.

Script installation package

What is a script installation package

  • The script installation package is not an independent software package type. The common installation is the source package.
  • The installation process is manually written as an automatic installation script. As long as the script is executed and simple parameters are defined, the installation can be completed.
  • It is very similar to the installation method of software under Windows.

The following is an example of the installed software package Webmin:

  • Software download, website.
  • Unzip and enter the directory.
tar -zxvf webmin-1.984.tar.gz
cd webmin-1.984
  • Execute the installation script.

    Setup under directory SH is the installation script


Enter all by default. The default port number here is 10000. After installation, enter the ip address and end slogan in the browser to access.

reference material:



Topics: Linux Apache CentOS