Fedora/Redhat在線安裝更新軟件包yum篇
在本文中,我們主要解介紹 Fedora core 4.0 通過軟件包管理工具yum來在線安裝更新軟件;關於apt工具應用,我們會在另外一篇中介紹;
一、 yum 的使用;
有些初學Linux的弟兄可能問,為什麼不用系統自帶的圖形化工具up2date來升級,卻要用 yum呢。其實大家用一用就知道了,up2date 真是奇慢無比,而且經常失去響應;造成機器假死的情況。所以我們還是試一試yum ;另外freshrpms.net 可能比官方站更快的更新升級源,也沒有理由不用 yum;
1、首先我們要到下面的地址下載與自己系統相對應的版本的 yum;
http://ayo.freshrpms.net/
比如我用的是Fedora core 4.0 就下載如下的包安裝;
[root@localhost beinan]# rpm -ivh freshrpms-release-1.1-1.fc.noarch.rpm
warning: freshrpms-release-1.1-1.fc.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e42d547b
Preparing... ########################################### [100%]
1:freshrpms-release ########################################### [100%]
2、安裝軟件舉例;
比如我要安裝能聽mp3的 bmp-mp3,只要輸入下面的命令行即可,系統就自己工作了;
[root@localhost beinan]# yum install bmp-mp3
內容全景如下:
[root@localhost beinan]# yum install bmp-mp3
Setting up Install Process
Setting up repositories
updates-released 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
base 100% |=========================| 1.1 kB 00:00
freshrpms 100% |=========================| 951 B 00:00
Reading repository metadata in from local files
primary.xml.gz 100% |=========================| 42 kB 00:03
freshrpms : ################################################## 122/122
Added 122 new packages, deleted 0 old in 0.72 seconds
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for bmp-mp3 to pack into transaction set.
bmp-mp3-0.9.7-1.2.fc4.i38 100% |=========================| 2.9 kB 00:00
---> Package bmp-mp3.i386 0:0.9.7-1.2.fc4 set to be updated
--> Running transaction check
--> Processing Dependency: libid3-3.8.so.3 for package: bmp-mp3
--> Processing Dependency: libbeep.so.2 for package: bmp-mp3
--> Processing Dependency: bmp >= 0.9.7 for package: bmp-mp3
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for id3lib to pack into transaction set.
id3lib-3.8.3-11.fc4.i386. 100% |=========================| 38 kB 00:05
---> Package id3lib.i386 0:3.8.3-11.fc4 set to be updated
---> Downloading header for bmp to pack into transaction set.
bmp-0.9.7-10.fc4.i386.rpm 100% |=========================| 14 kB 00:03
---> Package bmp.i386 0:0.9.7-10.fc4 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
bmp-mp3 i386 0.9.7-1.2.fc4 freshrpms 95 k
Installing for dependencies:
bmp i386 0.9.7-10.fc4 extras 912 k
id3lib i386 3.8.3-11.fc4 extras 752 k
Transaction Summary
=============================================================================
Install 3 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 1.7 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): id3lib-3.8.3-11.fc 100% |=========================| 752 kB 01:04
(2/3): bmp-0.9.7-10.fc4.i 100% |=========================| 912 kB 02:14
(3/3): bmp-mp3-0.9.7-1.2. 100% |=========================| 95 kB 00:05
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: bmp ######################### [1/3]
Installing: id3lib ######################### [2/3]
Installing: bmp-mp3 ######################### [3/3]
Installed: bmp-mp3.i386 0:0.9.7-1.2.fc4
Dependency Installed: bmp.i386 0:0.9.7-10.fc4 id3lib.i386 0:3.8.3-11.fc4
Complete!
注:yum優點:軟件包依賴關系自行解決,比如上面的,我們可以看到本來我們只安裝的是bmp-mp3,結果yum 安裝也安裝了 id3lib ;bmp
二、yum的一點小用法;
1、查詢軟件包;
面對成千上萬的軟件,我們可能無從下手,有時也不知道它的文件名;這時就要用到查詢;我們可以用 yum list 來列出yum升級源上的包有文件;然後我們再來查看 info
有以下幾個組合可以用;比如;
[root@localhost beinan]# yum list |more
加上一個管道 |,然後 more 一下,就能把所有的包分頁顯示出來。然後按一下空格鍵就能看下一頁了。在顯示的軟件列表中,會有軟件名稱、版本、是否安裝等;仔細的看一下吧。熟悉了就好了。也沒有什麼難的。
[root@localhost beinan]# yum list |more
Setting up repositories
Reading repository metadata in from local files
Installed Packages
4Suite.i386 1.0-8.b1 installed
Canna.i386 3.7p3-13 installed
Canna-devel.i386 3.7p3-13 installed
如果想知道軟件的詳細信息,可能得用上info參數了。比如:
用法:
[root@localhost beinan]# yum info 軟件名
比如:
[root@localhost beinan]# yum info bmp-mp3
Setting up repositories
updates-released 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
base 100% |=========================| 1.1 kB 00:00
freshrpms 100% |=========================| 951 B 00:00
Reading repository metadata in from local files
Installed Packages
Name : bmp-mp3
Arch : i386
Version: 0.9.7
Release: 1.2.fc4
Size : 234 k
Repo : freshrpms
Summary: MP3 playback plugin for the Beep Media Player
Description:
This package contains an MP3 playback plugin for BMP (Beep Media Player),
a media player that uses a skinned user interface based on Winamp 2.x skins,
and is based on ("forked off") XMMS.
在上面的例子中,如果Repo : freshrpms是這樣的,表示您的系統沒有安裝這個軟件,如果顯示的是:Repo : installed,表示已經安裝了。
查詢軟件包,也可以再加參數 grep ,比如我們想查詢升級源上是否有內核的新版本,則我們可以用下面的命令查詢;當然您也可以用 [root@localhost beinan]# yum search kernel |more ,也就是yum --help提供的參數,也是一樣的;
[root@localhost beinan]# yum list |grep kernel
我們看一下機器工作的結果,如下:
[root@localhost beinan]# yum list |grep kernel
GFS-kernel.i686 2.6.11.8-20050601.1526 installed
cman-kernel.i686 2.6.11.5-20050601.1526 installed
dlm-kernel.i686 2.6.11.5-20050601.1526 installed
gnbd-kernel.i686 2.6.11.2-20050420.1331 installed
kernel.i686 2.6.11-1.1369_FC4 installed
kernel-devel.i686 2.6.11-1.1369_FC4 installed
kernel-doc.noarch 2.6.11-1.1369_FC4 installed
GFS-kernel.i586 2.6.11.8-20050601.1526 base
GFS-kernel-debuginfo.i686 2.6.11.8-20050601.1526 updates-released
GFS-kernel-debuginfo.i586 2.6.11.8-20050601.1526 updates-released
GFS-kernel-smp.i686 2.6.11.8-20050601.1526 base
GFS-kernel-xen0.i686 2.6.11.8-20050601.1526 base
GFS-kernel-xenU.i686 2.6.11.8-20050601.1526 base
cman-kernel.i586 2.6.11.5-20050601.1526 updates-released
cman-kernel.i686 2.6.11.5-20050601.1526 updates-released
cman-kernel-debuginfo.i586 2.6.11.5-20050601.1526 updates-released
cman-kernel-debuginfo.i686 2.6.11.5-20050601.1526 updates-released
cman-kernel-smp.i686 2.6.11.5-20050601.1526 updates-released
cman-kernel-xen0.i686 2.6.11.5-20050601.1526 updates-released
cman-kernel-xenU.i686 2.6.11.5-20050601.1526 updates-released
dlm-kernel.i686 2.6.11.5-20050601.1526 updates-released
dlm-kernel.i586 2.6.11.5-20050601.1526 updates-released
dlm-kernel-debuginfo.i586 2.6.11.5-20050601.1526 updates-released
dlm-kernel-debuginfo.i686 2.6.11.5-20050601.1526 updates-released
dlm-kernel-smp.i686 2.6.11.5-20050601.1526 updates-released
dlm-kernel-xen0.i686 2.6.11.5-20050601.1526 updates-released
dlm-kernel-xenU.i686 2.6.11.5-20050601.1526 updates-released
gnbd-kernel.i686 2.6.11.2-20050420.1331 updates-released
gnbd-kernel.i586 2.6.11.2-20050420.1331 updates-released
gnbd-kernel-debuginfo.i586 2.6.11.2-20050420.1331 updates-released
gnbd-kernel-debuginfo.i686 2.6.11.2-20050420.1331 updates-released
gnbd-kernel-smp.i686 2.6.11.2-20050420.1331 updates-released
gnbd-kernel-xen0.i686 2.6.11.2-20050420.1331 updates-released
gnbd-kernel-xenU.i686 2.6.11.2-20050420.1331 updates-released
kernel.i586 2.6.12-1.1398_FC4 updates-released
kernel.i686 2.6.12-1.1398_FC4 updates-released
kernel-debuginfo.i686 2.6.12-1.1398_FC4 updates-released
kernel-debuginfo.i586 2.6.12-1.1398_FC4 updates-released
kernel-devel.i586 2.6.12-1.1398_FC4 updates-released
kernel-devel.i686 2.6.12-1.1398_FC4 updates-released
kernel-doc.noarch 2.6.12-1.1398_FC4 updates-released
kernel-smp.i686 2.6.12-1.1398_FC4 updates-released
kernel-smp-devel.i686 2.6.12-1.1398_FC4 updates-released
kernel-xen0.i686 2.6.12-1.1398_FC4 updates-released
kernel-xen0-devel.i686 2.6.12-1.1398_FC4 updates-released
kernel-xenU.i686 2.6.12-1.1398_FC4 updates-released
kernel-xenU-devel.i686 2.6.12-1.1398_FC4 updates-released
上面的確顯示出一大堆與內核有關的, installed表示我們的系統已經安裝了;
咱們看前一列吧,看一下名字就能猜個差不多;比如 doc 肯定和內核文檔有關了;smp是多處理器的內核;其它的我不懂了,請想知道的弟兄用 info來看吧。
比如我們用的機器是單處理器的X86機,想看一下是否有新內核可用。所以咱們試一下下面的這個。看是否已經有了新內核可以升級的;
[root@localhost beinan]# yum info kernel.i686
[root@localhost beinan]# yum info kernel.i686
Setting up repositories
updates-released 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
base 100% |=========================| 1.1 kB 00:00
freshrpms 100% |=========================| 951 B 00:00
Reading repository metadata in from local files
Installed Packages
Name : kernel
Arch : i686
Version: 2.6.11
Release: 1.1369_FC4
Size : 37 M
Repo : installed
Summary: Linux 內核(Linux 操作系統的核心)。
Description:
kernel 軟件包包含 Linux 內核 (vmlinuz),Red Hat Linux
操作系統的核心。內核處理操作系統的基本功能:
分配內存、處理分配、設備的輸入和輸出等等。
Available Packages
Name : kernel
Arch : i686
Version: 2.6.12
Release: 1.1398_FC4
Size : 14 M
Repo : updates-released
Summary: The Linux kernel (the core of the Linux operating system)
Description:
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.6.11的是已經安裝了,因為已經顯示的是Repo : installed ,下面還有一個Version: 2.6.12 ,告訴我們是Repo : updates-released,看來這個是升級用的了。
所以是否升級就看我們的了。
[root@localhost beinan]# yum update kernel
升級內核全景如下:
[root@localhost beinan]# yum update kernel
Setting up Upgrade Process
Setting up repositories
updates-released 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
base 100% |=========================| 1.1 kB 00:00
freshrpms 100% |=========================| 951 B 00:00
Reading repository metadata in from local files
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for kernel to pack into transaction set.
kernel-2.6.12-1.1398_FC4. 100% |=========================| 174 kB 00:18
---> Package kernel.i686 0:2.6.12-1.1398_FC4 set to be installed
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
kernel i686 2.6.12-1.1398_FC4 updates-released 14 M
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 14 M
Is this ok [y/N]:
是不是升級,只需要在 Is this ok [y/N]:行的後面輸入y或者N;y是yes,就是點頭同意的意思;N就是搖頭No的意思。
對於軟件包的查詢,還有,比如:
[root@localhost beinan]# yum list available 列出所有升級源上的包;
[root@localhost beinan]# yum list updates 列出所有升級源上的可以更新包;
[root@localhost beinan]# yum list installed 列出已經安裝的包;
yum 的命令支持通配符; 比如;
[root@localhost beinan]# yum list mp* |more
Setting up repositories
Reading repository metadata in from local files
Installed Packages
mpage.i386 2.5.4-5 installed
Available Packages
mpc.i386 0.11.2-3 extras
mpeg2dec.i386 0.4.0-5b.2.fc4 freshrpms
mpeg2dec-devel.i386 0.4.0-5b.2.fc4 freshrpms
mpg321.i386 0.2.10-6.2.fc4 freshrpms
mplayer.i386 1.0-0.16.pre7.2.fc4 freshrpms
mplayer-docs.i386 1.0-0.16.pre7.2.fc4 freshrpms
mplayer-fonts.noarch 1.1-3.fc freshrpms
mplayer-skins.noarch 1.7-1.fc freshrpms
[root@localhost beinan]#
2.安裝和升級軟件包;
安裝和升級分別是 install 和 update 參數;比如;
[root@localhost beinan]# yum update firefox
這樣我們就可以升級 firefox了。
[root@localhost beinan]# yum update firefox
Setting up Update Process
Setting up repositories
updates-released 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
base 100% |=========================| 1.1 kB 00:03
freshrpms 100% |=========================| 951 B 00:02
Reading repository metadata in from local files
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package firefox.i386 0:1.0.6-1.1.fc4 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Updating:
firefox i386 1.0.6-1.1.fc4 updates-released 18 M
Transaction Summary
=============================================================================
Install 0 Package(s)
Update 1 Package(s)
Remove 0 Package(s)
Total download size: 18 M
Is this ok [y/N]:
如果不加參數的 update 會是什麼呢??
[root@localhost beinan]# yum update
試著運行一下看看?會好長時間,對系統進行全面更新,我們要進行y和N了。
3.移除軟件包要用到remove參數;比如;
[root@localhost beinan]# yum remove bmp-mp3
內容全景如下:
[root@localhost beinan]# yum remove bmp-mp3
Setting up Remove Process
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package bmp-mp3.i386 0:0.9.7-1.2.fc4 set to be erased
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Removing:
bmp-mp3 i386 0.9.7-1.2.fc4 installed 234 k
Transaction Summary
=============================================================================
Install 0 Package(s)
Update 0 Package(s)
Remove 1 Package(s)
Total download size: 0
Is this ok [y/N]:
按y就移除了;
三、yum的圖形工具;
請參見: 《軟件在線升級更新yum 圖形工具介紹》
四、yum的幫助;
在論壇中有好多,有興趣的弟兄自己找找看吧;但也不要忘記了自救;呵。。。。
[root@localhost beinan]# yum --help
Usage: yum [options] < update | install | info | remove | list |
clean | provides | search | check-update | groupinstall |
groupupdate | grouplist | groupinfo | groupremove |
makecache | localinstall | shell >
Options:
-c [config file] - specify the config file to use
-e [error level] - set the error logging level
-d [debug level] - set the debugging level
-y - answer yes to all questions
-R [time in minutes] - set the max amount of time to randomly run in
-C run from cache only - do not update the cache
--installroot=[path] - set the install root (default '/')
--version - output the version of yum
--exclude=package to exclude
--disablerepo=repository id to disable (overrides config file)
--enablerepo=repository id to enable (overrides config file)
-h, --help - this screen
還有更厲害的幫助;
[root@localhost beinan]#man yum