linux下有三种rpm包的安装方式
rpm安装、yum安装和源码包编译
rpm安装方式
rpm包的命名格式规则
rpm 包名 版本号 、发布版本号、平台版本
rpm -ivh rpm包 #安装
rpm -Uvh rpm包 #升级
rpm -e rpm包 #卸载
rpm -qa rpm包 #查询安装的包
rpm -q rpm包 #查询指定的包是否安装
rpm -qi rpm包 #查询指定包信息
rpm -ql rpm包 #列出包安装的文件(安装包的所有安装文件)
rpm -qf 文件绝对路径 #查询这个文件属于哪个rpm安装包
rpm工具用法
查询包的详细信息
[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月07日 星期二 14时25分05秒 //安装时间
Group : Applications/Editors //属于的组
Size : 2292098 //包大小
License : Vim //授权是vim形式发布的
Signature : RSA/SHA256 , Key ID 24c6a8a7f4a80eb5
Source RPM : vim-7.4.160-2.el7.src.rpm
Build Host : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem
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.
列出一个rpm包所有的安装文件
[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
根据文件路径,查看文件的rpm安装包
[root@localhost Packages]# rpm -qf /usr/bin/vimdiff
vim-enhanced-7.4.160-2.el7.x86_64
rpm-反引号用法查询出命令路径。
[root@localhost Packages]# rpm -qf `which cd`
bash-4.2.46-20.el7_2.x86_64
yum工具用法
yum list列出可用的安装包
[root@localhost src]# yum list |head -n 30
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.neusoft.edu.cn
已安装的软件包
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
yum 搜索结果使用grep过滤某些包(这里截图,应为带有特殊颜色
yum install [-y] 包名 #安装yum中的包
[root@localhost src]# yum install vim
已加载插件:fastestmirror
base | 3.6 kB 00:00:00
epel/x86_64/metalink | 5.7 kB 00:00:00
epel | 3.2 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/2): epel/x86_64/updateinfo | 925 kB 00:00:02
(2/2): epel/x86_64/primary | 3.5 MB 00:00:02
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.neusoft.edu.cn
epel 12601/12601
软件包 2:vim-enhanced-7.4.160-4.el7.x86_64 已安装并且是最新版本
无须任何处理 这里已经安装,只做示范
yum grouplist 列出yum中的安装包组
[root@localhost src]# yum grouplist
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.neusoft.edu.cn
Available Environment Groups:
Minimal Install
Compute Node
Infrastructure Server
File and Print Server
Cinnamon Desktop
MATE Desktop
Basic Web Server
Virtualization Host
Server with GUI
GNOME Desktop
KDE Plasma Workspaces
yum groupinstall [-y] 安装组名 #安装一个安装组,如果安装组名称中包含空格,需要使用单引号引用
[root@localhost src]# yum groupinstall 'Basic Web Server'
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.neusoft.edu.cn
Resolving Dependencies
.....................................................
openssl x86_64 1:1.0.2k-12.el7 base 492 k
openssl-libs x86_64 1:1.0.2k-12.el7 base 1.2 M
Transaction Summary
=======================================================================================
Install 63 Packages (+36 Dependent packages)
Upgrade 1 Package (+39 Dependent packages)
Total download size: 136 M
Is this ok [y/d/N]: n
Exiting on user command
Your transaction was saved, rerun it with:
yum load-transaction /tmp/yum_save_tx.2018-06-24.19-33.pKADyS.yumtx
这里只是演示安装一个程序组,不进行安装
yum remove [-y] yum包名 #删除这个yum包程序
[root@localhost src]# yum remove vim
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.4.160-4.el7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================
Package Arch Version Repository Size
=======================================================================================
Removing:
vim-enhanced x86_64 2:7.4.160-4.el7 @base 2.2 M
Transaction Summary
=======================================================================================
Remove 1 Package
Installed size: 2.2 M
Is this ok [y/N]: n
Exiting on user command
Your transaction was saved, rerun it with:
yum load-transaction /tmp/yum_save_tx.2018-06-24.19-40.cVRYya.yumtx 这里只是删除示范
yum update [-y] #升级系统中的yum程序(所有)
yum provides '/* /vim' #通过一个命令找到这个安装包的名称
本地yum源配置
配置本地yum源,需要yum源的所有安装包,可以是存储在硬盘或者是安装镜像中
[root@localhost ]# vim /etc/yum.repos.d/local.repo
[local]
name=local install
baseurl=file:///mnt
enable=1
gpgcheck=0
[root@localhost ]# yum clean all 清除缓存