在三种方法中,源码包是最难的,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