Linux下程序包管理之YUM
来源:互联网 发布:淘宝黄金 编辑:程序博客网 时间:2024/06/07 05:22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#cat /etc/yum.conf
[main]
cachedir=/
var
/cache/yum/$basearch/$releasever
#yum下载的RPM包的缓存目录
keepcache=
0
#缓存是否保存,
1
保存,
0
不保存。
debuglevel=
2
#调试级别(
0
-
10
),默认为
2
(具体调试级别的应用,我也不了解)。
logfile=/
var
/log/yum.log
#yum的日志文件所在的位置
exactarch=
1
#在更新的时候,是否允许更新不同版本的RPM包,比如是否在i386上更新i686的RPM包。
obsoletes=
1
#这是一个update的参数,具体请参阅yum(
8
),简单的说就是相当于upgrade,允许更新陈旧的RPM包。
gpgcheck=
1
#是否检查GPG(GNU Private Guard),一种密钥方式签名。
plugins=
1
#是否允许使用插件,默认是
0
不允许,但是我们一般会用yum-fastestmirror这个插件。
installonly_limit=
5
#允许保留多少个内核包。
bugtracker_url=http:
//bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
# This
is
the
default
,
if
you make
this
bigger yum won't see
if
the metadata
#
is
newer on the remote and so you'll
"gain"
the bandwidth of not having to
# download the
new
metadata and
"pay"
for
it by yum not having correct
# information.
# It
is
esp. important, to have correct metadata,
for
distributions like
# Fedora which don
't keep old packages around. If you don'
t like
this
checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will
do
this
).
# metadata_expire=90m
# PUT YOUR REPOS HERE OR IN separate files named file.repo
#
in
/etc/yum.repos.d
1
2
3
4
5
[base]
name=CentOS-$releasever - Base
#baseurl=http:
//mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=
1
gpgkey=file:
///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[base]
#方括号里面的是软件源的名称,将被yum取得并识别
name=CentOS-$releasever - Base
#这里也定义了软件 仓库的名称,通常是为了方便阅读配置文件,一般没什么作用,
$releasever变量定义了发行版本,通常是
5
,
6
,
7
等数字,
这个变量根据当前系统的版本架构不同而有不同的取值,
这可以方便yum升级的时候选择 适合当前系统的软件包,以下同……
#baseurl=http:
//mirror.centos.org/centos/$releasever/os/$basearch/
#上面的一行baseurl第一个字符是
'#'
表示该行已经被注释,将不会被读取,
$basearch变量定义了系统的架构,可以是i386、x86_64、ppc等值
这一行的意思是指定一个baseurl(源的镜像服务器地址)
enabled=
1
#这个选项表示这个repo中定义的源是启用的,
0
为禁用
gpgcheck=
1
#
这个选项表示这个repo中下载的rpm将进行gpg的校验,已确定rpm包的来源是有效和安全的
gpgkey=file:
///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#定义用于校验的gpg密钥
1
#yum -y install createrepo
1
#createrepo 软件包文件目录
1
#mkdir /mnt/cdrom
1
#mount -t iso9660 /dev/cdrom /mnt/cdrom
1
#ls /mnt/cdrom
1
2
3
4
5
6
7
8
9
[root@LinuxHost yum.repos.d]# mkdir /mnt/cdrom
[root@LinuxHost yum.repos.d]# mount -t iso9660 /dev/cdrom /mnt/cdrom
mount: block device /dev/sr0
is
write-
protected
, mounting read-only
[root@LinuxHost yum.repos.d]# ls /mnt/cdrom
CentOS_BuildTag isolinux RPM-GPG-KEY-CentOS-Debug-
6
EFI Packages RPM-GPG-KEY-CentOS-Security-
6
EULA RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Testing-
6
GPL repodata TRANS.TBL
images RPM-GPG-KEY-CentOS-
6
1
#cd /etc/yum.repos.d/
1
#ls
1
2
#mv CentOS-Base.repo CentOS-Base.repo.bak
#mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.bak
1
#vi CentOS-Media.repo
1
2
3
4
5
6
7
[root@LinuxHost yum.repos.d]# cat CentOS-Media.repo
[C6-Media]
name=CentOS-$releaserver-Media
baseurl=file:
///mnt/cdrom
gpcheck=
1
enabled=
1
gpgkey=file:
///mnt/cdrom/RPM-GPG-KEY-CentOS-6
1
2
3
4
5
6
[root@LinuxHost yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
repo id repo name status
C6-Media CentOS-$releaserver-Media
6
,
518
repolist:
6
,
518
1
2
直接安装包(可指定版本号)
yum install packages -y
1
yum list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@LinuxHost yum.repos.d]# yum list |more
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
Installed Packages
ConsoleKit.x86_64
0.4
.
1
-
3
.el6 @anaconda-Cen
tOS-
201410241409
.x86_64/
6.6
ConsoleKit-libs.x86_64
0.4
.
1
-
3
.el6 @anaconda-Cen
tOS-
201410241409
.x86_64/
6.6
ConsoleKit-x11.x86_64
0.4
.
1
-
3
.el6 @anaconda-Cen
tOS-
201410241409
.x86_64/
6.6
DeviceKit-power.x86_64
014
-
3
.el6 @anaconda-Cen
tOS-
201410241409
.x86_64/
6.6
GConf2.x86_64
2.28
.
0
-
6
.el6 @anaconda-Cen
tOS-
201410241409
.x86_64/
6.6
1
yum repolist
1
2
3
4
5
6
[root@LinuxHost yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
repo id repo name status
C6-Media CentOS-$releaserver-Media
6
,
518
repolist:
6
,
518
1
2
3
--disablerepo=name repolist禁用某个仓库,优先级高于配置文件定义的
--enablerepo=name repolist启用某个仓库,优先级高于配置文件定义的
yum list {all|installed|available}显示选项后可以使用globbing通配符
1
yum clean all
1
2
3
4
5
[root@LinuxHost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: C6-Media
Cleaning up Everything
Cleaning up list of fastest mirrors
1
yum makecache
1
yum update packages
1
yum downgrade packages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
[root@LinuxHost dvd]# rpm -Uvh zsh-
4.3
.
10
-
8
.el6_5.x86_64.rpm
Preparing... ########################################### [
100
%]
1
:zsh ########################################### [
100
%]
[root@LinuxHost dvd]# yum downgrade zsh
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Downgrade Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package zsh.x86_64
0
:
4.3
.
10
-
7
.el6 will be a downgrade
---> Package zsh.x86_64
0
:
4.3
.
10
-
8
.el6_5 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================
Package Arch Version Repository Size
========================================================================================
Downgrading:
zsh x86_64
4.3
.
10
-
7
.el6 C6-Media
2.1
M
Transaction Summary
========================================================================================
Downgrade
1
Package(s)
Total download size:
2.1
M
Is
this
ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : zsh-
4.3
.
10
-
7
.el6.x86_64
1
/
2
Cleanup : zsh-
4.3
.
10
-
8
.el6_5.x86_64
2
/
2
Verifying : zsh-
4.3
.
10
-
7
.el6.x86_64
1
/
2
Verifying : zsh-
4.3
.
10
-
8
.el6_5.x86_64
2
/
2
Removed:
zsh.x86_64
0
:
4.3
.
10
-
8
.el6_5
Installed:
zsh.x86_64
0
:
4.3
.
10
-
7
.el6
Complete!
[root@LinuxHost dvd]# rpm -qa zsh
zsh-
4.3
.
10
-
7
.el6.x86_64
1
yum remove|erease packages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[root@LinuxHost dvd]# yum remove zsh
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package zsh.x86_64
0
:
4.3
.
10
-
7
.el6 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================
Package Arch Version Repository Size
========================================================================================
Removing:
zsh x86_64
4.3
.
10
-
7
.el6 @C6-Media
4.8
M
Transaction Summary
========================================================================================
Remove
1
Package(s)
Installed size:
4.8
M
Is
this
ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : zsh-
4.3
.
10
-
7
.el6.x86_64
1
/
1
Verifying : zsh-
4.3
.
10
-
7
.el6.x86_64
1
/
1
Removed:
zsh.x86_64
0
:
4.3
.
10
-
7
.el6
Complete!
[root@LinuxHost dvd]# rpm -qa zsh
1
yum info packages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[root@LinuxHost dvd]# yum info zsh
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Available Packages
Name : zsh
Arch : x86_64
Version :
4.3
.
10
Release :
7
.el6
Size :
2.1
M
Repo : C6-Media
Summary : A powerful interactive shell
URL : http:
//zsh.sunsite.dk/
License : BSD
Description : The zsh shell
is
a command interpreter usable
as
an interactive login
: shell and
as
a shell script command processor. Zsh resembles the ksh
: shell (the Korn shell), but includes many enhancements. Zsh supports
: command line editing, built-
in
spelling correction, programmable
: command completion, shell functions (
with
autoloading), a history
: mechanism, and more.
1
yum search KEYWORD
1
2
3
4
5
6
7
8
[root@LinuxHost dvd]# yum search zsh
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
=================================== N/S Matched: zsh ===================================
python-twisted-core-zsh.x86_64 : Tab completion
for
Zsh and Twisted Core
zsh-html.x86_64 : Zsh shell manual
in
html format
zsh.x86_64 : A powerful interactive shell
Name and summary matches only,
use
"search all"
for
everything.
1
yum provides|whatprovides /path/file
1
2
3
4
5
6
7
8
9
10
11
[root@LinuxHost dvd]# yum provides /usr/bin/yum
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
yum-
3.2
.
29
-
60
.el6.centos.noarch : RPM
package
installer/updater/manager
Repo : C6-Media
Matched from:
Filename : /usr/bin/yum
yum-
3.2
.
29
-
60
.el6.centos.noarch : RPM
package
installer/updater/manager
Repo : installed
Matched from:
Other : Provides-match: /usr/bin/yum
1
yum grouplist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[root@LinuxHost dvd]# yum grouplist |more
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Group Process
Loading mirror speeds from cached hostfile
Installed Groups:
Additional Development
Base
Console internet tools
Desktop
Development tools
Dial-up Networking Support
Directory Client
E-mail server
Fonts
General Purpose Desktop
Graphical Administration Tools
Hardware monitoring utilities
Input Methods
Legacy UNIX compatibility
Legacy X Window System compatibility
NFS file server
Network Infrastructure Server
Network file system client
Networking Tools
Performance Tools
Perl Support
Security Tools
System administration tools
Web Server
X Window System
Installed Language Groups:
--More--
1
yum groupinfo “group_name"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[root@LinuxHost dvd]# yum groupinfo
"Development tools"
|more
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Group Process
Loading mirror speeds from cached hostfile
Group: Development tools
Description: A basic development environment.
Mandatory Packages:
autoconf
automake
binutils
bison
flex
gcc
gcc-c++
gettext
libtool
make
patch
pkgconfig
redhat-rpm-config
rpm-build
Default Packages:
byacc
cscope
ctags
cvs
diffstat
doxygen
elfutils
gcc-gfortran
--More--
信息太多省略
1
2
yum groupinstall
"group_name"
yum install @group_name
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@LinuxHost dvd]# yum groupinstall
"Server Platform Development"
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Group Process
Loading mirror speeds from cached hostfile
Package zlib-devel-
1.2
.
3
-
29
.el6.x86_64 already installed and latest version
Package glibc-devel-
2.12
-
1.149
.el6.x86_64 already installed and latest version
Package libstdc++-devel-
4.4
.
7
-
11
.el6.x86_64 already installed and latest version
Package ncurses-devel-
5.7
-
3.20090208
.el6.x86_64 already installed and latest version
Package
1
:dbus-devel-
1.2
.
24
-
7
.el6_3.x86_64 already installed and latest version
Package db4-devel-
4.7
.
25
-
18
.el6_4.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package krb5-devel.x86_64
0
:
1.10
.
3
-
33
.el6 will be installed
省略。。。。。。。
1
2
yum groupremove
"group_name"
yum remove @group_name
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@LinuxHost dvd]# yum groupremove
"Server Platform Development"
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Group Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package db4-devel.x86_64
0
:
4.7
.
25
-
18
.el6_4 will be erased
--> Processing Dependency: db4-devel
for
package
:
4
:perl-devel-
5.10
.
1
-
136
.el6.x86_64
---> Package dbus-devel.x86_64
1
:
1.2
.
24
-
7
.el6_3 will be erased
---> Package glibc-devel.x86_64
0
:
2.12
-
1.149
.el6 will be erased
--> Processing Dependency: glibc-devel >=
2.2
.
90
-
12
for
package
: gcc-
4.4
.
7
-
11
.el6.x86_64
---> Package libstdc++-devel.x86_64
0
:
4.4
.
7
-
11
.el6 will be erased
--> Processing Dependency: libstdc++-devel =
4.4
.
7
-
11
.el6
for
package
: gcc-c++-
4.4
.
7
-
11
.el6.x86_64
省略。。。。。。
1
yum groupupdate
"group_name"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@LinuxHost dvd]# yum groupupdate
"Server Platform Development"
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Group Process
Loading mirror speeds from cached hostfile
Package zlib-devel-
1.2
.
3
-
29
.el6.x86_64 already installed and latest version
Package glibc-devel-
2.12
-
1.149
.el6.x86_64 already installed and latest version
Package libstdc++-devel-
4.4
.
7
-
11
.el6.x86_64 already installed and latest version
Package ncurses-devel-
5.7
-
3.20090208
.el6.x86_64 already installed and latest version
Package
1
:dbus-devel-
1.2
.
24
-
7
.el6_3.x86_64 already installed and latest version
Package db4-devel-
4.7
.
25
-
18
.el6_4.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package krb5-devel.x86_64
0
:
1.10
.
3
-
33
.el6 will be installed
--> Processing Dependency: libselinux-devel
for
package
: krb5-devel-
1.10
.
3
-
33
.el6.x86_64
省略
1
yum localinstall packages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@LinuxHost dvd]# yum localinstall zsh-
4.3
.
10
-
8
.el6_5.x86_64.rpm
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Local Package Process
Examining zsh-
4.3
.
10
-
8
.el6_5.x86_64.rpm: zsh-
4.3
.
10
-
8
.el6_5.x86_64
Marking zsh-
4.3
.
10
-
8
.el6_5.x86_64.rpm to be installed
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package zsh.x86_64
0
:
4.3
.
10
-
8
.el6_5 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================
Package Arch Version Repository Size
========================================================================================
Installing:
zsh x86_64
4.3
.
10
-
8
.el6_5 /zsh-
4.3
.
10
-
8
.el6_5.x86_64
4.8
M
Transaction Summary
========================================================================================
Install
1
Package(s)
Total size:
4.8
M
Installed size:
4.8
M
Is
this
ok [y/N]:
省略信息。。。。。。
1
yum localinstall packages --nogpgcheck
1
yum check-update
1
2
3
[root@LinuxHost dvd]# yum check-update
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
1
yum reinstall packages
1
yum deplist packages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[root@LinuxHost dvd]# yum deplist python
Loaded plugins: fastestmirror, refresh-packagekit, security
Finding dependencies:
Loading mirror speeds from cached hostfile
package
: python.x86_64
2.6
.
6
-
52
.el6
dependency: python-libs(x86-
64
) =
2.6
.
6
-
52
.el6
provider: python-libs.x86_64
2.6
.
6
-
52
.el6
dependency: libutil.so.
1
()(64bit)
provider: glibc.x86_64
2.12
-
1.149
.el6
dependency: libdl.so.
2
()(64bit)
provider: glibc.x86_64
2.12
-
1.149
.el6
dependency: rtld(GNU_HASH)
provider: glibc.x86_64
2.12
-
1.149
.el6
provider: glibc.i686
2.12
-
1.149
.el6
dependency: libm.so.
6
()(64bit)
provider: glibc.x86_64
2.12
-
1.149
.el6
dependency: libpython2.
6
.so.
1.0
()(64bit)
provider: python-libs.x86_64
2.6
.
6
-
52
.el6
dependency: libpthread.so.
0
()(64bit)
provider: glibc.x86_64
2.12
-
1.149
.el6
dependency: libc.so.
6
(GLIBC_2.
2.5
)(64bit)
provider: glibc.x86_64
2.12
-
1.149
.el6
1
yum history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@LinuxHost dvd]# yum history
Loaded plugins: fastestmirror, refresh-packagekit, security
ID | Login user |
Date
and time | Action(s) | Altered
-------------------------------------------------------------------------------
19
| root <root> |
2014
-
11
-
26
02
:
51
| Erase |
1
18
| root <root> |
2014
-
11
-
26
02
:
49
| Downgrade |
1
<
17
| root <root> |
2014
-
11
-
25
07
:
08
| Install |
1
>
16
| root <root> |
2014
-
11
-
25
06
:
46
| Install |
3
15
| root <root> |
2014
-
11
-
25
04
:
02
| Install |
1
14
| root <root> |
2014
-
11
-
24
13
:
35
| Install |
3
13
| root <root> |
2014
-
11
-
24
13
:
14
| Install |
1
12
| root <root> |
2014
-
11
-
24
12
:
13
| Install |
1
11
| root <root> |
2014
-
11
-
24
12
:
12
| Install |
10
10
| root <root> |
2014
-
11
-
24
12
:
10
| Install |
34
9
| root <root> |
2014
-
11
-
24
11
:
43
| Install |
1
8
| root <root> |
2014
-
11
-
24
11
:
12
| Install |
15
7
| root <root> |
2014
-
11
-
24
11
:
11
| Install |
1
6
| root <root> |
2014
-
11
-
24
08
:
58
| Install |
33
<
5
| root <root> |
2014
-
11
-
21
13
:
14
| Install |
1
>
4
| root <root> |
2014
-
11
-
12
20
:
21
| Install |
1
3
| root <root> |
2014
-
11
-
12
19
:
25
| Install |
1
2
| root <root> |
2014
-
11
-
12
11
:
14
| Install |
5
1
| System <unset> |
2014
-
11
-
12
09
:
42
| Install |
988
history list
1
yum check
1
2
3
[root@LinuxHost dvd]# yum check
Loaded plugins: fastestmirror, refresh-packagekit, security
check all
0 0
- Linux下程序包管理之YUM
- Linux程序包管理rpm与yum
- Linux程序包管理rpm与yum
- Linux程序包管理rpm与yum
- Linux程序包管理rpm与yum
- Linux程序包管理:RPM和YUM
- Linux程序包管理之RPM
- 程序包管理yum&&编译篇
- linux 程序包管理工具yum使用
- linux程序包管理
- Linux软件包管理之YUM
- Linux命令之软件管理--yum
- Linux RPM之yum在线管理
- 程序包管理前端工具yum的使用详解
- Linux学习之软件包管理--yum在线管理
- linux程序包管理命令rpm使用
- 程序包管理
- Linux软件管理-YUM
- Oracle如果需要输出引号或执行字符串里面的语句需要引号
- JSCharts 3 去掉LOGO的一种简单的解决方案
- iOS基础3:手势识别之谈
- Android瀑布流StaggeredGridView学习研究
- ios学习资料
- Linux下程序包管理之YUM
- c#实现md5加密16位及32位
- The Python Tutorial 3——An Informal Introduction to Python
- 确保对象的唯一性——单例模式
- Jass 技能模型定义(—):半人马酋长的反击光环
- 关于在安卓开发中百度地图功能不能实现定位。
- Native wifi API使用
- Spring+ActiveMQ+maven
- Unity3D类和方法