天天看點

使用yum源安裝和yum源配置rpm安裝方式rpm工具用法yum工具用法本地yum源配置

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源安裝和yum源配置rpm安裝方式rpm工具用法yum工具用法本地yum源配置

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
這裡隻是示範安裝一個程式組,不進行安裝           
[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源配置

[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 清除緩存           

繼續閱讀