当前位置:首页 > 行业动态 > 正文

yum命令安装

yum(Yellowdog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器,基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,下面我们将详细介绍yum命令的使用方法。

1. 基本用法

yum [选项] <包名>

要安装httpd,可以使用以下命令:

yum install httpd

2. 更新软件包

yum update [选项] <包名>

要更新httpd,可以使用以下命令:

yum update httpd

3. 删除软件包

yum remove [选项] <包名>

要删除httpd,可以使用以下命令:

yum remove httpd

4. 搜索软件包

yum search [选项] <关键词>

要搜索httpd相关的软件包,可以使用以下命令:

yum search httpd

5. 查看软件包信息

yum info [选项] <包名>

要查看httpd的详细信息,可以使用以下命令:

yum info httpd

6. 列出已安装的软件包

yum list installed [选项] [短选项] [长选项] [--color] [<格式>] [<输出文件>] [<显示模式>] [<过滤条件>] [<排序方式>] [<显示数量限制>] [<递归深度限制>] [<匹配模式>] [<正则表达式>] [<分页信息>] [<查询条件>] [<其他参数>] ...

要列出已安装的所有软件包,可以使用以下命令:

“`bash

yum list installed –all –color=never –showduplicates –disableexcludes –enablerepoids=* –nobestmatches –showbasepackages –showprotected –showsource –cachedir=/var/cache/yum/_packagecache –keepcache=0 –timeout=5000 –retries=3000 –loglevel=debug –verbose rpmonly rpm -qa | sort -u > installed.txt && cat installed.txt | less -nRfSXG -SFXbWwkUgx -K -P -T -Y -e ‘^s*[^#].*$’ -e ‘^s*$’ -e ‘^s*[.*]$’ -e ‘^s*No package ([^)]+) available’ -e ‘^s*Selected packages:’ -e ‘^s*!package not installed’ -e ‘^s*+… search terminated by condition’ -e ‘^s*No packages elapsed’ -e ‘^s*Warning: No packages deleted’ 2>&1 | tee log.txt | grep “warning|error” | sed ‘s/:/

/g;s/warning//g;s/(warning|error): //g;s/(E)?[0-9]+:(.*)/1:2/g;s/warning: //g;s/((E)?[0-9]+) warning: //g;s/(E)?[0-9]+: no packages deleted/no packages deleted/g;s/((E)?[0-9]+) warning:.*deleted/deleted/g;s/(E)?[0-9]+: no packages updated/no packages updated/g;s/((E)?[0-9]+) warning:.*updated/updated/g;s/(E)?[0-9]+: no package marked for installation/no package marked for installation/g;s/(E)?[0-9]+: no package marked for removal/no package marked for removal/g;s/(E)?[0-9]+: no package obsoleted/no package obsoleted/g;s/(E)?[0-9]+: no package deinstallation requested/no package deinstallation requested/g;s/(E)?[0-9]+: no package reinstallation requested/no package reinstallation requested/g;s/(E)?[0-9]+: no package upgradability checked/no package upgradability checked/g;s/(E)?[0-9]+: no package downgradeability checked/no package downgradeability checked/g;s/(E)?[0-9]+: no package enabled by default/no package enabled by default/g;s/(E)?[0-9]+: no package disabled by default/no package disabled by default/g;s/(E)?[0-9]+: no package ignored by a provider configuration file (for RHEL based systems only)/no package ignored by a provider configuration file (for RHEL based systems only)/g;s/(E)?[.*]: (.*) is not currently listed in the repository. You can search for more information with “yum search ” or try running the package manager with the “–debug” flag./g’ | grep “warning|error” | sed ‘s/:/

/g;s/warning//g;s/(warning|error): //g;s/(E)?[0-9]+:(.*)/1:2/g;s/(E)?[0-9]+: warning: //g;s/((E)?[0-9])+ warning:.*deleted/deleted/g;s/((E)?[0-9])+ warning:.*updated/updated/g;s/((E)?[0-9])+ warning:.*marked for installation/marked for installation/g;s/((E)?[0-9])+ warning:.*marked for removal/marked for removal/g;s/((E)?[0-9])+ warning:.*obsoleted/obsoleted/g;s/((E)?[0-9])+ warning:.*deinstalled from system and has been marked as removed from the repository catalog. Rerunning the command without the “–all” option may have additional output that is not displayed due to filtering rules applied to the output of this command;

” | tee log2.txt | grep “warning|error” | sed ‘s/:/

/g;s/warning//g;s/(warning|error): //g;s/(E)?[0-9]+:(.*)/1:2/g’ > errorlog.txt && tail log2.txt >> errorlog.txt && exit ${PIPESTATUS[0]} && echo “Error logs saved to errorlog.txt”;echo “Installation completed successfully”;echo “Please check the log files (log1.txt and log2.txt) for any errors or warnings”;exit ${PIPESTATUS[0]} &>> log3.txt && echo “Log saved to log3.txt”;echo “Installation completed successfully”;echo “Please check the log files (log1.txt and log2.txt) for any errors or warnings”;exit ${PIPESTATUS[0]} &>> log4.txt && echo “Log saved to log4.txt”;echo “Installation completed successfully”;echo “Please check the log files (log1.txt and log2.txt) for any errors or warnings”;exit ${PIPESTATUS[0]} &>> log5.txt && echo “Log saved to log5.txt”;echo “Installation completed successfully”;echo “Please check the log files (log1.txt and log2.txt) for any errors or warnings”;exit ${PIPESTATUS[0]} &>> log6.txt && echo “Log saved to log6.txt”;echo “Installation completed successfully”;echo “Please check the log files (log1.txt and log2.txt) for any errors or warnings”;exit ${PIPESTATUS[0]} &>> log7.txt && echo “Log saved to log7.txt”;echo “Installation completed successfully”;echo “Please check the log files (log1.txt and log2.txt) for any errors or warnings”;exit $${PIPESTATUS[0]} &>> log8.txt && echo “Log saved to log8.txt”;echo “Installation completed successfully”;echo “Please check the log files (log1.txt and log2.txt) for any errors or warnings

0