rpm包介绍 rpm工具用法 yum工具用法

安装软件包的三种方法

  • rpm工具
  • yum工具
  • 源码包

rmp包介绍

设置光驱并挂载mount /dev/cdrom /mnt

包名-版本号-发布版本号-平台

列出包安装的文件

查询指定包是否安装

[root@g_linux01 ~]# rpm -q ppp
未安装软件包 ppp 
[root@g_linux01 ~]# rpm -q kmod
kmod-20-15.el7.x86_64

如果不知道文件路径,可以用`which cd` 形式查看

yum工具

使用rpm时,如果需要安装的包依赖很多包,会比较麻烦,使用yum会自动安装依赖包。

  • yum list 显示可用rpm包

左边是包名,中间是版本信息,右边是仓库名,仓库这边显示@base、@anaconda表示已经安装。如果未安装这显示base或者anaconda,如果是updates表示已安装但是需要升级。

[root@glinux-01 ~]# yum list|head -10
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
已安装的软件包
GeoIP.x86_64                                1.5.0-11.el7               @anaconda
NetworkManager.x86_64                       1:1.8.0-9.el7              @anaconda
NetworkManager-libnm.x86_64                 1:1.8.0-9.el7              @anaconda
NetworkManager-team.x86_64                  1:1.8.0-9.el7              @anaconda
  • 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-7

  • yum search vim 搜索跟vim相关的包
[root@glinux-01 ~]# yum search vim
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
============================================ 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”试试。
  • yum list|grep vim 可以用匹配搜索
  • 安装包 yum install [-y] 【包名】 (-y加这个选项会不询问是否安装)
  • yum grouplist 列出可用分组
[root@glinux-01 ~]# yum grouplist
已加载插件:fastestmirror
没有安装组信息文件
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
可用的环境分组:
   最小安装
   基础设施服务器
   计算节点
   文件及打印服务器
   基本网页服务器
   虚拟化主机
   带 GUI 的服务器
   GNOME 桌面
   KDE Plasma Workspaces
   开发及生成工作站
可用组:
   传统 UNIX 兼容性
   兼容性程序库
   图形管理工具
   安全性工具
   开发工具
   控制台互联网工具
   智能卡支持
   科学记数法支持
   系统管理
   系统管理工具
完成
  • yum groupinstall [-y] [组名]  (先将上面内容转化为英文LENG=en,再选择)
  •  yum remove [-y] 卸载包
  • yum update [-y] 【包名】 更新包(如果不加包名,会将系统全部更新)
  • yum provide "/*/vim" 搜索一个命令都有哪些包

 yum本地仓库(使用本地光盘制作yum源)

创建方法:1挂载镜像到 /mnt目录(mount /dev/cdrom /mnt)

               2 cp -r /etc/yum.repos.d /etc/yum.repos.d.bak

               3 rm -f /etc/yum.repos.d/*

               4 vim /etc/yum.repos.d/dvd.repo//内容如下

[dvd] //仓库名字
name=install dvd
baseurl=file:///mnt //本地源地址 ??

(file://   /mnt)
enable=1 //本地是否可用,1可用,0不可以
gpgcheck=0 //是否检测,1检测,0不检测

  • yum clean all //清除缓存
  • yum list

猜你喜欢

转载自my.oschina.net/u/3771583/blog/1627225