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


yum [选项] <包名>
要安装httpd,令安可以使用以下命令:

yum install httpd
2. 更新软件包
yum update [选项] <包名>
要更新httpd,可以使用以下命令:
yum update httpd
3. 删除软件包
yum remove [选项] <包名>
要删除httpd,可以使用以下命令:
yum remove httpd4. 搜索软件包
yum search [选项] <关键(jian)词>
要搜索httpd相关的软件包,可以使用(yong)以下命令:
yum search httpdyum info [选项] <包名>
要(yao)查看httpd的令安详细信息,可以使用以下命令:
yum info httpd6. 列出已安装的令安软件包
yum list installed [选项] [短选项] [长选项] [--color] [<格式>] [<输出文件>] [<显示模式>] [<过滤条件>] [<排序方式>] [<显示数量限制>] [<递归深度限制>] [<匹配模式>] [<正则表达式>] [<分页信息>] [<查询条件>] [<其他(ta)参(can)数(shu)>] ...
要列出已安装的所有软件包,可以使用以下命令:
“`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="checked"/no package upgradability checked/g;s/(E)?[0-9]+: no package downgradeability checked/no package downgradeability checked='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="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