[Linux] Install and update software packages

1. RPM installation

     rpm: redhat package manager, Red Hat package management tool . You can download the installation package online or the CD-ROM comes with the installation package in the packages file.

     ① Installation process:

           (1) Mount (the CD name is too long to mount to a certain directory): mount /dev/sr0 /mnt

           (2) View the package name: ls /mnt/Packages

           (3) Install the software package: rpm -ivh yp-tools-      (need to switch to /mnt/Packages before installing)

                  (I--installation, v--detailed information, h---the sign "#" is listed during installation)

 

The installation packages that require dependencies need to be downloaded together:

[root@localhost Packages]# rpm -ivh yp-tools-2.14-3.el7.x86_64.rpm 
警告:yp-tools-2.14-3.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
错误:依赖检测失败:
	ypbind 被 yp-tools-2.14-3.el7.x86_64 需要
[root@localhost Packages]# rpm -ivh ypbind-1.37.1-7.el7.x86_64.rpm 
警告:ypbind-1.37.1-7.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
错误:依赖检测失败:
	yp-tools 被 ypbind-3:1.37.1-7.el7.x86_64 需要
[root@localhost Packages]# rpm -ivh ypbind-1.37.1-7.el7.x86_64.rpm  yp-tools-2.14-3.el7.x86_64.rpm 警告:ypbind-1.37.1-7.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:yp-tools-2.14-3.el7              ################################# [ 50%]
   2:ypbind-3:1.37.1-7.el7            ################################# [100%]

     ②Commonly used commands:

            Query all installed packages: rpm -qa | grep tree

           View the detailed location of the files released by the software package: rpm -ql package name

            Check which software package released a file: rpm -qf file name

           Remove software: rpm -e tree (package name)     

            Upgrade package: rpm -Uvh  

 

2. Yum (Red Hat Seven), dnf (Red Hat Eight) installation

      yum: Yellow dog Updater, Modified yellow dog manager, update manager, is a shell front-end package manager in Fedora, RedHat and CentOS. Based on RPM package management, it can automatically download and install rpm packages from a specified server, automatically handle dependencies, and install all dependent software packages at once.

① Installation process:

     (1) Define the configuration file: vim /etc/yum.repos.d/base.repo (installation package warehouse)

                 (Only the configuration files ending with .repo are recognized in the yum.repos.d directory) 

      (2) Local source configuration file :

               [base] (Source ID)

               name=base (source name)

               baseurl=file:///mnt/ (the location of the package file local file://)    

               enable=1 (enable this warehouse or source, one source can have multiple warehouses)

               gpgcheck=0/1 (0 means no check; 1 means check, gpgkey needs to be specified)

      (Gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release gpgcheck is not checked and omitted here, if it is checked, configuration is required)

    (3) Install the software: yum install package name

[root@localhost Packages]# vim /etc/yum.repos.d/base.repo

[RHCSA]
name=csa
baseurl=file:///mnt         (仓库的安装包从哪里来)
enable=1
gpgcheck=0


[root@localhost Packages]# yum install httpd
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-40.el7 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-40.el7,它被软件包 httpd-2.4.6-40.el7.x86_64 需要
--> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 httpd-2.4.6-40.el7.x86_64 需要
--> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 httpd-2.4.6-40.el7.x86_64 需要
--> 正在检查事务
---> 软件包 apr.x86_64.0.1.4.8-3.el7 将被 安装
---> 软件包 apr-util.x86_64.0.1.5.2-6.el7 将被 安装
---> 软件包 httpd-tools.x86_64.0.2.4.6-40.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

==========================================================================
 Package            架构          版本                 源            大小
==========================================================================
正在安装:
 httpd              x86_64        2.4.6-40.el7         RHCSA        1.2 M
为依赖而安装:
 apr                x86_64        1.4.8-3.el7          RHCSA        103 k
 apr-util           x86_64        1.5.2-6.el7          RHCSA         92 k
 httpd-tools        x86_64        2.4.6-40.el7         RHCSA         82 k

事务概要
==========================================================================
安装  1 软件包 (+3 依赖软件包)

总下载量:1.4 M
安装大小:4.3 M
Is this ok [y/d/N]: y
Downloading packages:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                        49 MB/s | 1.4 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
  正在安装    : apr-1.4.8-3.el7.x86_64                                                                                                                                 1/4 
  正在安装    : apr-util-1.5.2-6.el7.x86_64                                                                                                                            2/4 
  正在安装    : httpd-tools-2.4.6-40.el7.x86_64                                                                                                                        3/4 
  正在安装    : httpd-2.4.6-40.el7.x86_64                                                                                                                              4/4 
RHCSA/productid                                                                                                                                     | 1.6 kB  00:00:00     
  验证中      : httpd-tools-2.4.6-40.el7.x86_64                                                                                                                        1/4 
  验证中      : apr-1.4.8-3.el7.x86_64                                                                                                                                 2/4 
  验证中      : apr-util-1.5.2-6.el7.x86_64                                                                                                                            3/4 
  验证中      : httpd-2.4.6-40.el7.x86_64                                                                                                                              4/4 

已安装:
  httpd.x86_64 0:2.4.6-40.el7                                                                                                                                              

作为依赖被安装:
  apr.x86_64 0:1.4.8-3.el7                            apr-util.x86_64 0:1.5.2-6.el7                            httpd-tools.x86_64 0:2.4.6-40.el7                           

完毕!

 

②Commonly used commands:

       View source ID, source name, status: yum repolist      

       View all installed and installable packages: yum list

       Display the installation status of the specified package: yum list package name

       You can search when you are not sure about the package name: yum search command        

       Install the software: yum install

       Remove software: yum remove

       Local rpm package: localinstall

 

3. Source code installation

         ① Installation process:

              (1) Create a directory:   mkdir /1

      (2) Download the installation package: tar-1.29.tar.gz

   

 (3) Unzip: tar xvf tar-1.29.tar.gz    

 (4) Originally there is tar, it needs to be uninstalled and then reinstalled: yum remove tar -y 

 (5) Switch to Redhat and find the directory of the decompressed tar

 (6) Check whether the current environment can be installed: execute ./configure    

 (7) Install the C compiler as the root user: yum install gcc* -y    (before configuration, ensure that our compiler is complete before configuration can be performed. After configuration is completed, compile and compile and install)

 (8) Switch to redhat and execute ./configure (check whether the current system has the files and tools needed to install the software. This process is mainly to generate a Makefile file, which defines the dependencies between the various source files, and explains How to compile a source file is to generate an executable file, by describing the relationship between each source program to make the make tool automatically complete the compilation work)

(9) Execute again./configure

(10) Return to root, compile and install, switch to the decompressed directory, make compile, make install means installation (installation is complete)

      Which tar is currently stored in the directory: /usr/local/bin/tar

      tar xvf compressed package Previous storage directory: /usr/bin/tar

    Note: Although the path priority /usr/local/bin is higher than /usr/bin, because there is a hash command cache table, the executable file of the command will be searched from the cache table first, so the cache table needs to be cleared. (Hash implements cache management, caching, and saves all paths of executed commands in the hash table)

(11) Clear the hash table: hash -r

                   View hash table: hash       

                   Add a hash table: -p /bin/ls haha   

                   View the hash table of the specified command: -t ls     

                   Delete the hash table of the specified command: -d ls   

                   Clear all hash tables: -r       

         Now you can use the tar command!

Guess you like

Origin blog.csdn.net/trichloromethane/article/details/107685046