在三種方法中,源碼包是最難的,yum工具是最簡單的html
首先打開vmware,而後選擇右下角的 「光盤圖標」 ,鼠標右擊 「設置」python
將光盤鏈接到linux系統上linux
掛載光驅git
[root@hf-01 ~]# df -h 查看/mnt/目錄是否使用 文件系統 容量 已用 可用 已用% 掛載點 /dev/sda3 18G 3.1G 15G 18% / devtmpfs 488M 0 488M 0% /dev tmpfs 494M 0 494M 0% /dev/shm tmpfs 494M 6.7M 487M 2% /run tmpfs 494M 0 494M 0% /sys/fs/cgroup /dev/sda1 197M 76M 122M 39% /boot [root@hf-01 ~]# ls /mnt/ [root@hf-01 ~]# mount /dev/cdrom /mnt/ mount: /dev/sr0 寫保護,將以只讀方式掛載
進入到/mnt/目錄下,並查看文件vim
[root@hf-01 ~]# cd /mnt/ [root@hf-01 mnt]# ls CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7 EFI images Packages RPM-GPG-KEY-CentOS-Testing-7 EULA isolinux repodata TRANS.TBL [root@hf-01 mnt]#
在/mnt/中的一個Packages 目錄中有不少 .rpm 文件,而這些文件就是rpm包windows
[root@hf-01 mnt]# cd Packages/ [root@hf-01 Packages]# ls yum-utils-1.1.31-24.el7.noarch.rpm zenity-3.8.0-4.el7.x86_64.rpm zip-3.0-10.el7.x86_64.rpm zlib-1.2.7-13.el7.x86_64.rpm zlib-devel-1.2.7-13.el7.x86_64.rpm zsh-5.0.2-7.el7.x86_64.rpm 等等等
yelp-3.8.1-7.el7.x86_64.rpm yelp-libs-3.8.1-7.el7.x86_64.rpm
[root@localhost Packages]# rpm -ivh zsh-5.0.2-25.el7.x86_64.rpm 準備中... ################################# [100%] 正在升級/安裝... 1:zsh-5.0.2-25.el7 ################################# [100%]
這個文件在當前路徑,能夠加 ./zsh-5.0.2-25.el7.x86_64.rpm,或者可使用相對路徑,不用加 ./ 安裝rpm包的時候,也會存在依賴包
[root@localhost Packages]# rpm -e zsh [root@localhost Packages]#
直接刪除,不會有任何提示。(如果有提示,頗有多是出現什麼錯誤了)
[root@localhost Packages]# rpm -qa 這裏截取了前幾行代碼 trousers-0.3.13-1.el7.x86_64 filesystem-3.2-21.el7.x86_64 bind-license-9.9.4-37.el7.noarch fxload-2002_04_11-16.el7.x86_64 nss-softokn-freebl-3.16.2.3-14.4.el7.x86_64 libthai-0.1.14-9.el7.x86_64
列出來的都是已經安裝好的包,這些均可以直接卸載
[root@localhost Packages]# rpm -q ppp ppp-2.4.5-33.el7.x86_64 [root@localhost Packages]#
如果已經安裝的包,會直接顯示出來; 如果未安裝的包,則會提示未安裝軟件包。
[root@localhost Packages]# rpm -qi vim-enhanced Name : vim-enhanced //包名 Epoch : 2 Version : 7.4.160 //版本 Release : 2.el7 //發佈版本 Architecture: x86_64 //架構 Install Date: 2017年11月02日 星期四 11時24分32秒 //安裝時間 Group : Applications/Editors //屬於哪一個組 Size : 2292098 License : Vim Signature : RSA/SHA256, 2017年08月11日 星期五 04時15分38秒, Key ID 24c6a8a7f4a80eb5 Source RPM : vim-7.4.160-2.el7.src.rpm Build Date : 2017年08月02日 星期三 08時46分12秒 Build Host : c1bm.rdu2.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : http://www.vim.org/ Summary : A version of the VIM editor which includes recent enhancements Description : VIM (VIsual editor iMproved) is an updated and improved version of the vi editor. Vi was the first real screen-based editor for UNIX, and is still very popular. VIM improves on vi by adding new features: multiple windows, multi-level undo, block highlighting and more. The vim-enhanced package contains a version of VIM with extra, recently introduced features like Python and Perl interpreters. Install the vim-enhanced package if you'd like to use a version of the VIM editor which includes recently added enhancements like interpreters for the Python and Perl scripting languages. You'll also need to install the vim-common package. [root@localhost Packages]#
[root@localhost Packages]# rpm -ql vim-enhanced /etc/profile.d/vim.csh /etc/profile.d/vim.sh /usr/bin/rvim /usr/bin/vim /usr/bin/vimdiff /usr/bin/vimtutor [root@localhost Packages]#
[root@localhost Packages]# rpm -qf /usr/bin/vim 根據文件的絕對路徑來查看到是由哪一個包安裝的 vim-enhanced-7.4.160-2.el7.x86_64 [root@localhost Packages]#
which cd
[root@localhost Packages]# rpm -qf `which cd` bash-4.2.46-20.el7_2.x86_64 [root@localhost Packages]# which cd /usr/bin/cd [root@localhost Packages]#
[root@localhost Packages]# yum list //列出可用的rpm包(這裏只截取了一點) zziplib-devel.i686 0.13.62-5.el7 base zziplib-devel.x86_64 0.13.62-5.el7 base zziplib-utils.x86_64 0.13.62-5.el7 base
最左側是包的名字加相關信息 中間這一列是它的版本號以及平臺版本號 最右側是它倉庫的名字
倉庫名字的由來,能夠從 /etc/yum.repos.d/ 看yum的配置文件,在 /etc/yum.repos.d/中最核心的就是CentOS-Base.repo文件centos
[root@localhost Packages]# ls /etc/yum.repos.d/ CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo [root@localhost Packages]# ls /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo [root@localhost Packages]# cat !$ cat /etc/yum.repos.d/CentOS-Base.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [root@localhost Packages]#
會看到其中 方括號中 的就是倉庫的名字,把包放進容器中,而容器就是倉庫,而倉庫的地址上述有連接,rpm包就是在裏面尋找
[root@localhost Packages]# yum search vim 已加載插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.163.com =================================== N/S matched: vim =================================== protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers descriptions vim-X11.x86_64 : The VIM version of the vi editor for the X Window System vim-common.x86_64 : The common files needed by any version of the VIM editor vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements vim-filesystem.x86_64 : VIM filesystem layout vim-minimal.x86_64 : A minimal version of the VIM editor 名稱和簡介匹配 only,使用「search all」試試。 [root@localhost Packages]#
會搜索到與vim相關的包,但也會搜索出來一些說明。(若想只要包,則能夠過濾) 以下
[root@hf-01 Packages]# yum list |grep 'vim' vim-common.x86_64 2:7.4.160-2.el7 @base vim-enhanced.x86_64 2:7.4.160-2.el7 @base vim-filesystem.x86_64 2:7.4.160-2.el7 @base vim-minimal.x86_64 2:7.4.160-1.el7 @anaconda protobuf-vim.x86_64 2.5.0-8.el7 base vim-X11.x86_64 2:7.4.160-2.el7 base vim-minimal.x86_64 2:7.4.160-2.el7 base [root@hf-01 Packages]#
只要包名帶有vim的,就會顯示出來,而且vim還會有顏色顯示
[root@hf-01 Packages]# yum grouplist 已加載插件:fastestmirror 沒有安裝組信息文件 Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn Available environment groups: 最小安裝 基礎設施服務器 計算節點 文件及打印服務器 基本網頁服務器 虛擬化主機 帶 GUI 的服務器 GNOME 桌面 KDE Plasma Workspaces 開發及生成工做站 可用組: 傳統 UNIX 兼容性 兼容性程序庫 圖形管理工具 安全性工具 開發工具 控制檯互聯網工具 智能卡支持 科學記數法支持 系統管理 系統管理工具 完成 [root@hf-01 Packages]#
若選擇其中的組就會安裝組裏面的rpm包,在安裝完系統後,進入系統,使用yum工具安裝這些組
[root@hf-01 Packages]# yum groupinstall 'Virtualization Host'
[root@hf-01 Packages]# cd [root@hf-01 ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d.bak [root@hf-01 ~]# cd /etc/yum.repos.d [root@hf-01 yum.repos.d]# rm -rf ./* [root@hf-01 yum.repos.d]# vi dvd.repo
[root@hf-01 yum.repos.d]# yum clean all 已加載插件:fastestmirror 正在清理軟件源: dvd Cleaning up everything Cleaning up list of fastest mirrors [root@hf-01 yum.repos.d]#
[root@hf-01 yum.repos.d]# yum list 已加載插件:fastestmirror Loading mirror speeds from cached hostfile 已安裝的軟件包 GConf2.x86_64 3.2.6-8.el7 @base ModemManager-glib.x86_64 1.1.0-6.git20130913.el7 @anaconda NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 @anaconda NetworkManager-glib.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 @anaconda NetworkManager-tui.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 @anaconda OpenEXR-libs.x86_64 1.7.1-7.el7 @base 只截取了一小段 Availsble Packages //能夠安裝的包 389-ds-base.x86_64 1.3.5.10-11.el7 dvd
最右側以 @ 開頭的,表示已經安裝過的rpm包
yum本地倉庫,方便使用本地的光盤做爲他的倉庫,作爲它的依賴的包緩存
[root@hf-01 ~]# vim /etc/yum.conf [main] cachedir=/home/soft1/yumcache keepcache=1 debuglevel=2