The installation and management program in the Linux system is too detailed

One, Linux application basics

(1) The relationship between application programs and system commands

Roles System command application
File location Generally in the /bin and /sbin directories, or shell internal commands Usually in /usr/bin, lusr/sbin and /usr/local/bin, /usr/local/sbin
The 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 run in the character operation interface According to actual needs, some programs can be run in the graphical interface
Run format Generally include command words, command options and command parameters Usually there is no fixed execution format, which is defined by the program developer

Enter the / directory to view the directory files, and found that bin and sbin are actually soft links, pointing to user/bin and user/sbin, where user/bin and user/sbin are in the path environment variable. When doing source installation, the program commands will be made a soft link to user/bin and user/sbin.
Insert picture description here

(2) Directory structure of typical applications

file type Save directory Description
Ordinary executable program file /usr/bin Executable by all users
Server program, management program file /usr/sbin Only the administrator can execute
Application configuration file /etc Applications installed via rpm or yum
Log file / var / log System log
Application Reference Document File /usr/share/doc Reference documents and other data about the application
Application man page file /usr/share/man Man pages for executable files and configuration files

(3) Common package types

file type Save directory
RPM package The extension is ".rpm", suitable for RHEL, CentOS and other systems
DEB software package The extension is ".deb", suitable for Ubuntu, Debian and other systems
Source code package Compressed packages generally in the format of ".tar.g2" and ".tar.bz2" contain the original code of the program and need to be compiled and installed
Package with installer The extensions of the software packages vary, mostly in TarBall format; executable programs or script files for installation are provided in the software package, such as install.sh, setup, etc.

Commonly used in Linux systems are RPM software packages and source code software packages

Two, RPM

(1) RPM package management tool

1, RPM Package Manager Red-Hat Package Manager
   put forward by the company Red Hat, by many Linux distributions used
   to establish a unified database file
  detailed records package install, uninstall, upgrade, change information
  automatically analyze package dependencies
2, RPM software package
   Software material reference: http://www.rpm.org
  General naming format: bash-4.2.46-28.el7.x86 _64.rpm
(where bash represents the software name, 4.2.46 represents the version number, 28. Represents the number of releases, el7 represents the supported system, x86 _64 represents the supported hardware platform, and .rpm represents the extension)

(2) The format of rpm command

1. The rpm command can realize almost all the management functions of the RPM software package.
2. Execute the "man rpm" command to get detailed help information about the rpm command.
3. The rpm command function
   query and verify the relevant information of the RPM package
   installation, upgrade, Uninstall RPM software package
   maintain and rebuild RPM database information and other comprehensive management operations

(3) Query RPM software package information

1. Query information about installed RPM software

rpm   -q  [子选项]      软件名

Common options
   -qa, -qi, -ql, -qf, -qc, -qd
2, query the information in the RPM package file

rpm  -qp[子选项]       RPM包文件

Common options
    -qpi、 -qpl、 -qpc、 -qpd

(4) Query information about installed rpm software

rpm -q software name# query whether the specified software is installed
rpm -qi software name# show the detailed information of the specified software installed
rpm -ql software name# show the file list of the specified software installed
rpm -qc software name#list The configuration file of the specified software that has been installed
rpm -qd software name#lists the location of the software package documentation of the specified software that has been installed
rpm -qR software name#lists the dependent software packages and files of the specified software that have been installed
rpm -qf File or Directory#Query which installation package the specified software has been installed belongs to

rpm -qa #Display the list of all software installed in rpm mode in the current system
rpm -qa I grep -i postfix #Query whether the software postfix has been installed

Query the information in the RPM package file that is not installed
rpm -qpi RPM包FILENAME#Query the detailed information of the specified software package
rpm -qpl RPM包FILENAME#query the file list of the specified software package
rpm -qpc RPM包FILENAME#query specified The configuration file of the software package
rpm -qpd RPM package file name#Query the location of the software package document of the specified software package

Using rpm -q software name (check whether the specified software has been installed), you can find out whether the software you want to use has been installed.
Insert picture description here

Use the rpm -qi software name to display the detailed information of the installed postfix (specified software).

Insert picture description here

Use rpm -ql software name, you can display a list of all files related to postfix (specified software).
Insert picture description here

rpm -qa (display the list of all software installed in rpm mode in the current system) It can be used with the "grep" command to achieve the effect of filtering files and displaying them.
Insert picture description here

Use the rpm -qf file or directory (note that the software package cannot be added here), you can query which installation package the specified software belongs to
Insert picture description here

Use rpm -qa I grep -i postfix to query whether the software (postfix) has been installed
Insert picture description here

(Four), installation, upgrade, RPM software package format:

rpm    [选项]          RPM包文件
rpm         -ivh              RPM软件包

Common options:
-i: install a new RMM software package.
-U: Upgrade a software package, if it has not been installed, install it.
-F: Upgrade a certain software package, if it has not been installed, then abandon the installation.
-h: In the process of installing or upgrading the software package, the installation progress will be displayed with "#".
-v: Display detailed information during software installation.
--Force: force to install a certain package, such as installing an older package

-e: Uninstall the software package with the specified name.
-Nodeps: When installing or upgrading or uninstalling a software package, it does not check the dependencies with other software packages.

Commonly used rpm -ivh RPM software package to install a software can display detailed information and installation progress during the installation process:
Insert picture description here

Install the software Tree in Packages in the temporary mount directory mnt. First check the tree information, find the software package that needs to be installed, and then install it using rmp -ivh tree-1.6.0-10.el7.x86_64.rpm.
Insert picture description here

(5) Maintain RPM database

1. Rebuild the RPM database
When the RPM database is damaged, it can be repaired by rebuilding the RPM database

rpm     --rebuilddb       或者         rpm     --initdb

2. Import verification public key
Before importing the public key file for digital signature verification, an error will be reported when installing part of the RPM software package in the CD. Need to import the public key file located in the root directory of the CD into the RPM database

mount     /dev/sr0   /mnt/
rpm   --import    /mnt/RPM-GPG-KEY-Centos-7

The public key file is stored in the CD root directory mnt:

Insert picture description here

Three, source code compilation overview

(1) Tarball packet

        1、tar.gz和.tar.bz2格式居多
        2、软件素材参考: http://sourceforge.net

(Two), integrity check

         md5sum校验工具

Insert picture description here

(3) Confirm the source code compilation environment

     **需安装支持C/C++程序语言的编译器,如:gcc、gcc-c++、 make、......**

(4) Use yum to solve the problem of source installation dependencies

To install the source code software package, you need to compile and install, and you need to install a compiler that supports c and c++ programming languages, such as gcc. gcc-c++, make.
If you use rpm to install, you need to install multiple dependent packages first, which will be cumbersome. Here you can use yum to perform one-click installation.

First configure the local yum source warehouse:

mount   /dev/cdrom   /mnt/         #把光盘挂载到/mnt目录下
cd    /etc/yum.repos.d/               #进入到/etc下的yum.repos.d的目录下
mkdir    repos.bak                     #创建一个叫做repos.bak的新目录
mv    *.repo    repos.bak           #将带有.repo的所有文件移动到repos.bak目录下

Insert picture description here

cd    /etc/yum.repos.d/
vim   local.repo
[local]                                 #仓库类别
name=local                      #仓库名称
baseurl=file:///mnt    #指定URL访问路径为光盘挂载目录(前面两个//是固定格式,后面一个/是目录)
enabled=1                        #开启此yum源,此为默认项,可省略
gpgcheck=0                      #不验证软件包的签名

yum clean all && yum makecache             #删除yum缓存并更新(可分两步进行)

Create yum warehouse as follows:
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

yum常用的操作命令:
yum     -y     install     软件名                     #安装、升级软件包, "-y"选项表示自动确认
yum     -y     remove   软件名                    #卸载软件包,可自动解决其依赖关系
yum     -y     update    软件名        #升级软件包  
yum   list                               #查询yum中所有的软件包列表
yum   list    installed              #查询yum仓库中已安装的软件包
yum   list    available             #查询yum仓库中尚未安装的软件包
yum   list    updates              #查询yum仓库中可以升级版本的软件包
yum   info    软件名               #查询软件包的描述信息
yum   info    httpd                  #查询阿帕奇软件包的描述信息
yum    search    [all]    关键词           #根据某个关键词来查找相关的软件包
yum    search     all     httpd
yum    whatprovides     命令             #查询命令属于哪个软件包
yum    whatprovides     netstat

When mounting disks, be aware that the disks on the virtual machine need to be connected.
Insert picture description here

mount is the mount command; /dev/cdrom is the CD; mnt is the temporary mount directory. After mounting, it is read-only and cannot be executed:
Insert picture description here

Install Apache software with yum -y install:
Insert picture description here

Use yum -y remove to delete Apache:
Insert picture description here

Use yum info to query package information:
Insert picture description here

Use yum to install the compiler:

yum    install    -y    gcc    gcc-c++    make

The basic process of compiling and installing:

1), tar unpacking

tar   zxvf/jxvf  xxx.tar.gz/xxx.tar.bz2  -C  目标路径

2) Configure the software module (installation path, enable or disable module functions, user settings for managing service processes)
./configure --prefix=target path (where the software is installed)
3) Compile (convert the source code into a Program executed)
make
4) install
make install

Use the yum method to install the compiler: (Because the source code installation software requires C and C++ environments, you need to install these two compilers)
Insert picture description here

Guess you like

Origin blog.csdn.net/Gengchenchen/article/details/109822963