概念:RMP包的名称都是由-和.分成了若干部分。
挂载光驱
[root@localhost ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载 #因为光驱是只读的,不可以写东西
[root@localhost Packages]# ls #进入到/mnt/Packages目录里,ls出来的都是rpm包
rmp是由包名,版本号(主版本、次版本、修正版本)、发布版本号、平台
rpm包选项:
-i 表示安装
-U 表示升级一个包
-v 表示可视化
-h 表示显示安装进度
-e 卸载一个包
-q 查询一个包是否已经安装
-qi 查询指定包信息
-ql 列出一个包安装的文件
-qf 查询文件绝对路径 //查看一个嗯我呢见是由哪个包安装的
rpm -qf `which cd` 查看这命令的路径包在哪
另在,在安装RPM包时,常用的附带参数还包括如下几项。
--force 表示强制安装,即使覆盖属于其他包的文件也要安装。
--nodeps 表示当要安装的RPM包依赖于其他包时,即使其他包没有安装,也要安装这个包
[root@localhost Packages]# rpm -ivh zsh-5.0.2-28.el7.x86_64.rpm
[root@localhost Packages]# rpm -Uvh zsh-5.0.2-28.el7.x86_64.rpm
准备中... ################################# [100%]
软件包 zsh-5.0.2-28.el7.x86_64 已经安装安装最新版本
[root@localhost Packages]# rpm -e zsh-5.0.2-28.el7.x86_64.rpm
[root@localhost Packages]# rpm -q ppp
未安装软件包 ppp
[root@localhost Packages]# rpm -qi vim-enhanced
Name : vim-enhanced
Epoch : 2
Version : 7.4.160
Release : 2.el7
Architecture: x86_64
Install Date: 2018年04月12日 星期四 22时07分45秒
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]# 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]# rpm -qf /usr/bin/vim
vim-enhanced-7.4.160-2.el7.x86_64
[root@localhost Packages]# rpm -qf which cd # which cd两边有俩个反引号`
bash-4.2.46-28.el7.x86_64
[root@localhost Packages]# yum install -y texlive
[root@localhost Packages]# yum list |head -n 20
[root@localhost Packages]# yum search vim
除此之外,还可以用grep来过滤,从而找到相应的RPM包
[root@localhost 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-2.el7 @anaconda
protobuf-vim.x86_64 2.5.0-8.el7 base
vim-X11.x86_64 2:7.4.160-2.el7 base
[root@localhost Packages]# yum remove -y protobuf-vim
已加载插件:fastestmirror
参数 protobuf-vim 没有匹配
不删除任何软件包
[root@localhost /]# mount /dev/cdrom /mnt/
[root@localhost ~]# cp -r /etc/yum.repos.d/ /etc/yum.repos.d.bak
[root@localhost ~]# cd /etc/yum.repos.d #进入到yum.repos.d目录
[root@localhost yum.repos.d]# ls #查看
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repo CentOS-fasttrack.repo
CentOS-CR.repo CentOS-Media.repo CentOS-Vault.repo
[root@localhost yum.repos.d]# rm -rf ./* #删除所有的文件
[root@localhost yum.repos.d]# vi dvd.repo
[dvd] #仓库的名字
name=install dvd #描述
baseurl=file:///mnt #rpm在光驱的路径
enable=1 #是否可用
gpcheck=0 #是否需要检测,不需要
~
[root@localhost yum.repos.d]# yum clean all
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Cleaning repos: dvd
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
原文地址:http://blog.51cto.com/13646023/2103630