文件系统:使用 yum 安装软件包
前些天發現了一個巨牛的人工智能學習網站,通俗易懂,風趣幽默,忍不住分享一下給大家。點擊跳轉到教程。
一、yum命令的基本安裝功能
[root@localhost?~]#?man?yum
command?is?one?of:
?*?install?package1?[package2]?[...]:??install?+?包名
yum?-y:?安裝時自動回答為yes?
?
*?reinstall?package1?[package2]?[...]:?重新安裝
?
***?補充rmp命令:rpm?-ql?+?包名?:?查詢包安裝生成的文件清單
?rpm?-qf?+?/path/to/file_name:?查詢某文件是由哪個軟件包生成的
*?provides?|?whatprovides?feature1?[feature2]?[...]
使用yum來查詢軟件包生成哪些文件,以及文件是由哪個軟件包生成的。
?
*?update?[package1]?[package2]?[...]:?升級版本,可加多個包
*?update-to?[package1]?[package2]?[...]:?指定升級到哪個版本
?
*?downgrade?package1?[package2]?[...]?:?降級
?
*?check-update:?安裝前檢查有哪些可以升級的軟件包
????????
*?upgrade?[package1]?[package2]?[...]
*?upgrade-to?[package1]?[package2]?[...]
????這兩個命令已經被update取代了
?
*?remove?|?erase?package1?[package2]?[...]
????清除軟件包:使用yum來清除包會同時清除它被依賴的包
?
*?search?string1?[string2]?[...]?:?只記得部分字符,可以進行模糊查詢
???????
*?groupinstall?group1?[group2]?[...]?:組安裝:?
????1)?針對RHEL?6:
????Development?tools?+?Server?Platform?Development?+?Desktop?Platform?Development?
????2)?針對RHEL?5:?
????Development?tools?+?development?libraries
?安裝了這些這些組之后,就可以編譯rpm包了,即將源碼制作成二進制格式包
????*?groupupdate?group1?[group2]?[...]?升級組??????
????*?groupremove?group1?[group2]?[...]?移除組??????
?
*?localinstall?yum除了可以自動安裝外,也可以將軟件包下載到本地,然后手動安裝
??1)RHEL?6:?
統一使用yum?install?來安裝即可
????2)RHEL?5:?
????需要使用yum?localinstall?來安裝,同樣手動升級可以使用yum?localupdate,RHEL6處于兼容性需求,也支持這樣的用法。
? yum安裝軟件包最大的優勢在于可以自動解決依賴關系
?
--?nogpgcheck?:?
對比rpm包,yum即使使用了localinstall,也會檢查軟件包的來源合法性,如果密鑰無法匹配,則下載到本地的軟件包也無法使用yum安裝,故可以使用長選項?--nogpgcheck來避免檢查
?
*?history?:?查看此前的安裝卸載等操作歷史
?
二、yum命令安裝實例演示
/*--------?(1)?基本安裝?--------*/
[root@localhost?~]#?yum?install?bind-chroot
| 1 2 3 4 5 6 | Loaded?plugins:?fastestmirror,?refresh-packagekit,?security Loading?mirror?speeds?from?cached?hostfile Setting?up?Install?Process Package?32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64?already?installed?and?latest?version Nothing?to?do #?已經安裝了最新版,無需安裝 |
?
?
現在先卸載這個軟件包
[root@localhost?~]#?rpm?-e?bind-chroot
| 1 | grep:?/etc/sysconfig/named:?No?such?file?or?directory |
?
[root@localhost?~]#?rpm?-e?bind-chroot?--force
| 1 | rpm:?only?installation,?upgrading,?rmsource?and?rmspec?may?be?forced |
?
[root@localhost?~]#?rpm?-e?bind-chroot
| 1 | error:?package?bind-chroot?is?not?installed |
?
?
[root@localhost?~]#?yum?install?bind-chroot
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | Loaded?plugins:?fastestmirror,?refresh-packagekit,?security Loading?mirror?speeds?from?cached?hostfile Setting?up?Install?Process Resolving?Dependencies -->?Running?transaction?check --->?Package?bind-chroot.x86_64?32:9.8.2-0.17.rc1.el6_4.6?will?be?installed -->?Processing?Dependency:?bind?=?32:9.8.2-0.17.rc1.el6_4.6?for?package:?32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64 -->?Running?transaction?check --->?Package?bind.x86_64?32:9.8.2-0.17.rc1.el6_4.6?will?be?installed -->?Finished?Dependency?Resolution #依賴關系自動解決 ?? Dependencies?Resolved ?? ============================================================================= ?Package??????????????????Arch????????????????Version??????????????????????????????????Repository?????????Size ============================================================================== Installing: ?bind-chroot??????????????x86_64??????????????32:9.8.2-0.17.rc1.el6_4.6????????????????base???????????????71?k Installing?for?dependencies: ?bind?????????????????????x86_64??????????????32:9.8.2-0.17.rc1.el6_4.6????????????????base??????????????4.0?M ?? Transaction?Summary ========================================================================= Install???????2?Package(s) ?? Total?download?size:?4.0?M Installed?size:?7.3?M Is?this?ok?[y/N]:? ?? #?輸入y表示安裝,N表示不安裝,默認為不安裝,yum可以使用-y自動回答安裝 ?? Is?this?ok?[y/N]:?y Downloading?Packages: -------------------------------------------------------------------------------- Total???????????????????????????????????????????????????????????????????????????42?MB/s?|?4.0?MB?????00:00????? Running?rpm_check_debug Running?Transaction?Test Transaction?Test?Succeeded Running?Transaction Warning:?RPMDB?altered?outside?of?yum. ??Installing?:?32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64???????????????????????????????????????????????????????1/2? ??Installing?:?32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64????????????????????????????????????????????????2/2? ??Verifying??:?32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64???????????????????????????????????????????????????????1/2? ??Verifying??:?32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64????????????????????????????????????????????????2/2? ?? Installed: ??bind-chroot.x86_64?32:9.8.2-0.17.rc1.el6_4.6????????????????????????????????????????????????????????????????? ?? Dependency?Installed: ??bind.x86_64?32:9.8.2-0.17.rc1.el6_4.6???????????????????????????????????????????????????????????????????????? ?? Complete! |
?
?
?
/*--------?(2)?重新安裝?--------*/
?
[root@localhost?~]#?yum?install?bind
| 1 2 3 4 5 6 | Loaded?plugins:?fastestmirror,?refresh-packagekit,?security Loading?mirror?speeds?from?cached?hostfile Setting?up?Install?Process Package?32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64?already?installed?and?latest?version Nothing?to?do #?提示已經安裝過了 |
?
[root@localhost?~]#?yum?reinstall?bind
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #?不論是否安裝,都會重新安裝一遍 Loaded?plugins:?fastestmirror,?refresh-packagekit,?security Setting?up?Reinstall?Process Loading?mirror?speeds?from?cached?hostfile Resolving?Dependencies -->?Running?transaction?check --->?Package?bind.x86_64?32:9.8.2-0.17.rc1.el6_4.6?will?be?reinstalled -->?Finished?Dependency?Resolution ?? Dependencies?Resolved ?? ============================================================================ ?Package?????????????Arch??????????????????Version???????????????????????????????????Repository???????????Size =========================================================================== Reinstalling: ?bind????????????????x86_64????????????????32:9.8.2-0.17.rc1.el6_4.6?????????????????base????????????????4.0?M ?? Transaction?Summary =============================================================================== Reinstall?????1?Package(s) ?? Total?download?size:?4.0?M Installed?size:?7.3?M Is?this?ok?[y/N]:?y Downloading?Packages: Running?rpm_check_debug Running?Transaction?Test Transaction?Test?Succeeded Running?Transaction ??Installing?:?32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64???????????????????????????????????????????????????????1/1? ??Verifying??:?32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64???????????????????????????????????????????????????????1/1? ?? Installed: ??bind.x86_64?32:9.8.2-0.17.rc1.el6_4.6???????????????????????????????????????????????????????????????????????? ?? Complete! |
?
?
?
/*--------?(3)?卸載軟件包?--------*/
[root@localhost?~]#?yum?remove?bind
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | Loaded?plugins:?fastestmirror,?refresh-packagekit,?security Setting?up?Remove?Process Resolving?Dependencies -->?Running?transaction?check --->?Package?bind.x86_64?32:9.8.2-0.17.rc1.el6_4.6?will?be?erased -->?Processing?Dependency:?bind?=?32:9.8.2-0.17.rc1.el6_4.6?for?package:?32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64 -->?Running?transaction?check --->?Package?bind-chroot.x86_64?32:9.8.2-0.17.rc1.el6_4.6?will?be?erased -->?Finished?Dependency?Resolution ?? Dependencies?Resolved ?? ================================================================================ ?Package??????????????????Arch????????????????Version?????????????????????????????????Repository??????????Size ============================================================================== Removing: ?bind?????????????????????x86_64??????????????32:9.8.2-0.17.rc1.el6_4.6???????????????@base??????????????7.3?M Removing?for?dependencies: ?bind-chroot??????????????x86_64??????????????32:9.8.2-0.17.rc1.el6_4.6???????????????@base??????????????0.0?? ?#?清除bind的同時會清除bind-chroot,因為bind-chroot是依賴于bind的 ?? Transaction?Summary ============================================================================== Remove????????2?Package(s) ?? Installed?size:?7.3?M Is?this?ok?[y/N]:?y Downloading?Packages: Running?rpm_check_debug Running?Transaction?Test Transaction?Test?Succeeded Running?Transaction ??Erasing????:?32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64????????????????????????????????????????????1/2? ??Erasing????:?32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64????????????2/2? warning:?/etc/sysconfig/named?saved?as?/etc/sysconfig/named.rpmsave ??Verifying??:?32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64???????????????????????????????????????????????????????1/2? ??Verifying??:?32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64????????????????????????????????????????????????2/2? ?? Removed: ??bind.x86_64?32:9.8.2-0.17.rc1.el6_4.6???????????????????????????????????????????????????????????????????????? ?? Dependency?Removed: ??bind-chroot.x86_64?32:9.8.2-0.17.rc1.el6_4.6????????????????????????????????????????????????????????????????? ?? Complete! |
?
?
?
/*--------?(4)軟件包安裝信息查詢?--------*/
[root@localhost?~]#?rpm?-qf?/etc/inittab
| 1 | initscripts-9.03.40-2.el6.centos.x86_64 |
[root@localhost?~]#?rpm?-qf?/etc/fstab
| 1 | setup-2.8.14-20.el6_4.1.noarch |
?
??
[root@localhost?~]#?yum?provides?/etc/fstab
| 1 2 3 4 5 6 7 8 9 10 11 12 | Loaded?plugins:?fastestmirror,?refresh-packagekit,?security Loading?mirror?speeds?from?cached?hostfile setup-2.8.14-20.el6_4.1.noarch?:?A?set?of?system?configuration?and?setup?files #?此包生成了/etc/fstab Repo????????:?base Matched?from: Filename????:?/etc/fstab ??? setup-2.8.14-20.el6_4.1.noarch?:?A?set?of?system?configuration?and?setup?files Repo????????:?installed Matched?from: Other???????:?Provides-match:?/etc/fstab |
?
?
?
[root@localhost?~]#?yum?provides?/etc/named.conf
| 1 2 3 4 5 6 7 8 9 | #也可以顯示沒有安裝的文件 Loaded?plugins:?fastestmirror,?refresh-packagekit,?security Loading?mirror?speeds?from?cached?hostfile 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64?:?The?Berkeley?Internet?Name?Domain?(BIND)?DNS?(Domain?Name?System) ??????????????????????????????????????:?server #?這個包之前被卸載了,這里顯示的是服務器倉庫上的包 Repo????????:?base Matched?from: Filename????:?/etc/named.conf |
?
?
?
/*--------?(5)?模糊匹配查詢?--------*/
[root@localhost?~]#?yum?search?init
| 1 2 3 4 5 6 7 8 9 10 11 | Loaded?plugins:?fastestmirror,?refresh-packagekit,?security Loading?mirror?speeds?from?cached?hostfile ==============================N/S?Matched:?init?=============================== initscripts.x86_64?:?The?inittab?file?and?the?/etc/init.d?scripts iscsi-initiator-utils-devel.x86_64?:?Development?files?for? ... upstart.x86_64?:?An?event-driven?init?system xhtml1-dtds.noarch?:?XHTML?1.0?document?type?definitions xorg-x11-xinit-session.x86_64?:?Display?manager?support?for?~/.xsession?and?~/.Xclients ?? ??Name?and?summary?matches?only,?use?"search?all"?for?everything. |
/*--------?(6)?安裝包組?--------*/
?
通常安裝開發環境,為避免依賴關系,通常需要安裝三個組:Development?tools;?Server?Platform?Development;?Desktop?Platform?Development
[root@localhost?~]#?yum?grouplist
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | Loaded?plugins:?fastestmirror,?refresh-packagekit,?security Setting?up?Group?Process Loading?mirror?speeds?from?cached?hostfile base/group_gz????????????????????????????????????????????????????????????????|?220?kB?????00:00?...? Installed?Groups: ???Additional?Development ???Base ???Debugging?Tools ???... ???Web?Server ???X?Window?System Installed?Language?Groups: ???Arabic?Support?[ar] ???... ???Venda?Support?[ve] Available?Groups: ???Backup?Client ???... ???iSCSI?Storage?Client Available?Language?Groups: ???Afrikaans?Support?[af] ??... ???Zulu?Support?[zu] Done |
?
?
[root@localhost~]#yum?-y groupinstall?"Development?tools"?"Server?Platform?Development"?"Desktop?Platform?Development"
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ?? ... ?pixman-devel??????????????x86_64?????????0.26.2-5.el6_4?????????????????????????????base??????????18?k ?ppl???????????????????????x86_64?????????0.10.2-11.el6??????????????????????????????base?????????1.3?M ?systemtap-client????????????x86_64?????????2.3-3.el6??????????????????????????????????base?????????3.4?M ?systemtap-devel????????????x86_64?????????2.3-3.el6??????????????????????????????????base?????????1.4?M ?xorg-x11-proto-devel???????noarch?????????7.6-25.el6?????????????????????????????????base?????????274?k ?yajl??????????????????????x86_64?????????1.0.7-3.el6????????????????????????????????base??????????27?k ?? Transaction?Summary ============================================================================== Install?????115?Package(s) ?? Total?download?size:?123?M Installed?size:?404?M ...????????????????????????? ??systemtap-devel.x86_64?0:2.3-3.el6??????????????xorg-x11-proto-devel.noarch?0:7.6-25.el6???????????????????? ??yajl.x86_64?0:1.0.7-3.el6?????????????????????? ?? Complete! |
?
?
?
/*--------?(7)?通過yum下載到本地,然后手動安裝軟件包?--------*/
[root@localhost?~]#?cd?/media/cdrom/Packages/
[root@localhost?Packages]#?yum?install?bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #?這個包已經下載到本地了,因此不再從服務器下載 Loaded?plugins:?fastestmirror,?refresh-packagekit,?security Loading?mirror?speeds?from?cached?hostfile Setting?up?Install?Process Examining?bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm:?32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64 Marking?bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm?to?be?installed Resolving?Dependencies -->?Running?transaction?check --->?Package?bind.x86_64?32:9.8.2-0.17.rc1.el6_4.6?will?be?installed -->?Finished?Dependency?Resolution ?? Dependencies?Resolved ?? ========================================================================================= ?Package?????Arch??????????Version????????????????????????????Repository??????????????????????????????????Size ========================================================================================== Installing: ?bind????????x86_64????????32:9.8.2-0.17.rc1.el6_4.6??????????/bind-9.8.2-0.17.rc1.el6_4.6.x86_64????????7.3?M ?? Transaction?Summary ========================================================================================== Install???????1?Package(s) ?? Total?size:?7.3?M Installed?size:?7.3?M Is?this?ok?[y/N]:?N |
?
?
?
[root@localhost?Packages]#?yum?localinstall?bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | Loaded?plugins:?fastestmirror,?refresh-packagekit,?security Setting?up?Local?Package?Process Examining?bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm:?32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64 Marking?bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm?to?be?installed Loading?mirror?speeds?from?cached?hostfile Resolving?Dependencies -->?Running?transaction?check --->?Package?bind-chroot.x86_64?32:9.8.2-0.17.rc1.el6_4.6?will?be?installed -->?Processing?Dependency:?bind?=?32:9.8.2-0.17.rc1.el6_4.6?for?package:?32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64 -->?Running?transaction?check --->?Package?bind.x86_64?32:9.8.2-0.17.rc1.el6_4.6?will?be?installed -->?Finished?Dependency?Resolution ?? #?可以看到使用localinstall?也會自動解決依賴關系 ?? Dependencies?Resolved ?? ========================================================================================= ?Package?????????Arch???????Version???????????????????????Repository??????????????????????????????????????Size ========================================================================================== Installing: ?bind-chroot?????x86_64?????32:9.8.2-0.17.rc1.el6_4.6?????/bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64?????0.0?? Installing?for?dependencies: ?bind????????????x86_64?????32:9.8.2-0.17.rc1.el6_4.6?????base???????????????????????????????????4.0?M ?? Transaction?Summary ========================================================================================== Install???????2?Package(s) ?? Total?download?size:?4.0?M Installed?size:?7.3?M Is?this?ok?[y/N]:?n Exiting?on?user?Command |
?
?
/*--------?(8)?查看yum命令的歷史記錄?--------*/
?
[root@localhost?~]#?yum?history
| 1 2 3 4 5 6 7 8 9 | Loaded?plugins:?fastestmirror,?refresh-packagekit,?security ID?????|?Login?user???????????????|?Date?and?time????|?Action(s)??????|?Altered ------------------------------------------------------------------------------- ?????5?|?root?<root>??????????????|?2014-08-17?06:53?|?Install????????|??115??? ?????4?|?root?<root>??????????????|?2014-08-17?06:37?|?Erase??????????|????2?EE ?????3?|?root?<root>??????????????|?2014-08-17?06:20?|?Reinstall??????|????1??? ?????2?|?root?<root>??????????????|?2014-08-17?06:16?|?Install????????|????2??< ?????1?|?System?<unset>???????????|?2014-07-09?21:22?|?Install????????|?1205?>? history?list |
?
?
?
/*--------?(9)?使用yum安裝lftp工具包?--------*/
?
現在來安裝一個比較常用的ftp工具包?lftp:
?
[root@localhost?~]#?rpm?-ql?lftp
| 1 2 | #?首先檢查這個軟件包有沒有安裝 package?lftp?is?not?installed |
?
[root@localhost?~]#?yum?install?lftp
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | Loaded?plugins:?fastestmirror,?refresh-packagekit,?security Loading?mirror?speeds?from?cached?hostfile Setting?up?Install?Process Resolving?Dependencies -->?Running?transaction?check --->?Package?lftp.x86_64?0:4.0.9-1.el6?will?be?installed -->?Finished?Dependency?Resolution ?? Dependencies?Resolved ?? ================================================================================ ?Package????????????Arch?????????????????Version?????????????????????Repository???????????????????Size ================================================================================= Installing: ?lftp???????????????x86_64???????????????4.0.9-1.el6?????????????????cdrom-centos6???????????????753?k ?? Transaction?Summary ================================================================================ Install???????1?Package(s) ?? Total?download?size:?753?k Installed?size:?2.5?M Is?this?ok?[y/N]:?y Downloading?Packages: Running?rpm_check_debug Running?Transaction?Test Transaction?Test?Succeeded Running?Transaction ??Installing?:?lftp-4.0.9-1.el6.x86_64?????????????????????????????????????????????????????????????1/1? ??Verifying??:?lftp-4.0.9-1.el6.x86_64?????????????????????????????????????????????????????????????1/1? ?? Installed: ??lftp.x86_64?0:4.0.9-1.el6???????????????????????????????????????????????????????????????????????????? ?? Complete! |
?
安裝完成,現在可以使用lftp來ping服務器了:
?
[root@localhost?~]#?ifconfig
| 1 2 3 4 5 6 7 8 9 | eth0??????Link?encap:Ethernet??HWaddr?08:00:27:CA:DF:46?? ??????????inet?addr:192.168.56.103??Bcast:192.168.56.255??Mask:255.255.255.0 ??#?本機的IP地址 ??????????inet6?addr:?fe80::a00:27ff:feca:df46/64?Scope:Link ??????????UP?BROADCAST?RUNNING?MULTICAST??MTU:1500??Metric:1 ??????????RX?packets:114790?errors:0?dropped:0?overruns:0?frame:0 ??????????TX?packets:46931?errors:0?dropped:0?overruns:0?carrier:0 ??????????collisions:0?txqueuelen:1000? ??????????RX?bytes:10065569?(9.5?MiB)??TX?bytes:12450568?(11.8?MiB) |
?
[root@localhost?~]#?lftp?192.168.56.103
| 1 2 3 4 5 6 7 | ?? lftp?192.168.56.103:~>?pwd ftp://192.168.56.103? #?查看登陸的站點 lftp?192.168.56.103:~>?!pwd /root #查看本地目錄 |
?
lftp可以使用的基本命令有:
get:?下載單個文件
mget:下載多個文件
mirror:鏡像一個目錄到本地
bye:退出
cd:切換目錄
pwd:查看當前位置
?
轉自:http://blog.51cto.com/wuyelan/1615130
總結
以上是生活随笔為你收集整理的文件系统:使用 yum 安装软件包的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: qt+visa实现程控实例
- 下一篇: Qt--在.pro文件中添加链接库的写法