Linux7.2 yum工具

能夠發現安裝某些包,須要另外一些包的支持,遇到多重依賴關係包,安裝比較麻煩。vim

[root@chy002 Packages]# rpm -ivh texlive-2012-32.20130427_r30134.el7.x86_64.rpm
錯誤:依賴檢測失敗:
        texlive-scheme-basic 被 texlive-2:2012-32.20130427_r30134.el7.x86_64 須要
        texlive-collection-latexrecommended 被 texlive-2:2012-32.20130427_r30134.el7.x86_64 須要
        tex-kpathsea 被 texlive-2:2012-32.20130427_r30134.el7.x86_64 須要
        tex-tetex 被 texlive-2:2012-32.20130427_r30134.el7.x86_64 須要

yum工具能夠自動解決依賴關係centos

[root@chy002 Packages]# yum install texlive
... ...
安裝  1 軟件包 (+246 依賴軟件包)

總下載量:123 M
安裝大小:237 M
Is this ok [y/d/N]:

... ...

yum工具用法

#yum   list      列出可用rpm包

[root@chy002 Packages]#yum list
... ...
zziplib-devel.x86_64                                   0.13.62-5.el7                        base
zziplib-utils.x86_64                                   0.13.62-5.el7                        base

#yum list中倉庫名的base是來自倉庫配置文件中的 [base]
[root@chy002 Packages]# ls /etc/yum
yum/         yum.conf     yum.log      yum.repos.d/
[root@chy002 Packages]# ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  CentOS-Vault.repo
[root@chy002 Packages]# 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
#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
#baseurl=http://mirror.centos.org/centos/$rele
... ...


#搜索包    yum search  vim   不夠精準,說明中帶的vim也過濾出
[root@chy002 Packages]# yum search vim
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * extras: mirrors.zju.edu.cn
 * updates: mirrors.zju.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」試試。

#較精準搜索
[root@chy002 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

#安裝包  yum install -y  包名

#列出可用安裝組、套件
[root@chy002 Packages]# yum grouplist
... ...
Available environment groups:
   最小安裝
... ...
   開發及生成工做站
可用組:
   傳統 UNIX 兼容性
   ... ...
   系統管理工具
完成

#安裝組、套件  yum groupinstall -y 

#卸載  yum  remove -y

#更新  yum   update  -y

#經過命令搜索包名     yum  provides   "/*/命令"
[root@chy002 Packages]# yum provides "/*/pstree"
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * extras: mirrors.zju.edu.cn
 * updates: mirrors.zju.edu.cn
psmisc-22.20-15.el7.x86_64 : Utilities for managing processes on your system
源    :base
匹配來源:
文件名    :/usr/bin/pstree



psmisc-22.20-15.el7.x86_64 : Utilities for managing processes on your system
源    :@base
匹配來源:
文件名    :/usr/bin/pstree

yum搭建本地倉庫

  Linux系統不能聯網就不能使用聯網的yum源了,能夠利用Linux系統光盤製做一個yum源。緩存

#掛載光盤
mount /dev/cdrom  /mnt

#備份,刪除/etc/yum.repos.d 目錄全部的repo文件
cp -r /etc/yum.repos.d /etc/yum.repos.d.bak
rm -rf /etc/yum.repos.d/*

#建立新的dvd.repo文件
[root@chy002 yum.repos.d]# cat dvd.repo
[dvd]
name=install dvd
baseurl=file:///mnt
enabled=1
gpgcheck=0

#刷新repos生成緩存
yum makecache


[root@chy002 yum.repos.d]# yum list
... ...

zenity.x86_64                                   3.8.0-4.el7                          dvd
zlib-devel.x86_64                               1.2.7-13.el7                         dvd
zsh.x86_64                                      5.0.2-7.el7                          dvd
zziplib.x86_64                                  0.13.62-5.el7                        dvd

yum更換國內源

  備份倉庫源配置文件。經過wget + 連接  或者  curl  -O  + 連接    下載yum源配置文件到該文件夾下,而後yum clean all清空緩存。bash

首先備份/etc/yum.repos.d/CentOS-Base.repo
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下載對應版本repo文件, 放入/etc/yum.repos.d/(操做前請作好相應備份)
http://mirrors.163.com/.help/CentOS5-Base-163.repo
http://mirrors.163.com/.help/CentOS6-Base-163.repo

運行如下命令生成緩存
    yum clean all
    yum makecache

yum下載rpm包

安裝擴展源 

  有時候系統源沒有該rpm包,須要安裝擴展源epel架構

[root@chy002 etc]# cp -r yum.repo.d.bak/* yum.repos.d/
[root@chy002 etc]# ls yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  CentOS-Vault.repo
[root@chy002 etc]# yum install -y epel-release
已加載插件:fastestmirror
base                                                                   | 3.6 kB  00:00:00
extras                                                                 | 3.4 kB  00:00:00
updates                                                                | 3.4 kB  00:00:00
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.zju.edu.cn
 * updates: centos.ustc.edu.cn
正在解決依賴關係
--> 正在檢查事務
---> 軟件包 epel-release.noarch.0.7-9 將被 安裝
--> 解決依賴關係完成

依賴關係解決

==============================================================================================
 Package                    架構                 版本              源                    大小
==============================================================================================
正在安裝:
 epel-release               noarch               7-9               extras                14 k

事務概要
==============================================================================================
安裝  1 軟件包

總下載量:14 k
安裝大小:24 k
Downloading packages:
epel-release-7-9.noarch.rpm                                            |  14 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安裝    : epel-release-7-9.noarch                                                   1/1
  驗證中      : epel-release-7-9.noarch                                                   1/1

已安裝:
  epel-release.noarch 0:7-9

完畢!
[root@chy002 etc]# cd yum.repos.d
[root@chy002 yum.repos.d]# ls
CentOS-Base.repo       CentOS-Sources.repo  epel.repo
CentOS-Debuginfo.repo  CentOS-Vault.repo    epel-testing.repo

yum下載rpm包到本地

#能夠下載一個沒有安裝過的rpm包
yum install -y 包名  --downloadonly  --downloaddir=路徑

[root@chy002 tmp]# yum install  zvbi-devel.x86_64  -y --downloadonly
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
... ...
Background downloading packages, then exiting:
警告:/var/cache/yum/x86_64/7/epel/packages/zvbi-devel-0.2.35-1.el7.x86_64.rpm.2734.tmp: 頭V3 RSA/SHA256 Signature, 密鑰 ID 352c64e5: NOKEY

... ...

#能夠發現,該rpm包下載的地址 /var/cache/yum/x86_64/7/epel/packages/

#若是下載已安裝的rpm包
[root@chy002 tmp]# yum install  vim-enhanced  -y --downloadonly
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.zju.edu.cn
 * updates: centos.ustc.edu.cn
軟件包 2:vim-enhanced-7.4.160-2.el7.x86_64 已安裝而且是最新版本
無須任何處理
[root@chy002 tmp]# yum reinstall  vim-enhanced  -y --downloadonly  --downloaddir=/tmp/
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * epel: mirror01.idc.hinet.net
 * extras: mirrors.zju.edu.cn
... ...

Background downloading packages, then exiting:
vim-enhanced-7.4.160-2.el7.x86_64.rpm                                  | 1.0 MB  00:00:03
exiting because "Download Only" specified
[root@chy002 tmp]# ls
123      chyuanliu1                             yum_save_tx.2017-11-14.04-12.cXiZgk.yumtx
123.txt  passwd.txt                             yum_save_tx.2017-11-14.06-12.tVu9wM.yumtx
321.txt  vim-enhanced-7.4.160-2.el7.x86_64.rpm  yum_save_tx.2017-11-14.06-26.O985nb.yumtx
相關文章
相關標籤/搜索