安装软件包的三种方法:node
设置光驱并挂载 1)点击--虚拟机—设置—CD/DVD(ide)--右边设置iso映像文件路径。
linux
2)挂载光驱git
[root@linux-128 ~]# mount /dev/cdrom /mnt mount: /dev/sr0 写保护,将以只读方式挂载 [root@linux-128 ~]# ls /mnt CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7 EFI images Packages RPM-GPG-KEY-CentOS-Testing-7 EULA isolinux repodata TRANS.TBL
3)/mnt/Packages目录里面是rpm包
[root@linux-128 ~]# ls /mnt/Packages/ |head -5 389-ds-base-1.3.5.10-11.el7.x86_64.rpm 389-ds-base-libs-1.3.5.10-11.el7.x86_64.rpm abattis-cantarell-fonts-0.0.16-3.el7.noarch.rpm abrt-2.1.11-45.el7.centos.x86_64.rpm abrt-addon-ccpp-2.1.11-45.el7.centos.x86_64.rpm
小知识: 每一个rpm包的名称都是由-和.分红若干部分,好比abrt-2.1.11-45.el7.centos.x86_64.rpm Abrt:包名
2.1.11-45:版本号;2为主版本号,1为次版本号,11为修正版本
45-el7.centos:发布版本号
x86_64.:运行平台,64位 cpu目前分32位和64位,i38六、i58六、i686是32位,X86_64是64位。
64位系统能够安装32位软件,可是32位系统不能安装64为软件。vim
[root@linux-128 ~]# cd /mnt/Packages/ [root@linux-128 Packages]# rpm -ivh xz-5.2.2-1.el7.x86_64.rpm 准备中... ################################# [100%] 软件包 xz-5.2.2-1.el7.x86_64 已经安装
[root@linux-128 Packages]# rpm -e xz 错误:依赖检测失败: xz 被 (已安裝) dracut-033-463.el7.x86_64 须要 /usr/bin/xz 被 (已安裝) kmod-20-9.el7.x86_64 须要
[root@linux-128 Packages]# rpm -qa tree tree-1.6.0-10.el7.x86_64
[root@linux-128 Packages]# rpm -qa |head trousers-0.3.13-1.el7.x86_64 filesystem-3.2-21.el7.x86_64 net-tools-2.0-0.17.20131004git.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 ncurses-libs-5.9-13.20130511.el7.x86_64 libX11-common-1.6.3-3.el7.noarch libselinux-2.5-6.el7.x86_64
[root@linux-128 Packages]# rpm -qi tree Name : tree Version : 1.6.0 Release : 10.el7 Architecture: x86_64 Install Date: 2017年10月20日 星期五 15时00分08秒 Group : Applications/File Size : 89505 License : GPLv2+ Signature : RSA/SHA256, 2014年07月04日 星期五 13时36分46秒, Key ID 24c6a8a7f4a80eb5 Source RPM : tree-1.6.0-10.el7.src.rpm Build Date : 2014年06月10日 星期二 03时28分53秒 Build Host : worker1.bsys.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : http://mama.indstate.edu/users/ice/tree/ Summary : File system tree viewer Description : The tree utility recursively displays the contents of directories in a tree-like format. Tree is basically a UNIX port of the DOS tree utility.
[root@linux-128 Packages]# rpm -ql tree /usr/bin/tree /usr/share/doc/tree-1.6.0 /usr/share/doc/tree-1.6.0/LICENSE /usr/share/doc/tree-1.6.0/README /usr/share/man/man1/tree.1.gz
[root@linux-128 Packages]# rpm -qf /usr/bin/cd bash-4.2.46-20.el7_2.x86_64
[root@linux-128 Packages]# rpm -qf `which cd` bash-4.2.46-20.el7_2.x86_64 注意:``里面which cd 显示只有一行,若是是which ls 显示2行,这里就不能使用这条命令。
Yum比rpm工具更方便,yum工具最大的优点在于能够联网去下载所须要的的rpm包,而后自动安装,安装全部相关的rpm包,解决依赖关系。centos
[root@linux-128 Packages]# yum list |head -20 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.btte.net 已安装的软件包 GeoIP.x86_64 1.5.0-11.el7 @anaconda NetworkManager.x86_64 1:1.4.0-12.el7 @anaconda NetworkManager-libnm.x86_64 1:1.4.0-12.el7 @anaconda NetworkManager-team.x86_64 1:1.4.0-12.el7 @anaconda NetworkManager-tui.x86_64 1:1.4.0-12.el7 @anaconda NetworkManager-wifi.x86_64 1:1.4.0-12.el7 @anaconda acl.x86_64 2.2.51-12.el7 @anaconda aic94xx-firmware.noarch 30-6.el7 @anaconda alsa-firmware.noarch 1.0.28-2.el7 @anaconda alsa-lib.x86_64 1.1.1-1.el7 @anaconda alsa-tools-firmware.x86_64 1.1.0-1.el7 @anaconda atk.x86_64 2.14.0-1.el7 @anaconda atkmm.x86_64 2.22.7-3.el7 @anaconda audit.x86_64 2.6.5-3.el7 @anaconda
左边是包名,中间是版本信息,右边是仓库名,仓库这边显示@base、@anaconda表示已经安装。若是未安装这显示base或者anaconda,若是是updates表示已安装可是须要升级。缓存
yum的配置文件:/etc/yum.repos.d/Centos-Base.repo 里面能够配置仓库名,yum源地址安全
[base] //仓库名 name=CentOS-$releasever – Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra //yum源地址。 #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7bash
[root@linux-128 Packages]# yum search vim 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.btte.net =============================== 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
[root@linux-128 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@linux-128 Packages]# yum install -y tree 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.btte.net 正在解决依赖关系 --> 正在检查事务 ---> 软件包 tree.x86_64.0.1.6.0-10.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 ================================================================================= Package 架构 版本 源 大小 ================================================================================= 正在安装: tree x86_64 1.6.0-10.el7 base 46 k 事务概要 ================================================================================= 安装 1 软件包 总下载量:46 k 安装大小:87 k Downloading packages: tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : tree-1.6.0-10.el7.x86_64 1/1 验证中 : tree-1.6.0-10.el7.x86_64 1/1 已安装: tree.x86_64 0:1.6.0-10.el7 完毕!
命令:yum remove –y 包名 [root@linux-128 Packages]# yum remove -y tree 已加载插件:fastestmirror 正在解决依赖关系 --> 正在检查事务 ---> 软件包 tree.x86_64.0.1.6.0-10.el7 将被 删除 --> 解决依赖关系完成 依赖关系解决 ================================================================================= Package 架构 版本 源 大小 ================================================================================= 正在删除: tree x86_64 1.6.0-10.el7 @base 87 k 事务概要 ================================================================================= 移除 1 软件包 安装大小:87 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 正在删除 : tree-1.6.0-10.el7.x86_64 1/1 验证中 : tree-1.6.0-10.el7.x86_64 1/1 删除: tree.x86_64 0:1.6.0-10.el7 完毕!
命令:yum grouplist [root@linux-128 Packages]# yum grouplist 已加载插件:fastestmirror 没有安装组信息文件 Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.btte.net 可用的环境分组: 最小安装 基础设施服务器 计算节点 文件及打印服务器 基本网页服务器 虚拟化主机 带 GUI 的服务器 GNOME 桌面 KDE Plasma Workspaces 开发及生成工做站 可用组: 传统 UNIX 兼容性 兼容性程序库 图形管理工具 安全性工具 开发工具 控制台互联网工具 智能卡支持 科学记数法支持 系统管理 系统管理工具 完成
[root@linux-128 ~]# mount /dev/cdrom /mnt mount: /dev/sr0 写保护,将以只读方式挂载
[dvd] //仓库名字
name=install dvd
baseurl=file:///mnt //本地源地址
enable=1 //本地是否可用,1可用,0不能够
gpgcheck=0 //是否检测,1检测,0不检测服务器
[root@linux-128 ~]# yum list |tail -10 yum-plugin-aliases.noarch 1.1.31-40.el7 dvd yum-plugin-changelog.noarch 1.1.31-40.el7 dvd yum-plugin-tmprepo.noarch 1.1.31-40.el7 dvd yum-plugin-verify.noarch 1.1.31-40.el7 dvd yum-plugin-versionlock.noarch 1.1.31-40.el7 dvd yum-utils.noarch 1.1.31-40.el7 dvd zenity.x86_64 3.8.0-5.el7 dvd zlib-devel.x86_64 1.2.7-17.el7 dvd zsh.x86_64 5.0.2-25.el7 dvd zziplib.x86_64 0.13.62-5.el7 dvd