您现在的位置是:首页 > 编程 > 

深度解析Linux 软件包管理器 yum(查看、安装、卸载软件的相关操作)

2025-07-22 10:34:28
深度解析Linux 软件包管理器 yum(查看、安装、卸载软件的相关操作) 卸载的话就是apt remove -y xxxLinux下载安装软件的方案1.源代码安装(不推荐)2.rpm包安装(不推荐).包管理器进行安装—yum/apt(相当于手机上面的应用商店)我们使用的云服务器是被定制化过的我们选择centos的原因是因为centos的生态好 开源本质是一种商业模式在我们的Linux机器上,

深度解析Linux 软件包管理器 yum(查看、安装、卸载软件的相关操作)

卸载的话就是apt remove -y xxx

Linux下载安装软件的方案

1.源代码安装(不推荐)

2.rpm包安装(不推荐)

.包管理器进行安装—yum/apt(相当于手机上面的应用商店)

我们使用的云服务器是被定制化过的

我们选择centos的原因是因为centos的生态好

开源本质是一种商业模式

在我们的Linux机器上,有对应的给yum/apt提供的配置文件

这些配置文件应该保存的是各个服务器的url或者是ip地址

云服务器:内置的配置文件已经是国内的了

我们可以通过yum list grep sl罗列出我们的centos所支持的所有软件

那么我们这里就能查到我们的sl这个软件的信息

将所有的软件包名字和配置信息都拉到本地

代码语言:javascript代码运行次数:0运行复制
[root@hcss-ecs-28de ~]# yum list |grep sl
cyrus-sasl-lib.x86_64                                             2.1.                                           @BaseOS   
isl.x86_64                                                        0.16.                                           @AppStream
libnsl2.x86_64                                                    1.2.0-2.                         @anaconda 
libpsl.x86_64                                                     0.20.                                           @BaseOS   
openssl.x86_64                                                    1:1.1._5                                       @BaseOS   
openssl-libs.x86_64                                               1:1.1._5                                       @BaseOS   
openssl-pkcs11.x86_64                                             0.4.                                           @anaconda 
                                               0.6.                                           @anaconda 
                                          0.6.                                           @anaconda 
rsyslog.x86_64                                                    8.2102.                                         @AppStream
slang.x86_64                                                      2..                                            @anaconda 
etworkManager-adsl.x86_64                                        1:1.2.                                        BaseOS    
etworkManager-fortissl.x86_64                                 1.2.                                           epel      
etworkManager-fortissl-gnome.x86_64                           1.2.                                           epel      
anope-openssl.x86_64                                              2.1.                                            epel      
apr-util-openssl.i686                                             1.6.                                            AppStream 
apr-util-openssl.x86_64                                           1.6.                                            AppStream 
                                                1:6.4.7.                                        AppStream 
certwatch-mod_ssl.x86_64                                          1.                                              epel      
cgnslib.x86_64                                                    .4.                                            epel      
cgnslib-devel.x86_64                                              .4.                                            epel      
compat-openssl10.i686                                             1:1.0.                                         AppStream 
compat-openssl10.x86_64                                           1:1.0.                                         AppStream 
cyrus-sasl.i686                                                   2.1.                                           BaseOS    
cyrus-sasl.x86_64                                                 2.1.                                           BaseOS    
cyrus-sasl-devel.i686                                             2.1.                                           BaseOS    
cyrus-sasl-devel.x86_64                                           2.1.                                           BaseOS    
cyrus-sasl-gs2.i686                                               2.1.                                           BaseOS    
cyrus-sasl-gs2.x86_64                                             2.1.                                           BaseOS    
cyrus-sasl-gssapi.i686                                            2.1.                                           BaseOS    
cyrus-sasl-gssapi.x86_64                                          2.1.                                           BaseOS    
cyrus-sasl-ldap.i686                                              2.1.                                           BaseOS    
cyrus-sasl-ldap.x86_64                                            2.1.                                           BaseOS    
cyrus-sasl-lib.i686                                               2.1.                                           BaseOS    
cyrus-sasl-md5.i686                                               2.1.                                           BaseOS    
cyrus-sasl-md5.x86_64                                             2.1.                                           BaseOS    
cyrus-sasl-ntlm.i686                                              2.1.                                           BaseOS    
cyrus-sasl-ntlm.x86_64                                            2.1.                                           BaseOS    
cyrus-sasl-plain.i686                                             2.1.                                           BaseOS    
cyrus-sasl-plain.x86_64                                           2.1.                                           BaseOS    
cyrus-sasl-scram.i686                                             2.1.                                           BaseOS    
cyrus-sasl-scram.x86_64                                           2.1.                                           BaseOS    
cyrus-sasl-sql.i686                                               2.1.                                           AppStream 
cyrus-sasl-sql.x86_64                                             2.1.                                           AppStream 
dcap-tunnel-ssl.x86_64                                            2.47.                                          epel      
dislocker.x86_64                                                  0.7.                                            epel      
dislocker-libs.x86_64                                             0.7.                                            epel      
                                          1.79.                                           AppStream 
                                         1.79.                                           epel      
                              1.79.                                           epel      
erlang-sasl.x86_64                                                22.0.                                           epel      
erlang-ssl.x86_64                                                 22.0.                                           epel      
                                     2.5.                                           epel      
fuse-dislocker.x86_64                                             0.7.                                            epel      
gedit-plugin-translate.x86_64                                     .28.                                           AppStream 
glibc-langpack-sl.x86_64                                          2.                                           BaseOS    
                              .                                              epel      
globus-gsi-openssl-error.x86_64                                   4.                                              epel      
globus-gsi-openssl-error-devel.x86_64                             4.                                              epel      
                               4.                                              epel      
globus-gsi-proxy-ssl.x86_64                                       6.                                              epel      
globus-gsi-proxy-ssl-devel.x86_64                                 6.                                              epel      
                                   6.                                              epel      
globus-openssl-module.x86_64                                      5.                                              epel      
globus-openssl-module-devel.x86_64                                5.                                              epel      
                                  5.                                              epel      
globus-rsl.x86_64                                                 11.                                             epel      
globus-rsl-devel.x86_64                                           11.                                             epel      
                                             11.                                             epel      
gsl.i686                                                          2.                                              AppStream 
gsl.x86_64                                                        2.                                              AppStream 
gsl-devel.i686                                                    2.                                              AppStream 
gsl-devel.x86_64                                                  2.                                              AppStream 
                                               .                                              epel      
htslib.x86_64                                                     1.                                              epel      
htslib-devel.x86_64                                               1.                                              epel      
htslib-tools.x86_64                                               1.                                              epel      
                                                0.                                      AppStream 
                                                  0.                                      AppStream 
isl.i686                                                          0.16.                                           AppStream 
                                              1.0.                                           epel      
java-1.8.0-openjdk-headless-slowdebug.x86_64                      1:1.8.0.12.b07_5                                AppStream 
java-1.8.0-openjdk-slowdebug.x86_64                               1:1.8.0.12.b07_5                                AppStream 
java-latest-openjdk-demo-slowdebug.x86_64                         1:2.0.1.0.11-1.                            epel      
java-latest-openjdk-devel-slowdebug.x86_64                        1:2.0.1.0.11-1.                            epel      
java-latest-openjdk-headless-slowdebug.x86_64                     1:2.0.1.0.11-1.                            epel      
java-latest-openjdk-jmods-slowdebug.x86_64                        1:2.0.1.0.11-1.                            epel      
java-latest-openjdk-portable-devel-slowdebug.x86_64               1:2.0.1.0.11-1.                            epel      
java-latest-openjdk-portable-slowdebug.x86_64                     1:2.0.1.0.11-1.                            epel      
java-latest-openjdk-portable-static-libs-slowdebug.x86_64         1:2.0.1.0.11-1.                            epel      
java-latest-openjdk-slowdebug.x86_64                              1:2.0.1.0.11-1.                            epel      
java-latest-openjdk-src-slowdebug.x86_64                          1:2.0.1.0.11-1.                            epel      
java-latest-openjdk-static-libs-slowdebug.x86_64                  1:2.0.1.0.11-1.                            epel      
                                             1.7._el8.0.0+9+6a9b6e22                    AppStream 
kdesdk-kioslaves.x86_64                                           22.04.                                          epel      
                                               1.                                             AppStream 
libgsasl.x86_64                                                   1.8.                                            epel      
libgsasl-devel.x86_64                                             1.8.                                            epel      
libknet1-crypto-openssl-plugin.x86_64                             1.24-4.                                           epel      
libnsl.i686                                                       2.                                           BaseOS    
libnsl.x86_64                                                     2.                                           BaseOS    
libnsl2.i686                                                      1.2.0-2.                         BaseOS    
libpsl.i686                                                       0.20.                                           BaseOS    
libreoffice-help-sl.x86_64                                        1:6.4.7.                                        AppStream 
libreoffice-langpack-sl.x86_64                                    1:6.4.7.                                        AppStream 
libreoffice-xsltfilter.x86_64                                     1:6.4.7.                                        AppStream 
libslirp.x86_64                                                   4.4._el8.5.0+890+6b16101                    AppStream 
libslirp-devel.x86_64                                             4.4._el8.5.0+890+6b16101                    AppStream 
libslopy.x86_64                                                   7.                                              epel      
libslopy-devel.x86_64                                             7.                                              epel      
libslz.x86_64                                                     1.2.0                                            epel      
libslz-devel.x86_64                                               1.2.0                                            epel      
libxslt.i686                                                      1.1.                                           BaseOS    
libxslt.x86_64                                                    1.1.                                           BaseOS    
libxslt-devel.i686                                                1.1.                                           AppStream 
libxslt-devel.x86_64                                              1.1.                                           AppStream 
lighttpd-mod_authn_sasl.x86_64                                    1.4.6                                           epel      
lighttpd-mod_openssl.x86_64                                       1.4.6                                           epel      
lua-cyrussasl.x86_64                                              1.1.                                            epel      
lua-luaossl.x86_64                                                201907                                         epel      
                                            201907                                         epel      
lua5.1-luaossl.x86_64                                             201907                                         epel      
                                              0.5.                                           epel      
                                                0.5.                                           epel      
mod_ssl.x86_64                                                    1:2.4._el8.5.0+1022+b541fb1               AppStream 
                                   1.00                                            epel      
                            1.00                                            epel      
                         1.00                                            epel      
                                                  0.201010-1                                      AppStream 
nagios-plugins-ssl_validity.x86_64                                2.4.9-                                            epel      
nginx-mod-http-xslt-filter.x86_64                                 1:1.14._el8.0.0+184+e4fea82                 AppStream 
openslide.x86_64                                                  .4.                                           epel      
openslide-devel.x86_64                                            .4.                                           epel      
openslide-tools.x86_64                                            .4.                                           epel      
openslp.i686                                                      2.0.                                           AppStream 
openslp.x86_64                                                    2.0.                                           AppStream 
openssl-devel.i686                                                1:1.1._5                                       BaseOS    
openssl-devel.x86_64                                              1:1.1._5                                       BaseOS    
openssl-ibmpkcs11.x86_64                                          1.0.                                            BaseOS    
openssl-libs.i686                                                 1:1.1._5                                       BaseOS    
openssl-perl.x86_64                                               1:1.1._5                                       BaseOS    
openssl-pkcs11.i686                                               0.4.                                           BaseOS    
openssl.x86_64                                                   .2.2-2.                                          epel      
openssl-devel.x86_64                                             .2.2-2.                                          epel      
openssl-libs.x86_64                                              .2.2-2.                                          epel      
osslsigncode.x86_64                                               2.                                              epel      
pcp-pmda-rsyslog.x86_64                                           5..                                            AppStream 
pcp-pmda-slurm.x86_64                                             5..                                            AppStream 
pdsh-mod-slurm.x86_64                                             2.                                             epel      
                                       0.                                             epel      
                                        1.                                             epel      
                       1.                                             epel      
perl-Sys-Syslog.x86_64                                            0.                                           AppStream 
perl-Unix-Syslog.x86_64                                           1.                                             AppStream 
                                   0.                                              epel      
plasma-nm-fortissl.x86_64                                      5.24.                                           epel      
pslib.x86_64                                                      0.4.                                           epel      
pslib-devel.x86_64                                                0.4.                                           epel      
                                            1.1.                                            epel      
                                            0.1.0-                                           epel      
python2-backports-ssl_match_                       .5.0._el8.5.0+74+cd2f5d28                 AppStream 
                                  1.                                              epel      
                                            0.1.0-                                           epel      
                                         0.5.                                            epel      
                                            0.4.1                                            epel      
                                             0.9.2                                           epel      
                                             0.2.                                           epel      
python-openslide.x86_64                                          1.1.                                            epel      
                                            1.7.                                            epel      
                                             2.1.7                                           BaseOS    
python-should_                                         2.1.                                            epel      
                                            0.1.                                           epel      
                                        0.1.                                           epel      
python-slixmpp.x86_64                                            1.7.                                            epel      
                                          0.2.0-                                            epel      
                                            4.0.0-                                            epel      
                                          2.7.0                                            epel      
                                  1.                                              epel      
                                      0.7.                                            epel      
python.                                         1.7.                                           epel      
qca-qt5-cyrus-sasl.x86_64                                         2..4                                            epel      
qca-qt5-ossl.x86_64                                               2..4                                            epel      
                                    8.0.                                            epel      
                                         5.15.                                           AppStream 
rpm-plugin-syslog.x86_64                                          4.14.                                          BaseOS    
rsyslog-crypto.x86_64                                             8.2102.                                         AppStream 
                                                8.2102.                                         AppStream 
rsyslog-elasticsearch.x86_64                                      8.2102.                                         AppStream 
rsyslog-gnutls.x86_64                                             8.2102.                                         AppStream 
rsyslog-gssapi.x86_64                                             8.2102.                                         AppStream 
rsyslog-kafka.x86_64                                              8.2102.                                         AppStream 
rsyslog-mmaudit.x86_64                                            8.2102.                                         AppStream 
rsyslog-mmjsonparse.x86_64                                        8.2102.                                         AppStream 
rsyslog-mmkubernetes.x86_64                                       8.2102.                                         AppStream 
rsyslog-mmnormalize.x86_64                                        8.2102.                                         AppStream 
rsyslog-mmsnmptrapd.x86_64                                        8.2102.                                         AppStream 
rsyslog-mysql.x86_64                                              8.2102.                                         AppStream 
rsyslog-omamqp1.x86_64                                            8.2102.                                         AppStream 
rsyslog-openssl.x86_64                                            8.2102.                                         AppStream 
rsyslog-pgsql.x86_64                                              8.2102.                                         AppStream 
rsyslog-relp.x86_64                                               8.2102.                                         AppStream 
rsyslog-snmp.x86_64                                               8.2102.                                         AppStream 
rsyslog-udpspoof.x86_64                                           8.2102.                                         AppStream 
rubygem-openssl.i686                                              2.1._el8.4.0+847+ee687b6c                  AppStream 
rubygem-openssl.x86_64                                            2.1._el8.4.0+847+ee687b6c                  AppStream 
sasl-xoauth2.x86_64                                               0.2                                             epel      
sl.x86_64                                                         5.0                                             epel      
slang.i686                                                        2..                                            BaseOS    
slang-devel.i686                                                  2..                                            AppStream 
slang-devel.x86_64                                                2..                                            AppStream 
sleef.x86_64                                                      .5.                                            epel      
sleef-devel.x86_64                                                .5.                                            epel      
                                                  .5.                                            epel      
sleef-gnuabi.x86_64                                               .5.                                            epel      
sleef-gnuabi-devel.x86_64                                         .5.                                            epel      
sleuthkit.x86_64                                                  4.9.0-                                            epel      
sleuthkit-devel.x86_64                                            4.9.0-                                            epel      
sleuthkit-libs.x86_64                                             4.9.0-                                            epel      
                                                      1.7._el8.0.0+9+6a9b6e22                    AppStream 
slick-greeter.x86_64                                              1.5.                                            epel      
                                     1.5.                                            epel      
                                         1.5.                                            epel      
slirp4netns.x86_64                                                1.1._el8.5.0+890+6b16101                    AppStream 
sloccount.x86_64                                                  2.                                            epel      
slop.x86_64                                                       7.                                              epel      
slowhttptest.x86_64                                               1.8.                                            epel      
                                                  0.2.0-                                            epel      
slurm.x86_64                                                      20.11.9-                                          epel      
slurm-contribs.x86_64                                             20.11.9-                                          epel      
slurm-devel.x86_64                                                20.11.9-                                          epel      
slurm-doc.x86_64                                                  20.11.9-                                          epel      
slurm-gui.x86_64                                                  20.11.9-                                          epel      
slurm-libs.x86_64                                                 20.11.9-                                          epel      
slurm-nss_slurm.x86_64                                            20.11.9-                                          epel      
slurm-openlava.x86_64                                             20.11.9-                                          epel      
slurm-pam_slurm.x86_64                                            20.11.9-                                          epel      
slurm-perlapi.x86_64                                              20.11.9-                                          epel      
slurm-pmi.x86_64                                                  20.11.9-                                          epel      
slurm-pmi-devel.x86_64                                            20.11.9-                                          epel      
slurm-rrdtool.x86_64                                              20.11.9-                                          epel      
slurm-slurmctld.x86_64                                            20.11.9-                                          epel      
slurm-slurmd.x86_64                                               20.11.9-                                          epel      
slurm-slurmdbd.x86_64                                             20.11.9-                                          epel      
slurm-slurmrestd.x86_64                                           20.11.9-                                          epel      
slurm-torque.x86_64                                               20.11.9-                                          epel      
ssldump.x86_64                                                    1.9-                                              epel      
sslh.x86_64                                                       1.20-                                             epel      
sslscan.x86_64                                                    2.0.                                            epel      
syslinux.x86_64                                                   6.0                                             BaseOS    
syslinux-extlinux.x86_64                                          6.0                                             BaseOS    
                                 6.0                                             BaseOS    
                                          6.0                                             BaseOS    
                                          6.0                                             BaseOS    
syslog-ng.x86_64                                                  .2.                                           epel      
syslog-ng-amqp.x86_64                                             .2.                                           epel      
syslog-ng-devel.x86_64                                            .2.                                           epel      
syslog-ng-geoip.x86_64                                            .2.                                           epel      
syslog-ng-http.x86_64                                             .2.                                           epel      
syslog-ng-java.x86_64                                             .2.                                           epel      
syslog-ng-libdbi.x86_64                                           .2.                                           epel      
syslog-ng-logrotate.x86_64                                        .2.                                           epel      
syslog-ng-mongodb.x86_64                                          .2.                                           epel      
syslog-ng-python.x86_64                                           .2.                                           epel      
syslog-ng-redis.x86_64                                            .2.                                           epel      
syslog-ng-riemann.x86_64                                          .2.                                           epel      
syslog-ng-smtp.x86_64                                             .2.                                           epel      
                                     4.0.                                            epel      
                                     4.0.                                            epel      
                                     4.0.                                            epel      
                                                    .2~rc-                                          epel      
                                           7:20180414                                      AppStream 
                                            7:20180414                                      AppStream 
                                           7:20180414                                      AppStream 
                           7:20180414                                      AppStream 
                                         7:                                      epel      
                                            0.9.7.                                          epel      
tsl-sparse-map-devel.x86_64                                       0.6.2                                            epel      
tslib.x86_64                                                      1.2                                             epel      
tslib-devel.x86_64                                                1.2                                             epel      
uwsgi-logger-rsyslog.x86_64                                       2.0.                                           epel      
uwsgi-logger-syslog.x86_64                                        2.0.                                           epel      
uwsgi-plugin-xslt.x86_64                                          2.0.                                           epel      
uwsgi-router-ssl.x86_64                                           2.0.                                           epel      
wcslib.x86_64                                                     7.1                                             epel      
wcslib-devel.x86_64                                               7.1                                             epel      
wcslib-utils.x86_64                                               7.1                                             epel      
xmlsec1-openssl.i686                                              1.2.                                           AppStream 
xmlsec1-openssl.x86_64                                            1.2.                                           AppStream 
                                                   .28.0                                           AppStream 
[root@hcss-ecs-28de ~]# 

我们现在下载一个软件叫做sl

输入命令yum install -y sl就能进行下载的操作

代码语言:javascript代码运行次数:0运行复制
[root@hcss-ecs-28de ~]# yum install -y sl
Last metadata expiration check: :17:18 ago on Sun 22 Dec 2024 02:27:58 PM CST.
Dependencies resolved.
============================================================================================================================================================================
 Package                              Architecture                             Version                                         Repository                              Size
============================================================================================================================================================================
Installing:
 sl                                   x86_64                                   5.0                                      epel                                    16 k

Transaction Summary
============================================================================================================================================================================
Install  1 Package

Total download size: 16 k
Installed size: 26 k
Downloading Packages:
sl-5.0.x86_64.rpm                                                                                                                     18 kB/s |  16 kB     00:00    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                        18 kB/s |  16 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                    1/1 
  Installing       : sl-5.0.x86_64                                                                                                                               1/1 
  Running scriptlet: sl-5.0.x86_64                                                                                                                               1/1 
  Verifying        : sl-5.0.x86_64                                                                                                                               1/1 

Installed:
  sl-5.0.x86_64                                                                                                                                                      

Complete!
[root@hcss-ecs-28de ~]# 

那么我们运行我们的Linux,输入sl这个命令,出现在我们面前的就是一个小火车

但是你如果正常输入指令进行安装操作的话但是系统不让你安装你会怎么办呢?

是为什么呢?

因为我们这里使用的是普通用户的账号,我们是需要使用root账号进行安装的

或者是用sudo进行安装的操作

Linux一般而言,软件只要安装一次,所有都能用,我们使用other用户的身份进行使用

那么我们如何进行卸载的操作呢?

我们使用命令yum remove sl就能卸载对应的软件,但是我们是需要使用root用户进行卸载操作的

只有root用户才能进行安装和卸载的操作的

总结:

yum三板斧

yunm list | grep xxx查看我们要下载的软件的相关的信息

yum install -y xxx进行软件的安装操作

yum remove xxx进行软件的卸载的操作

如果我们的系统是乌班图的话我们使用apt search sl进行相关的软件搜索的操作

下载的话就是apt install -y xxx

其实区别是不大的

并且我们在安装的时候只能装完一个再装另外一个,如果同时安装两个的话是会进行报错的

我们电脑必须联网才能进行安装软件的操作

这个yum配置软件在那个本地的文件etc目录下的yum.repos.d

这个路径就是yum源配置文件所在的路径

我们输入命令cd /etc/yum.repos.d/就能看见了

我们对应的yum源不一定只有一个

而centos中最核心的最基础的yum源就是CentOS-Base.repo

代码语言:javascript代码运行次数:0运行复制
[root@hcss-ecs-28de ~]# cd /etc/yum.repos.d/
[root@hcss-ecs-28de yum.repos.d]# pwd
/etc/yum.repos.d
[root@hcss-ecs-28de yum.repos.d]# ll
total 76
-rw-r--r-- 1 root root  748 Jul 17  202 CentOS-AppStream.repo
-rw-r--r-- 1 root root  729 Jul 17  202 CentOS-Base.repo
-rw-r--r-- 1 root root  815 Jul 17  202 CentOS-centosplus.repo
-rw-r--r-- 1 root root 1060 Jul 17  202 CentOS-CR.repo
-rw-r--r-- 1 root root  668 Jul 17  202 CentOS-Debuginfo.repo
-rw-r--r-- 1 root root  760 Jul 17  202 CentOS-Devel.repo
-rw-r--r-- 1 root root  77 Jul 17  202 CentOS-Extras.repo
-rw-r--r-- 1 root root  55 Jul 17  202 CentOS-fasttrack.repo
-rw-r--r-- 1 root root  755 Jul 17  202 CentOS-HA.repo
-rw-r--r-- 1 root root  928 Jul 17  202 CentOS-Media.repo
-rw-r--r-- 1 root root  75 Jul 17  202 CentOS-PowerTools.repo
-rw-r--r-- 1 root root 182 Jul 17  202 CentOS-Sources.repo
-rw-r--r-- 1 root root   74 Jul 17  202 CentOS-Vault.repo
-rw-r--r-- 1 root root 151 Jul 17  202 epel-modular.repo
-rw-r--r-- 1 root root 1680 Apr 17  202 epel-modular.repo.rpmnew
-rw-r--r-- 1 root root 1450 Jul 17  202 epel.repo
-rw-r--r-- 1 root root 12 Apr 17  202 epel.repo.rpmnew
-rw-r--r-- 1 root root 1779 Apr 17  202 epel-testing-modular.repo
-rw-r--r-- 1 root root 141 Apr 17  202 epel-testing.repo
[root@hcss-ecs-28de yum.repos.d]# 

我们输入命令cat CentOS-Base.repo进行配置文件的查看操作

代码语言:javascript代码运行次数:0运行复制
[root@hcss-ecs-28de yum.repos.d]# cat CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[BaseOS]
name=CentOS-$releasever - Base
#mirrorlist=/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
baseurl=/$contentdir/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[root@hcss-ecs-28de yum.repos.d]# 

乌班图下也有自己的yum源的

在我们的/etc/apt/sources.list

切换yum源的本质就是更改配置文件

如果我们需要进行切换yum源的话,我们可以到文心一言进行帮助

输入centos 7系统重切换yum镜像源到16,帮我形成清单,并且进行简单的说明

下面是我的gpt生成的答案

以下是将 CentOS 7 的 yum 镜像源切换到 16 镜像源的清单和操作说明:


步骤清单
  1. 备份当前的 yum 源配置文件
  • 备份 /etc/yum.repos.d/CentOS-Base.repo 文件,以便出问题时还原。
  1. 下载 16 镜像源的 repo 文件
  • 删除或禁用原有的 CentOS 源,下载并替换为 16 提供的配置文件。
  1. 清理和重建 yum 缓存
  • 清理旧的缓存并更新以使用新的镜像源。
  1. 验证配置是否成功
  • 测试 yum 能否正常访问 16 镜像源,并检查下载速度。

详细操作说明
1. 备份原有配置文件
代码语言:javascript代码运行次数:0运行复制
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

说明:备份原有配置文件可以防止切换过程中出现错误,方便快速恢复。

2. 下载 16 镜像源配置

先删除旧的 yum 源文件(非必须,但推荐保持整洁):

代码语言:javascript代码运行次数:0运行复制
sudo rm -f /etc/yum.repos.d/CentOS-Base.repo

下载 16 提供的 CentOS 7 配置文件:

代码语言:javascript代码运行次数:0运行复制
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo /.help/CentOS7-Base-16.repo
. 清理和更新缓存

执行以下命令清理 yum 缓存,并重新生成新缓存:

代码语言:javascript代码运行次数:0运行复制
sudo yum clean all
sudo yum makecache
4. 验证镜像源是否正常

运行以下命令检查是否成功切换到 16 源:

代码语言:javascript代码运行次数:0运行复制
sudo yum repolist

输出的结果中应该能看到类似以下内容:

代码语言:javascript代码运行次数:0运行复制
repo id                         repo name                                status
base/7/x86_64                   CentOS-7 - Base - 16               XXXX
extras/7/x86_64                 CentOS-7 - Extras - 16             XXXX
updates/7/x86_64                CentOS-7 - Updates - 16            XXXX
5. 测试下载速度

安装一个简单软件包(如 wget)测试下载速度:

代码语言:javascript代码运行次数:0运行复制
sudo yum install -y wget

注意事项
  • 如果 16 镜像源不可用,可能需要切换到其他镜像源(如阿里云或腾讯云)。
  • 如果你的网络环境有限制,确保可以正常访问 16 的服务器地址(mirrors.16)。
  • 不建议在生产环境随意更换镜像源,请提前测试稳定性。

希望以上步骤能够帮助你顺利切换镜像源!

我们这里下载一个有趣的命令htop

会将你的电脑信息显示出来的

代码语言:javascript代码运行次数:0运行复制
[root@hcss-ecs-28de ~]# yum install -y htop
Last metadata expiration check: 2:5:41 ago on Tue 24 Dec 2024 10:1:54 AM CST.
Dependencies resolved.
========================================================================================
 Package           Architecture        Version                  Repository         Size
========================================================================================
Installing:
 htop              x86_64              .2.              epel              170 k

Transaction Summary
========================================================================================
Install  1 Package

Total download size: 170 k
Installed size: 96 k
Downloading Packages:
htop-.2..x86_64.rpm                              41 kB/s | 170 kB     00:04    
----------------------------------------------------------------------------------------
Total                                                    41 kB/s | 170 kB     00:04     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                1/1 
  Installing       : htop-.2..x86_64                                        1/1 
  Running scriptlet: htop-.2..x86_64                                        1/1 
  Verifying        : htop-.2..x86_64                                        1/1 

Installed:
  htop-.2..x86_64                                                               

Complete!
[root@hcss-ecs-28de ~]# htop
[root@hcss-ecs-28de ~]# 
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2025-01-01,如有侵权请联系 cloudcommunity@tencent 删除软件包管理器linuxyumx86

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/biancheng/1173435.html

相关标签:无
上传时间: 2025-07-21 12:25:58
留言与评论(共有 13 条评论)
本站网友 梦见大蛇吃人
15分钟前 发表
所有都能用
本站网友 骗子查询
23分钟前 发表
如果同时安装两个的话是会进行报错的我们电脑必须联网才能进行安装软件的操作这个yum配置软件在那个本地的文件etc目录下的yum.repos.d 这个路径就是yum源配置文件所在的路径我们输入命令cd /etc/yum.repos.d/就能看见了我们对应的yum源不一定只有一个而centos中最核心的最基础的yum源就是CentOS-Base.repo代码语言:javascript代码运行次数:0运行复制[root@hcss-ecs-28de ~]# cd /etc/yum.repos.d/ [root@hcss-ecs-28de yum.repos.d]# pwd /etc/yum.repos.d [root@hcss-ecs-28de yum.repos.d]# ll total 76 -rw-r--r-- 1 root root 748 Jul 17 202 CentOS-AppStream.repo -rw-r--r-- 1 root root 729 Jul 17 202 CentOS-Base.repo -rw-r--r-- 1 root root 815 Jul 17 202 CentOS-centosplus.repo -rw-r--r-- 1 root root 1060 Jul 17 202 CentOS-CR.repo -rw-r--r-- 1 root root 668 Jul 17 202 CentOS-Debuginfo.repo -rw-r--r-- 1 root root 760 Jul 17 202 CentOS-Devel.repo -rw-r--r-- 1 root root 77 Jul 17 202 CentOS-Extras.repo -rw-r--r-- 1 root root 55 Jul 17 202 CentOS-fasttrack.repo -rw-r--r-- 1 root root 755 Jul 17 202 CentOS-HA.repo -rw-r--r-- 1 root root 928 Jul 17 202 CentOS-Media.repo -rw-r--r-- 1 root root 75 Jul 17 202 CentOS-PowerTools.repo -rw-r--r-- 1 root root 182 Jul 17 202 CentOS-Sources.repo -rw-r--r-- 1 root root 74 Jul 17 202 CentOS-Vault.repo -rw-r--r-- 1 root root 151 Jul 17 202 epel-modular.repo -rw-r--r-- 1 root root 1680 Apr 17 202 epel-modular.repo.rpmnew -rw-r--r-- 1 root root 1450 Jul 17 202 epel.repo -rw-r--r-- 1 root root 12 Apr 17 202 epel.repo.rpmnew -rw-r--r-- 1 root root 1779 Apr 17 202 epel-testing-modular.repo -rw-r--r-- 1 root root 141 Apr 17 202 epel-testing.repo [root@hcss-ecs-28de yum.repos.d]# 我们输入命令cat CentOS-Base.repo进行配置文件的查看操作代码语言:javascript代码运行次数:0运行复制[root@hcss-ecs-28de yum.repos.d]# cat CentOS-Base.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you
本站网友 哈尔滨长途汽车站
15分钟前 发表
2.0.1.0.11-1. epel java-latest-openjdk-headless-slowdebug.x86_64 1
本站网友 96888
11分钟前 发表
出现在我们面前的就是一个小火车但是你如果正常输入指令进行安装操作的话但是系统不让你安装你会怎么办呢?是为什么呢? 因为我们这里使用的是普通用户的账号
本站网友 女孩子第一次
18分钟前 发表
出现在我们面前的就是一个小火车但是你如果正常输入指令进行安装操作的话但是系统不让你安装你会怎么办呢?是为什么呢? 因为我们这里使用的是普通用户的账号
本站网友 泥垢
12分钟前 发表
htop-.2..x86_64 Complete! [root@hcss-ecs-28de ~]# htop [root@hcss-ecs-28de ~]# 本文参与 腾讯云自媒体同步曝光计划
本站网友 无锡搜房网
27分钟前 发表
1.8.0.12.b07_5 AppStream java-1.8.0-openjdk-slowdebug.x86_64 1
本站网友 勤诚达22世纪
12分钟前 发表
2
本站网友 招行网银专业版
9分钟前 发表
可能需要切换到其他镜像源(如阿里云或腾讯云)
本站网友 硒的作用
11分钟前 发表
58 PM CST. Dependencies resolved. ============================================================================================================================================================================ Package Architecture Version Repository Size ============================================================================================================================================================================ Installing
本站网友 叶斌
22分钟前 发表
我们使用other用户的身份进行使用那么我们如何进行卸载的操作呢?我们使用命令yum remove sl就能卸载对应的软件
本站网友 返利网可信吗
19分钟前 发表
我们可以到文心一言进行帮助输入centos 7系统重切换yum镜像源到16