4.1 問題
本例要求學會使用yum命令查詢軟件包信息,完成下列任務:
1)列出軟件包名稱、版本信息
列出所有已安裝的軟件、所有未安裝但軟件源能提供的軟件包
檢查軟件 httpd、firefox、rar 是否已經安裝
2)查詢軟件包描述信息
瞭解軟件包 kernel、bash、wireshark 的用途
3)查詢哪些軟件包能提供指定的程序/文件
查詢命令程序 vim 由哪個軟件包提供
查詢文件 /etc/redhat-release 由哪個軟件包提供
4.2 步驟
實現此案例需要按照如下步驟進行。
步驟一:列出軟件包名稱、版本信息
1)列出所有已安裝的軟件
[root@svr7 ~]# yum list installed
.. ..
已安裝的軟件包
GConf2.x86_64 3.2.6-8.el7 @anaconda
GeoIP.x86_64 1.5.0-14.el7 @anaconda
ModemManager.x86_64 1.6.10-3.el7_6 @anaconda
ModemManager-glib.x86_64 1.6.10-3.el7_6 @anaconda
NetworkManager.x86_64 1:1.18.0-5.el7 @anaconda
NetworkManager-adsl.x86_64 1:1.18.0-5.el7 @anaconda
NetworkManager-glib.x86_64 1:1.18.0-5.el7 @anaconda
NetworkManager-libnm.x86_64 1:1.18.0-5.el7 @anaconda
.. ..
yum.noarch 3.4.3-163.el7.centos @anaconda
yum-langpacks.noarch 0.4.2-7.el7 @anaconda
yum-metadata-parser.x86_64 1.1.4-10.el7 @anaconda
yum-plugin-fastestmirror.noarch 1.1.31-52.el7 @anaconda
yum-utils.noarch 1.1.31-52.el7 @anaconda
zenity.x86_64 3.28.1-1.el7 @anaconda
zip.x86_64 3.0-11.el7 @anaconda
zlib.x86_64 1.2.7-18.el7 @anaconda
[root@svr7 ~]#
3)檢查軟件 httpd、firefox、rar 是否已經安裝
[root@svr7 ~]# yum list httpd
.. ..
可安裝的軟件包 //未安裝但可安裝的軟件
httpd.x86_64 2.4.6-90.el7.centos repo_cos7dvd
[root@svr7 ~]# yum list firefox
.. ..
已安裝的軟件包 //已安裝的軟件
firefox.x86_64 60.8.0-1.el7.centos @anaconda
[root@svr7 ~]# yum list rar
.. ..
錯誤:沒有匹配的軟件包可以列出 //未安裝且沒有源提供的軟件
步驟二:查詢軟件包描述信息
1)瞭解軟件包 kernel 的用途
軟件包kernel主要提供Linux的運行內核程序:
[root@svr7 ~]# yum info kernel
.. ..
已安裝的軟件包
名稱 :kernel
架構 :x86_64
版本 :3.10.0
發佈 :1062.el7
大小 :64 M
源 :installed
來自源:anaconda
簡介 : The Linux kernel
網址 :http://www.kernel.org/
協議 : GPLv2
描述 : The kernel package contains the Linux kernel (vmlinuz), the core of
: any Linux operating system. The kernel handles the basic functions
: of the operating system: memory allocation, process allocation,
: device input and output, etc.
2)瞭解軟件包 bash 的用途
軟件包bash主要爲Linux系統提供命令行解釋器程序(/bin/bash):
[root@svr7 ~]# yum info bash
.. ..
已安裝的軟件包
名稱 :bash
架構 :x86_64
版本 :4.2.46
發佈 :33.el7
大小 :3.5 M
源 :installed
來自源:anaconda
簡介 : The GNU Bourne Again shell
網址 :http://www.gnu.org/software/bash
協議 : GPLv3+
描述 : The GNU Bourne Again shell (Bash) is a shell or command language
: interpreter that is compatible with the Bourne shell (sh). Bash
: incorporates useful features from the Korn shell (ksh) and the C
: shell (csh). Most sh scripts can be run by bash without
: modification.
步驟三:查詢哪些軟件包能提供指定的程序/文件
1)查詢命令程序 vim 由哪個軟件包提供
可以獲知對應的軟件包名稱是 vim-enhanced:
[root@svr7 ~]# yum provides "*bin/vim"
.. ..
2:vim-enhanced-7.4.629-6.el7.x86_64 : A version of the VIM editor which
: includes recent enhancements
源 :repo_cos7dvd
匹配來源:
文件名 :/usr/bin/vim
2:vim-enhanced-7.4.629-6.el7.x86_64 : A version of the VIM editor which
: includes recent enhancements
源 :@anaconda
匹配來源:
文件名 :/usr/bin/vim
[root@svr7 ~]#
2)查詢命令程序 ifconfig 由哪個軟件包提供
可以獲知對應的軟件包名稱是 net-tools:
[root@svr7 ~]# yum provides /etc/redhat-release
.. ..
net-tools-2.0-0.25.20131004git.el7.x86_64 : Basic networking tools
源 :repo_cos7dvd
匹配來源:
文件名 :/sbin/ifconfig
net-tools-2.0-0.25.20131004git.el7.x86_64 : Basic networking tools
源 :@anaconda
匹配來源:
文件名 :/sbin/ifconfig
[root@svr7 ~]#