Linux installation and management procedures in detail

A, RPM package management tools

1, the query RPM installed software information

Query installed RPM package syntax is as follows:
Linux installation and management procedures in detail

Application examples:

[root@01 ~]# rpm -qa  <!--查询所有已安装的rpm软件信息-->
2-pyasn1-modules-0.1.9-7.el7.noarch
mesa-libEGL-17.0.1-6.20170307.el7.x86_64
xcb-util-0.4.0-2.el7.x86_64
python-pyblock-0.53-6.el7.x86_64
sysstat-10.1.5-12.el7.x86_64
sos-3.4-6.el7.centos.noarch
xorg-x11-server-Xorg-1.19.3-11.el7.x86_64
libiscsi-1.9.0-7.el7.x86_64
sssd-ldap-1.15.2-50.el7.x86_64
postfix-2.10.1-6.el7.x86_64
…………<!--此处省略部分内容-->
[root@centos01 ~]# rpm -q bash    <!--查询已安装的bash软件包-->
bash-4.2.46-28.el7.x86_64
[root@centos01 ~]# rpm -qi bash    <!--查询bash软件包的详细信息-->
Name        : bash
Version     : 4.2.46
Release     : 28.el7
Architecture: x86_64
Install Date: 2019年10月23日 星期三 22时29分35秒
Group       : System Environment/Shells
Size        : 3663637
License     : GPLv3+
Signature   : RSA/SHA256, 2017年08月10日 星期四 23时03分40秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : bash-4.2.46-28.el7.src.rpm
Build Date  : 2017年08月03日 星期四 05时13分21秒
Build Host  : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://www.gnu.org/software/bash
Summary     : The GNU Bourne Again shell
Description :
The GNU Bourne Again shell (Bash) is a shell or command language
interpreter that is compatible with the Bourne shell (sh). Bash
incorporates useful features from the Korn shell (ksh) and the C shell
(csh). Most sh scripts can be run by bash without modification.
[root@centos01 ~]# rpm -qa | grep bash
bash-4.2.46-28.el7.x86_64
bash-completion-2.1-6.el7.noarch
[root@centos01 ~]# rpm -ql openssh <!--查看openssh在系统中安装的所有目录-->
/etc/ssh
/etc/ssh/moduli
/usr/bin/ssh-keygen
/usr/libexec/openssh
/usr/libexec/openssh/ctr-cavstest
/usr/libexec/openssh/ssh-keysign
/usr/share/doc/openssh-7.4p1
/usr/share/doc/openssh-7.4p1/CREDITS
…………<!--此处省略部分内容-->

2, query file or directory belongs to which software RPM

Syntax is as follows:
Linux installation and management procedures in detail

Application examples:

[root@centos01 ~]# rpm -qf /usr/bin/vim   <!--查询vim是由哪个软件包安装的-->
vim-enhanced-7.4.160-2.el7.x86_64
[root@centos01 ~]# rpm -qf /usr/libexec/openssh/  <!--查看配置文件是哪个程序使用-->
openssh-7.4p1-11.el7.x86_64

3, to query the RPM package file is not installed

Query is not installed RPM package syntax is as follows:
Linux installation and management procedures in detail

Application examples:

[root@centos01 ~]# rpm -qpi /mnt/Packages/httpd-2.4.6
-67.el7.centos.x86_64.rpm    
            <!--查看httpd的rpm包详细信息-->
Name        : httpd
Version     : 2.4.6
Release     : 67.el7.centos
Architecture: x86_64
Install Date: (not installed)
Group       : System Environment/Daemons
Size        : 9823661
License     : ASL 2.0
Signature   : RSA/SHA256, 2017年08月11日 星期五 00时40分32秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : httpd-2.4.6-67.el7.centos.src.rpm
Build Date  : 2017年08月04日 星期五 11时21分07秒
Build Host  : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://httpd.apache.org/
Summary     : Apache HTTP Server
Description :
The Apache HTTP Server is a powerful, efficient, and extensible
web server.
[root@centos01 ~]# rpm -qpl /mnt/Packages/httpd-2.4.6
-67.el7.centos.x86_64.rpm    
          <!--查看httpd的rpm包安装包含的目录-->
/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
/etc/httpd/conf.d/README
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d
/etc/httpd/conf.modules.d/00-base.conf
/etc/httpd/conf.modules.d/00-dav.conf
/etc/httpd/conf.modules.d/00-lua.conf
/etc/httpd/conf.modules.d/00-mpm.conf
/etc/httpd/conf.modules.d/00-proxy.conf
/etc/httpd/conf.modules.d/00-systemd.conf
/etc/httpd/conf.modules.d/01-cgi.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/httpd/logs
/etc/httpd/modules
/etc/httpd/run
…………   <!--此处省略部分内容-->
[root@centos01 ~]# rpm -qpc /mnt/Packages/httpd-2.4.6
-67.el7.centos.x86_64.rpm    
                <!--查看httpd安装后的配置文件-->
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d/00-base.conf
/etc/httpd/conf.modules.d/00-dav.conf
/etc/httpd/conf.modules.d/00-lua.conf
/etc/httpd/conf.modules.d/00-mpm.conf
/etc/httpd/conf.modules.d/00-proxy.conf
/etc/httpd/conf.modules.d/00-systemd.conf
/etc/httpd/conf.modules.d/01-cgi.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd

Second, install, upgrade and uninstall the RPM software

Install, upgrade and uninstall the RPM software syntax and common options are as follows:
Linux installation and management procedures in detail

1, install the RPM software

[root@centos01 ~]# rpm -ivh /mnt/Packages/ntsysv-1.7.4
-1.el7.x86_64.rpm    <!--安装ntsysv程序-->
警告:/mnt/Packages/ntsysv-1.7.4-1.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
    软件包 ntsysv-1.7.4-1.el7.x86_64 已经安装

End add "--force" option is mandatory to install the specified rpm package.

2, RPM software upgrade

[root@centos01 ~]# rpm -U /mnt/Packages/ntsysv-1.7.4-1.el7.x86_64.rpm
警告:/mnt/Packages/ntsysv-1.7.4-1.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
    软件包 ntsysv-1.7.4-1.el7.x86_64 已经安装

3, uninstall the RPM software

Uninstall rpm package syntax and auxiliary options are as follows:
Linux installation and management procedures in detail

Application examples:

[root@centos01 ~]# rpm -e ntsysv    <!--卸载ntsysv程序-->
[root@centos01 ~]# rpm -ivh /mnt/Packages/system-config
-kickstart-2.9.6-1.el7.noarch.rpm --nodeps   
              <!--结合“--nodeps”选项忽略依赖关系-->
警告:/mnt/Packages/system-config-kickstart-2.9.6-1.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:system-config-kickstart-2.9.6-1.e################################# [100%]

4, maintain RPM database

[root@centos01 ~]# rpm --initdb
<!--或者-->
[root@centos01 ~]# rpm --rebuilddb

5, introducing a public key to verify

[root@centos01 ~]# cd /mnt/
[root@centos01 mnt]# ls
CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL
[root@centos01 mnt]# rpm --import ./RPM-GPG-KEY-CentOS-7          <!--导入验证公钥-->

[root@centos01 ~]# rpm -ivh /mnt/Packages/dhcp-4.2.5
-58.el7.centos.x86_64.rpm    
              <!--再次安装rpm包不再显示密钥-->
准备中...                          ################################# [100%]
正在升级/安装...
   1:dhcp-12:4.2.5-58.el7.centos      ################################# [100%]

6, resolve package dependencies

Linux installation and management procedures in detail

Three, Linux application infrastructure

1 relationship, applications and system commands

1) file location

  • System Command: general / bin and / sbin directory, or from Shell internal instruction.

  • Applications: usually / usr / bin and / usr / sbin directories.

2) The main purpose

  • System Commands: perform basic management of the system, such as IP configuration tools.

  • Applications: Complete relatively independent of other supporting tasks, such as web browsers.

3) For the environment

  • System Command: generally only run in the character operator interface.

  • Application: according to actual needs, some programs can be run in a graphical interface.

4) Run Format

  • System commands: General, including the command word, command options and command parameters.

  • Applications: Typically no fixed execution format.

2, the directory structure of a typical application

Linux installation and management procedures in detail

3, common package types of packages

Linux installation and management procedures in detail

Fourth, the source code compiler installation

1, the source code is compiled Overview

1) The advantage of using the source code of the software installed

Get the latest software version, timely repair bug; according to user needs, the flexibility to customize the software functions.

2) application source code compiler installations Examples

Install and use than the new version of the application; currently installed programs in case you need can not be met; need to add new functionality to your application use and so on.

2, the source code compiler installation package

1) Tarball package

.tar.gz and .tar.bz2 format majority. Software Reference material: http: //sourceforge.net

2) Integrity Check

MD5 checksum calculation and are consistent, and compared with the determination value provided by the official. as follows:

[root@centos01 ~]# md5sum /mnt/Packages/tomcat-7.0.76-2.el7.noarch.rpm
3c901508f0651c5c3207f999fbf395ed  /mnt/Packages/tomcat-7.0.76-2.el7.noarch.rpm

3) confirm that the source code compiler environment

Need to support a compiler C / C ++ programming language, as follows:

[root@centos01 ~]# rpm -qa | grep gcc  <!--查看是否安装gcc和gcc-c++-->
libgcc-4.8.5-16.el7.x86_64
gcc-c++-4.8.5-16.el7.x86_64
gcc-4.8.5-16.el7.x86_64
gcc-gfortran-4.8.5-16.el7.x86_64
[root@centos01 ~]# rpm -qa | grep make   <!--查看是否安装make-->
make-3.82-23.el7.x86_64
automake-1.13.4-3.el7.noarch

4, compile and install process

Linux installation and management procedures in detail

5, build Setup

1) tar unpack

Habitual release package will usually to / usr / src / directory, source code files unpacked location / usr / src / name of the software - version number /. Application examples:

[root@centos01 ~]# tar zxvf /mnt/httpd-2.2.17.tar.gz -C /usr/src/

2) ./ configure configuration

Configure script source directory; the implementation of "./configure --help" to see help; a typical configuration options: - prefix = Software installation directory. Application examples:

[root@centos01 ~]# cd /usr/src/httpd-2.2.17/
[root@centos01 httpd-2.2.17]# ./configure --prefix=/usr/local/httpd

Do not specify any configuration options, the default value.

3) Compile

[root@centos01 httpd-2.2.17]# make 

4) Installation

[root@centos01 httpd-2.2.17]#make install

NOTE: Build and installation can be performed together, in conjunction with the intermediate && command to execute the two-time.

5) optimization program directory

[root@centos01 ~]# ln -s /usr/local/httpd/bin/* /usr/local/bin/

6) Create a system service, add execute permissions

[root@centos01 ~]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
[root@centos01 ~]# chmod +x /etc/init.d/httpd

7) Modify system services

[root@centos01 ~]# vim /etc/init.d/httpd 
#!/bin/sh
#chkconfig:35 80 20
............<!--此处省略部分内容-->

8) Add a system service, set up at startup

[root@centos01 ~]# chkconfig --add httpd
[root@centos01 ~]# chkconfig --level 35 httpd on

9) Start apache service

[root@centos01 ~]# systemctl start httpd

10) port to listen apache services

[root@centos01 ~]# netstat -anptu | grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      53115/httpd         

Guess you like

Origin www.linuxidc.com/Linux/2020-01/162124.htm