[Linux] Installation and query of Linux operating system software packages

1. Rpm installation

1.1 System commands and applications

The relationship between applications and system commands

Character Command Program
File location Generally in the /bin and /sbin directories or as Shell internal commands Usually in the /usr/bin, /usr/sbin and /usr/local/bin, /usr/local/sbin directories
Main purpose Complete basic management of the system, such as IP configuration tools Complete other relatively independent auxiliary tasks, such as web browsers
Applicable Environment Generally only runs in the character operation interface Completes other relatively independent auxiliary tasks, such as web browser
running Format Generally includes command words, command options and command parameters There is usually no fixed execution format and is defined by the program developer himself
Directory structure of a typical application
File type Saving directory Description
Ordinary executable Program files /usr/bin Executable by all users
Server program, management program files /usr/bin Only administrator executable
Application configuration file /etc Applications installed through rpm or yum
Log files /var/log System log
Application reference documents /usr/share/doc Reference documents and other data about the application
Application Manual /usr/share/man man man page for executable files and configuration files

< /table>

Linux files
1. Everything in Linux is a file 2. The main file types in Linux include ordinary files, directory files, block device files, link files, and socket files. and pipe files, etc.
3. Linux files do not have extensions. Linux also determines the file type based on the Wenniu extension. We give it to Wenniu when we name it. The specific suffix is to facilitate user management (for example, files with the suffix “.sh” are generally considered to be shell script files, and files with the suffix “.tar.gz” are compressed files 4. In the Linux file system, files whose file names start with “A” are hidden files. In actual operation, to display the information of hidden files, you need to use specific command options.
Common types of software package packaging
File type Saving directory
RPM software package Extension It is “.rpm”, suitable for CentOS system
Source code software package Generally in the format of “.tar.gz.tar.bz2” etc. The compressed package contains the original code of the program and needs to be compiled and installed

2. RPM

2.1 rpm package management tool

RPM package managerRed-Hat Package Manager

1. Proposed by Red Hat and adopted by many Linux distributions

2. Establish a unified document database

3. Record in detail information about software package installation, uninstallation, upgrade and other changes

4. Automatically analyze software package dependencies

RPM package naming principles

General naming format: bash -4.1.2 -15.el7 .X86_64 .rpm

From left to right: software name – version number – number of releases – hardware platform – extension

2.2 Format of rpm command

The rpm command can realize the management functions of almost all RPM software packages

Execute the “man rpm” command to get detailed help information about the rpm command

rpm command function:

1. Query and verify relevant information of rpm software packages

2. Install, upgrade, and uninstall RPM software packages

2.3. Query rpm software packages

Query installed rpm software information

rpm -q [sub-option] [software name]

Common options

-qa, -qi, -ql, -qf, -qc, -qd

Query information in rpm package files

rpm -qp [sub-option] rpm package file name

Software package query mainly includes:Querying the installed software package information in the system;

For the “-qa ” query option, the command parameter (i.e. the software package name) is not required;

In general queries, the software name does not need to specify a version number.

Inquire
Query Function
-q Query whether the software is installed
-ql Query file list
-qc Query software Configuration file
-qi Query basic software information

Supplement: -qa queries all software

rpm -q command

[root@localhost ~]# rpm -q rpm #Check whether the rpm package has been installed
rpm-4.11.3-25.el7.x86_64
[root@localhost ~]# rpm -q yum #Check whether the yum package has been installed
yum-3.4.3-154.el7.centos.noarch
[root@localhost ~]# systemctl status nfs #View the status of nfs service
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
[root@localhost ~]# rpm -q nfs-utils #Check whether the nfs-utils package has been installed
nfs-utils-1.3.0-0.48.el7.x86_64
[root@localhost ~]# 

rpm -ql command

[root@localhost ~]# rpm -q nfs-utils #Display the file list of the installed specified software yum
nfs-utils-1.3.0-0.48.el7.x86_64
[root@localhost ~]# rpm -ql yum
/etc/logrotate.d/yum
/etc/yum
/etc/yum.conf
/etc/yum.repos.d
/etc/yum/fssnap.d
/etc/yum/pluginconf.d
/etc/yum/protected.d
/etc/yum/vars
/etc/yum/version-groups.conf
/usr/bin/yum

rpm -qc command

[root@localhost ~]# rpm -qc yum #List the configuration files of the installed specified software yum
/etc/logrotate.d/yum
/etc/yum.conf #yum configuration file, file name
/etc/yum/version-groups.conf

rpm -qi command

[root@localhost ~]# rpm -qc yum #Display detailed information of installed yum packages
/etc/logrotate.d/yum
/etc/yum.conf
/etc/yum/version-groups.conf
[root@localhost ~]# ^C
[root@localhost ~]# ^C
[root@localhost ~]# rpm -qi yum
Name: yum
Version: 3.4.3
Release: 154.el7.centos
Architecture: noarch
Install Date: Friday, October 27, 2023 20:23:57
Group: System Environment/Base
Size: 5803844
License: GPLv2+
Signature: RSA/SHA256, Friday, August 11, 2017 04:27:53, Key ID 24c6a8a7f4a80eb5
Source RPM: yum-3.4.3-154.el7.centos.src.rpm
Build Date: Sunday, August 6, 2017 03:13:08
Build Host: c1bm.rdu2.centos.org
Relocations: (not relocatable)
Packager: CentOS BuildSystem <http://bugs.centos.org>
Vendor: CentOS
URL: http://yum.baseurl.org/
Summary: RPM package installer/updater/manager
Description:
Yum is a utility that can check for and automatically download and
install updated RPM packages. Dependencies are obtained and downloaded
automatically, prompting the user for permission as necessary.

rpm -qa command

[root@localhost ~]# rpm -qa |wc -l # Count how many software packages are installed in rpm mode in the current system
1385

2.4 Install, upgrade, and uninstall rpm software packages

Install or upgrade rpm software

rpm [option] rpm package file…

Common options

-i (installation), -v (show process), -h (humanization)

Uninstall the specified rpm software

rpm -e software name

The yum warehouse automatically resolves dependencies

Three, yum

3.1 Configure local yum source repository

The steps to configure the local yum source repository are as follows:

(1) Mount the CD image to the specified location/mnt

[root@localhost ~]# mount /dev/sdr0 /mnt
mount: special device /dev/sdr0 does not exist
[root@localhost ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected and will be mounted read-only.
mount: /dev/sr0 is already mounted or /mnt is busy
       /dev/sr0 has been mounted on /run/media/root/CentOS 7 x86_64
       /dev/sr0 is mounted on /mnt

(2) Enter the yum warehouse configuration directory and back up the original *.repo file

cd /etc/yum.repos.d/
mkdir repo.bak
mv *.repo repo.bak

(3) Create a local yum source configuration file

(4) Delete yum cache and update

yum clean all & amp; & amp; yum makecache

(5) Test whether the yum source installation is successful

3.2 Source code compilation and installation software

step:

1../configure

1. Check the compilation environment and whether the dependent packages are installed completely

2. Select the installation path

3. Add or reduce the functions of the installation package

2.make

Translate high-level languages written by humans into binary

3. make install

Copy this binary file and configuration file to the previously specified directory

Specific operations

cd /opt
wget http://nginx.org/download/nginx-1.18.0.tar.gz //Download the package from the official website
tar xf nginx-1.18.0.tar.gz #Decompress
cd nginx-1.18.0 #Enter the decompressed nginx folder
yum -y install gcc pcre-devel openssl-devel zlib-devel openssl openssl-devel Install dependency environment and check that the installation package is complete
mkdir /apps/nginx -p #Create a folder
./configure --prefix=/apps/nginx Add configuration file
make #compile
make install #install
ln -s /apps/nginx/sbin/nginx /usr/sbin/nginx #Create a soft connection
#Make soft link can be completed
nginx #Start nginx directly
ss -natp |grep 80 #Detect port 80
systemctl stop firewalld #Close the firewall
setenforce 0 #Turn off core protection
 

Enter the verification on the website to see if it is successful

To this end of the experiment success.