1. 程式人生 > >使用yum源安裝和yum源配置

使用yum源安裝和yum源配置

architect version arch pla BE nim img 平臺 enable

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 <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.

列出一個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 清除緩存

使用yum源安裝和yum源配置