是否有一些簡單的 yum 命令,以便我可以知道要更新的軟體包的當前版本和未來版本。
我現在關於:
yum list updates
但這只會列印新版本的軟體包......
答案1
要列出所有已安裝的軟體包,您可以使用:
# yum list installed
對於特定的包,請嘗試以下操作:
# yum info httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.vietoss.com
* epel: ftp.cuhk.edu.hk
* extras: mirror.vietoss.com
* rpmforge: ftp-stud.fht-esslingen.de
* updates: mirror.vietoss.com
Installed Packages
Name : httpd
Arch : x86_64
Version : 2.2.3
Release : 43.el5.centos
Size : 3.3 M
Repo : installed
Summary : Apache HTTP Server
URL : http://httpd.apache.org/
License : Apache Software License
Description: The Apache HTTP Server is a powerful, efficient, and extensible
: web server.
Available Packages
Name : httpd
Arch : x86_64
Version : 2.2.3
Release : 53.el5.centos.3
Size : 1.2 M
Repo : updates
Summary : Apache HTTP Server
URL : http://httpd.apache.org/
License : Apache Software License
Description: The Apache HTTP Server is a powerful, efficient, and extensible
: web server.
# yum list httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.vietoss.com
* epel: ftp.cuhk.edu.hk
* extras: mirror.vietoss.com
* rpmforge: ftp-stud.fht-esslingen.de
* updates: mirror.vietoss.com
Installed Packages
httpd.x86_64 2.2.3-43.el5.centos installed
Available Packages
httpd.x86_64 2.2.3-53.el5.centos.3 updates
答案2
如果您想更多地編寫腳本,直接退出 rpm 可能會更容易。您可以透過執行下列操作來取得已安裝的軟體包及其版本的清單:
rpm -qa --queryformat "%{NAME} %{VERSION}\n"
。
您可以執行rpm --querytags
找出可以放入 %{VARIABLES} 中的所有內容。此格式採用像 printf 一樣的參數(例如 \n 表示換行符號或 \t 表示製表符)。