linux下通过命令行安装yum

注意!

系统是centOS 7,手贱卸掉了yum,后面什么包都装不上了,开始想办法重新安装yum。废话不多说,每一条命令按顺序执行就行

先通过网址下载安装包,总共下四个,出现任何404 not FOUND,都是包发布了新版本,在地址: http://mirrors.163.com/centos/7/os/x86_64/Packages/ 查看新的版本号修改一下就行。

wget  http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget  http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget  http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget  http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-auto-update-debug-info-1.1.31-54.el7_8.noarch.rpm

再通过rpm顺序安装下载的包

rpm -ivh --force --nodeps python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh --force --nodeps yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh --force --nodeps yum-3.4.3-168.el7.centos.noarch.rpm
rpm -ivh --force --nodeps yum-plugin-auto-update-debug-info-1.1.31-54.el7_8.noarch.rpm

输入yum查看是否安装成功

Loaded plugins: auto-update-debuginfo
You need to give some command
Usage: yum [options] COMMAND

List of Commands:

check          Check for problems in the rpmdb
check-update   Check for available package updates
clean          Remove cached data
deplist        List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade      downgrade a package
erase          Remove a package or packages from your system
fs             Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot     Creates filesystem snapshots, or lists/deletes current snapshots.
groups         Display, or use, the groups information
help           Display a helpful usage message
history        Display, or use, the transaction history
info           Display details about a package or group of packages
install        Install a package or packages on your system
list           List a package or groups of packages
load-transaction load a saved transaction from filename
makecache      Generate the metadata cache
provides       Find what package provides the given value
reinstall      reinstall a package
repo-pkgs      Treat a repo. as a group of packages, so we can install/remove all of them
repolist       Display the configured software repositories
search         Search package details for the given string
shell          Run an interactive yum shell
swap           Simple way to swap packages, instead of using shell
update         Update a package or packages on your system
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo     Acts on repository update information
upgrade        Update packages taking obsoletes into account
version        Display a version for the machine and/or available repos.


Options:
  -h, --help            show this help message and exit
  -t, --tolerant        be tolerant of errors
  -C, --cacheonly       run entirely from system cache, don't update cache
  -c [config file], --config=[config file]
                        config file location
  -R [minutes], --randomwait=[minutes]
                        maximum command wait time
  -d [debug level], --debuglevel=[debug level]
                        debugging output level
  --showduplicates      show duplicates, in repos, in list/search commands
  -e [error level], --errorlevel=[error level]
                        error output level
  --rpmverbosity=[debug level name]
                        debugging output level for rpm
  -q, --quiet           quiet operation
  -v, --verbose         verbose operation
  -y, --assumeyes       answer yes for all questions
  --assumeno            answer no for all questions
  --version             show Yum version and exit
  --installroot=[path]  set install root
  --enablerepo=[repo]   enable one or more repositories (wildcards allowed)
  --disablerepo=[repo]  disable one or more repositories (wildcards allowed)
  -x [package], --exclude=[package]
                        exclude package(s) by name or glob
  --disableexcludes=[repo]
                        disable exclude from main, for a repo or for
                        everything
  --disableincludes=[repo]
                        disable includepkgs for a repo or for everything
  --obsoletes           enable obsoletes processing during updates
  --noplugins           disable Yum plugins
  --nogpgcheck          disable gpg signature checking
  --disableplugin=[plugin]
                        disable plugins by name
  --enableplugin=[plugin]
                        enable plugins by name
  --skip-broken         skip packages with depsolving problems
  --color=COLOR         control whether color is used
  --releasever=RELEASEVER
                        set value of $releasever in yum config and repo files
  --downloadonly        don't update, just download
  --downloaddir=DLDIR   specifies an alternate directory to store packages
  --setopt=SETOPTS      set arbitrary config and repo options
  --bugfix              Include bugfix relevant packages, in updates
  --security            Include security relevant packages, in updates
  --advisory=ADVS, --advisories=ADVS
                        Include packages needed to fix the given advisory, in
                        updates
  --bzs=BZS             Include packages needed to fix the given BZ, in
                        updates
  --cves=CVES           Include packages needed to fix the given CVE, in
                        updates
  --sec-severity=SEVS, --secseverity=SEVS
                        Include security relevant packages matching the
                        severity, in updates

结束

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 要在Linux命令行安装yum,您需要执行以下步骤: 1. 打开终端并以root用户身份登录。 2. 输入以下命令以安装yum: CentOS/RHEL 7及更高版本: ``` yum install -y yum-utils ``` CentOS/RHEL 6及更低版本: ``` rpm -Uvh http://mirror.centos.org/centos/6/os/x86_64/Packages/yum-utils-1.1.30-42.el6.noarch.rpm ``` 3. 安装完成后,您可以使用yum命令来安装其他软件包。例如,要安装Apache Web服务器,请输入以下命令: ``` yum install -y httpd ``` 4. 安装完成后,您可以使用以下命令启动Apache Web服务器: ``` systemctl start httpd ``` 这就是在Linux命令行安装yum的步骤。 ### 回答2: 作为Linux的一项关键功能,包管理器(Package Manager)扮演了至关重要的角色。内置的软件包管理器,如Yum,是Linux分发版中的一种标准工具,它有一个庞大的操作系统和其他重要的应用程序存储库,可以方便地安装、升级和移除软件包等。 下面将介绍如何在Linux中通过命令行安装和配置yum。 第一步:安装yum 首先,必须确认系统上是否已安装Yum。一种简单的方式是在终端中运行以下命令: yum -v 如果系统中已安装Yum,则将会显示其版本信息;如果未安装,则将会出现错误消息。 如果您发现系统中没有Yum,那么可以通过命令行安装Yum。终端窗口是一种可以用于在Linux中输入命令的窗口。您可以通过以下步骤在终端中安装Yum: 1.打开终端。 2.以root用户身份登录或使用sudo命令。 3.在命令行中输入以下命令:yum install yum-utils -y 这个命令将安装Yum。一旦安装完成,您就可以开始使用它来管理软件包。 第二步:配置yum 收到“Command not found”等错误提示时,有可能是因为系统没有正确配置Yum。因此,在使用Yum之前,最好先对其进行配置。下面介绍如何配置yum: 1.以root用户身份登录或使用sudo命令。 2.打开termal,并输入以下命令sudo vi /etc/yum.repos.d/CentOS-Base.repo 该命令将导致打开CentOS-Base.repo文件。 3.找到 “[base]”、“[updates]”、“[extras]”、“[centosplus]” 和 “[contrib]”五个标记,并确保所有的启用设置(enabled=1)全部为“1”。 4.保存并退出该文件(保存并退出,qa!)。 5.运行此命令以清除任何现有 yum 缓存: yum clean all 6.运行此命令以更新 yum: yum makecache fast 您现在已经按照自己的需求正确地配置了yum,可以使用yum命令向系统中安装它所需的软件包和更新。 ### 回答3: Yum是一种基于RPM(Red Hat Package Manager)的包管理工具,用于在Linux系统中安装、升级和删除软件包。在Linux命令行安装Yum需要以下步骤: 1. 下载Yum安装包 在浏览器中打开Yum的官方网站(http://yum.baseurl.org/),找到相应的安装包并下载。如果你的Linux系统是基于Red Hat、CentOS等发行版的话,则可以使用以下命令从官方源中下载: wget http://yum.baseurl.org/download/3.4/yum-3.4.3.tar.gz 2. 解压安装包并进入安装目录 使用以下命令解压下载的安装包: tar -zxvf yum-3.4.3.tar.gz 解压后会生成一个yum-3.4.3的目录,使用cd命令进入该目录: cd yum-3.4.3 3. 安装Yum 使用以下命令安装Yum: python setup.py install 如果出现以下错误信息: Traceback (most recent call last): File "setup.py", line 23, in ? from distutils.core import setup ImportError: No module named distutils.core 说明你的系统缺少Python的distutils核心模块,需要先安装该模块: yum install python-devel 4. 配置Yum Yum的配置文件yum.conf一般位于/etc目录下,可以使用以下命令打开该文件: vi /etc/yum.conf 在该文件中可以添加各种配置参数,比如设置Yum的镜像源等。 至此,Yum命令行安装就完成了。可以使用以下命令测试Yum是否安装成功: yum list 如果输出了系统中已安装的软件包列表,则表明Yum已经成功安装并工作正常。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值