轉自:http://songzj.iteye.com/blog/1920773mysql
第一次翻譯外文,若有不正確之處請指出. 至於版權, 應該是屬於原做者吧. 鬧球不清.linux
在linux環境中, 安裝, 卸載更新包是一個極爲常見的操做.大部分的linux環境都提供了包的管理工具, 例如:apt-get, dpkg, rpm, yum等等.sql
一些Linux環境中,yum是默認的包管理工具.Yum是Yellowdog Updater Modified的簡稱.shell
該文章闡釋了常常被使用到yum命令的15個場景.數據庫
1> 使用yum install 安裝包.vim
要安裝一個包,使用 'yum install 包名'. 該命令將會自動的安裝該包的依賴.less
# yum install postgresql.x86_64 Resolving Dependencies Install 2 Package(s) Is this ok [y/N]: y Package(s) data still to download: 3.0 M (1/2): postgresql-9.0.4-5.fc15.x86_64.rpm | 2.8 MB 00:11 (2/2): postgresql-libs-9.0.4-5.fc15.x86_64.rpm | 203 kB 00:00 ------------------------------------------------------------------ Total 241 kB/s | 3.0 MB 00:12 Running Transaction Installing : postgresql-libs-9.0.4-5.fc15.x86_64 1/2 Installing : postgresql-9.0.4-5.fc15.x86_64 2/2 Complete!
默認的'yum install'命令, 將會在安裝這些包以前 提示你"接受"或"放棄", 若是想要使用yum自動安裝包,而不對你進行提示. 使用 -y 選項. 以下所示:ide
2> 使用yum remove 卸載包.工具
以下所示:使用'yum remove 包名' 命令卸載包.post
# yum remove postgresql.x86_64 Resolving Dependencies ---> Package postgresql.x86_64 0:9.0.4-5.fc15 will be erased Is this ok [y/N]: y Running Transaction Erasing : postgresql-9.0.4-5.fc15.x86_64 1/1 Removed: postgresql.x86_64 0:9.0.4-5.fc15 Complete!
3> 使用 'yum update'命令升級已存在的包.
若是你的系統中存在一箇舊版本的包, 使用'yum update 包名' 可使它升級到最新版本. 固然,這個命令也會自動的找出並安裝該報的全部必須的依賴.
# yum update postgresql.x86_64
4> 使用'yum search'命令查找包.
若是你不知道你想要安裝的包的準確包名, 可使用'yum search 關鍵字', 他將會搜索並列出匹配你的'關鍵字'的全部記錄.
下面的實例是在yum的資源庫中搜索全部匹配關鍵字'firefox'的包, 而且將其羅列出來.
# yum search firefox Loaded plugins: langpacks, presto, refresh-packagekit ============== N/S Matched: firefox ====================== firefox.x86_64 : Mozilla Firefox Web browser gnome-do-plugins-firefox.x86_64 : gnome-do-plugins for firefox mozilla-firetray-firefox.x86_64 : System tray extension for firefox mozilla-adblockplus.noarch : Adblocking extension for Mozilla Firefox mozilla-noscript.noarch : JavaScript white list extension for Mozilla Firefox Name and summary matches only, use "search all" for everything.
5> 使用'yum info' 查看包的額外信息.
一旦你使用yum search搜索到了一個包, 你就可使用'yum info 包名' 來查看該包的額外信息.
下面的例子展現了 'samba-common'包的額外信息.
# yum info samba-common.i686 Loaded plugins: langpacks, presto, refresh-packagekit Available Packages Name : samba-common Arch : i686 Epoch : 1 Version : 3.5.11 Release : 71.fc15.1 Size : 9.9 M Repo : updates Summary : Files used by both Samba servers and clients URL : http://www.samba.org/ License : GPLv3+ and LGPLv3+ Description : Samba-common provides files necessary for both the server and client : packages of Samba.
6> 使用yum list 查看全部可見包.
下面的命令將會列出yum 數據庫中全部的可見包.
# yum list | less
7> 使用 yum list installed 查看你本身系統中已經安裝的包.
# yum list installed | less
8> 使用'yum provides 文件名' 能夠查看該文件屬於哪一個包.
若是你想知道某個文件屬於哪一個包, 使用'yum provides'. 例如, 如想要知道 /etc/sysconfig/nfs 文見屬於哪一個包.可使用以下命令.
# yum provides /etc/sysconfig/nfs Loaded plugins: langpacks, presto, refresh-packagekit 1:nfs-utils-1.2.3-10.fc15.x86_64 : NFS utilities and supporting clients and : daemons for the kernel NFS server Repo : fedora Matched from: Filename : /etc/sysconfig/nfs 1:nfs-utils-1.2.4-1.fc15.x86_64 : NFS utilities and supporting clients and : daemons for the kernel NFS server Repo : updates Matched from: Filename : /etc/sysconfig/nfs 1:nfs-utils-1.2.4-1.fc15.x86_64 : NFS utilities and supporting clients and : daemons for the kernel NFS server Repo : installed Matched from: Other : Provides-match: /etc/sysconfig/nfs
9> 使用yum grouplist 查看可見的"軟件集合",
在yum 中,在一個指定的軟件集合中,一些有關係的包被歸類在一塊兒, 你能夠簡單滴安裝整個"軟件集合"來安裝全部該集合下的全部包, 而不是一個個的搜索和安裝每一個獨立的包.
以下所示. 你能夠執行"yum grouplist"來查看全部可見的"軟件集合", 列出的三個已安裝"集合"有, 已安裝語言, 可見"軟件集合."
# yum grouplist Installed Groups: Administration Tools Base Design Suite .... Installed Language Groups: Arabic Support [ar] Armenian Support [hy] Bengali Support [bn] .... Available Groups: Authoring and Publishing Books and Guides Clustering DNS Name Server Development Libraries Development Tools Directory Server Dogtag Certificate System ...
10> 使用"yum groupinstall" 安裝指定的"軟件集合".
以下示例中使用了'yum groupinstall' 功能來安裝指定的軟件集合 "DNS Name Server" 集合包含了bind 和bind-chroot.
# yum groupinstall 'DNS Name Server' Dependencies Resolved Install 2 Package(s) Is this ok [y/N]: y Package(s) data still to download: 3.6 M (1/2): bind-9.8.0-9.P4.fc15.x86_64.rpm | 3.6 MB 00:15 (2/2): bind-chroot-9.8.0-9.P4.fc15.x86_64.rpm | 69 kB 00:00 ----------------------------------------------------------------- Total 235 kB/s | 3.6 MB 00:15 Installed: bind-chroot.x86_64 32:9.8.0-9.P4.fc15 Dependency Installed: bind.x86_64 32:9.8.0-9.P4.fc15 Complete!
說明: 固然咱們會稍後討論如何使用yum groupinstall 安裝mysql 數據庫.
原文連接.http://www.thegeekstuff.com/2010/04/yum-groupinstall-mysql-database/
11>使用"yum groupupdate" 升級已存在的軟件集合.
若是你已經使用 yum groupinstall 安裝用了一個"軟件集合",而後想要把它升級到最新的版本. 你可使用以下命令.
# yum groupupdate 'Graphical Internet' Dependencies Resolved Upgrade 5 Package(s) Is this ok [y/N]: y Running Transaction Updating : evolution-data-server-3.0.2-1.fc15.x86_64 1/10 Updating : evolution-3.0.2-3.fc15.x86_64 2/10 Updating : evolution-NetworkManager-3.0.2-3.fc15.x86_64 3/10 Updating : evolution-help-3.0.2-3.fc15.noarch 4/10 Updating : empathy-3.0.2-3.fc15.x86_64 5/10 Cleanup : evolution-NetworkManager-3.0.1-1.fc15.x86_64 6/10 Cleanup : evolution-help-3.0.1-1.fc15.noarch 7/10 Cleanup : evolution-3.0.1-1.fc15.x86_64 8/10 Cleanup : empathy-3.0.1-3.fc15.x86_64 9/10 Cleanup : evolution-data-server-3.0.1-1.fc15.x86_64 10/10 Complete!
12: 使用"yum groupremove" 來卸載軟件集合.
好不容易裝上了, 又升級到最新版本了. 又要卸載掉.有病吧.^_^.......
# yum groupremove 'DNS Name Server' Dependencies Resolved Remove 2 Package(s) Is this ok [y/N]: y Running Transaction Erasing : 32:bind-chroot-9.8.0-9.P4.fc15.x86_64 1/2 Erasing : 32:bind-9.8.0-9.P4.fc15.x86_64 2/2 Complete!
13> 使用"yum repolist"列出你當前的yum 資源庫.
全部的yum命令"依賴"這一個或者多個yum資源庫. 執行'yum repolist' 能夠查看你係統中全部的yum資源庫配置信息.
以下所列的只有可用的資源庫.
# yum repolist repo id repo name status fedora Fedora 15 - x86_64 24,085 updates Fedora 15 - x86_64 - Updates 5,612
若是想要查看全部的包含"可用"和"不可用"資源庫, 使用"yum repolist all"
# yum repolist all repo id repo name status fedora Fedora 15 - x86_64 enabled: 24,085 fedora-debuginfo Fedora 15 - x86_64 - Debug disabled fedora-source Fedora 15 - Source disabled rawhide-debuginfo Fedora - Rawhide - Debug disabled rawhide-source Fedora - Rawhide - Source disabled updates Fedora 15 - x86_64 - Updates enabled: 5,612 updates-debuginfo Fedora 15 - x86_64 - Updates - Debug disabled updates-source Fedora 15 - Updates Source disabled updates-testing Fedora 15 - x86_64 - Test Updates disabled updates-testing-debuginfo Fedora 15 - x86_64 - Test Updates Debug disabled updates-testing-source Fedora 15 - Test Updates Source disabled
若是想要查看不可用資源庫. 使用 "yum repositories disabled"
14> 從不可用的資源庫安裝, 可用使用"yum -enablerepo"
yum默認的會從可用的資源庫中安裝文件. 不過某些緣由下,你必須從不可用的資源庫安裝它, 那麼你可使用
-enablerepo參數.以下所示.
# yum --enablerepo=fedora-source install vim-X11.x86_64 Dependencies Resolved Install 1 Package(s) Is this ok [y/N]: y Running Transaction Installing : 2:vim-X11-7.3.138-1.fc15.x86_64 1/1 Complete!
15> 使用Yum Shell 的方式來執行yum命令.
yum支持使用yum shell的方式來運行多個yum命令.
# yum shell Setting up Yum Shell > info samba.x86_64 Available Packages Name : samba Arch : x86_64 Epoch : 1 Version : 3.5.11 Release : 71.fc15.1 Size : 4.6 M Repo : updates Summary : Server and Client software to interoperate with Windows machines URL : http://www.samba.org/ License : GPLv3+ and LGPLv3+ Description : : Samba is the suite of programs by which a lot of PC-related : machines share files, printers, and other information (such as : lists of available files and printers). The Windows NT, OS/2, and : Linux operating systems support this natively, and add-on packages : can enable the same thing for DOS, Windows, VMS, UNIX of all : kinds, MVS, and more. This package provides an SMB/CIFS server : that can be used to provide network services to SMB/CIFS clients. : Samba uses NetBIOS over TCP/IP (NetBT) protocols and does NOT : need the NetBEUI (Microsoft Raw NetBIOS frame) protocol. >
固然, yum也能夠從一個text文件中讀取命令,而後一行行的執行, 對於你有多個系統的時候是很是有用的.
建立一個包含這些命令的text文件,而後使用 'yum shell'來執行這些命令, 而沒必要再每一個系統上執行同樣的命令.
# cat yum_cmd.txt repolist info nfs-utils-lib.x86_64 # yum shell yum_cmd.txt repo id repo name status fedora Fedora 15 - x86_64 24,085 updates Fedora 15 - x86_64 - Updates 5,612 Available Packages Name : nfs-utils-lib Arch : x86_64 Version : 1.1.5 Release : 5.fc15 Size : 61 k Repo : fedora Summary : Network File System Support Library URL : http://www.citi.umich.edu/projects/nfsv4/linux/ License : BSD Description : Support libraries that are needed by the commands and : daemons the nfs-utils rpm. Leaving Shell