Linux distribution | 软件管理机制 | 使用命令 | 在线升级机制(命令) |
RPM | rmp,rpmbuild | YUM(yum) | |
Debian/Ubuntu | DPKG | dpkg | APT(apt-get) |
文件格式 | 文件名格式 | 直接安装与否 | 内含程序类型 | 可否修改参数并编译 |
RPM | xxx.rpm | 可 | 已编译 | 不可 |
SRPM | xxx.src.rpm | 不可 | 未编译的源代码 | 可 |
rp-rpppoe | 3.1 | 5 | i386 | rpm |
软件名称 | 软件版本信息 | 发布次数 | 适合硬件平台 | 扩展名 |
1
|
/
var
/lib/rpm
|
1
2
3
4
|
/etc 设置文件放置目录
/usr/bin 一些程序使用的动态函数库
/usr/share/doc 一些基本软件的使用手册与帮助文档
/usr/share/man 一引起man page文件
|
1
2
3
4
5
6
7
8
|
[root@xpleaf ~]# rpm -ivh pam-devel-
1.1
.
1
-
17
.el6.x86_64.rpm
i:install
v:view,显示详细安装信息画面
h:以安装信息栏显示安装进度(显示
50
个“#”)
[root@xpleaf ~]# rpm -ivh pam-devel*.rpm ===>安装以pam-devel开头的多个RPM包
[root@xpleaf ~]# rpm -ivh http:
//website.name/path/pkgname.rpm ===>安装网络上的RPM包
|
1
2
3
4
5
|
--replacefiles 覆盖安装
--replacepkgs 重复安装
--force 强制安装,上面两个参数的结合
--test 检测需要安装的软件依赖性问题
[root@xpleaf ~]# rpm -ivh pam-devel-
1.1
.
1
-
17
.el6.x86_64.rpm --test
|
1
2
3
4
5
6
7
8
9
10
11
|
[root@xpleaf ~]# mount /dev/cdrom /mnt ===>挂载光盘到/mnt
mount: block device /dev/sr0
is
write-
protected
, mounting read-only
[root@xpleaf ~]# find /mnt -name
"pam-devel*"
===>查找pam-devel软件
/mnt/Packages/pam-devel-
1.1
.
1
-
17
.el6.i686.rpm
/mnt/Packages/pam-devel-
1.1
.
1
-
17
.el6.x86_64.rpm
[root@xpleaf ~]# cp -a /mnt/Packages/pam-devel-
1.1
.
1
-
17
.el6.x86_64.rpm /root
[root@xpleaf ~]# rpm -ivh pam-devel-
1.1
.
1
-
17
.el6.x86_64.rpm --test ===>检测依赖软件
Preparing... ########################################### [
100
%]
[root@xpleaf ~]# rpm -ivh pam-devel-
1.1
.
1
-
17
.el6.x86_64.rpm ===>安装
Preparing... ########################################### [
100
%]
1
:pam-devel ########################################### [
100
%]
|
1
2
3
|
[root@xpleaf ~]# rpm -ivh pam-devel-
1.1
.
1
-
17
.el6.x86_64.rpm
Preparing... ########################################### [
100
%]
package
pam-devel-
1.1
.
1
-
17
.el6.x86_64
is
already installed
|
参数 | 区别 |
-Uvh | 如果没有安装该软件,则直接安装;如果安装的是旧版,则升级 |
-Fvh | 如果没有安装该软件,不予以安装;如果安装的是旧版,则升级 |
1
|
rpm -Uvh/-Fvh RPM文件名
|
1
2
3
4
|
rpm -qa ===>查询本机已安装的软件
rpm -q[ilcdR] 已安装的软件名称 ===>查询已安装软件的特定信息
rpm -qf 存在于系统上的某个文件名 ===>查询文件的所属安装软件
rpm -qp[ilcdR] 未安装的RPM包完整名称 ===>查询RMP包的特定信息(与上面类似,只是安装与未安装)
|
参数 | 说明 |
-q | |
-qa |
列出所有的已经安装在本机 Linux 系统上面的所有软件名称 |
-qi |
列出该软件的详绅信息 (information),包含开发商、版本与说明等 |
-ql |
列出该软件所有的文件与目录所在完整文件名(list) |
-qc |
列出该软件的所有配置文件 (找出在/etc/下面的文件名而已) |
-qd |
列出该软件的所有帮助文件 (找出与man有关的文件而已) |
-qR |
列出与该软件有关的依赖软件所含的文件(Required 的意思) |
-qf |
由后面接的文件名找出该文件属于哪一个已安装的软件 |
1
|
-qp[icdlR]:-qp后面接的所有参数以上面的说明一致,但仅用于找出某个RPM文件内的信息,而非已安装的软件信息
|
1
2
|
[root@xpleaf ~]# rpm -q python
python-
2.6
.
6
-
51
.el6.x86_64
|
1
2
3
4
5
6
7
8
9
|
[root@xpleaf ~]# rpm -ql python
/usr/bin/pydoc
/usr/bin/python
/usr/bin/python2
/usr/bin/python2.
6
/usr/share/doc/python-
2.6
.
6
/usr/share/doc/python-
2.6
.
6
/LICENSE
/usr/share/doc/python-
2.6
.
6
/README
/usr/share/man/man1/python.
1
.gz
|
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
|
[root@xpleaf ~]# rpm -qi python
Name : python Relocations: (not relocatable)
Version :
2.6
.
6
Vendor: CentOS
Release :
51
.el6 Build
Date
: Fri
22
Nov
2013
08
:
18
:
53
PM CST
Install
Date
: Mon
11
May
2015
10
:
21
:
27
PM CST Build Host: c6b8.bsys.dev.centos.org
Group : Development/Languages Source RPM: python-
2.6
.
6
-
51
.el6.src.rpm
Size :
79603
License: Python
Signature : RSA/SHA1, Mon
25
Nov
2013
03
:
33
:
16
AM CST, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http:
//bugs.centos.org>
URL : http:
//www.python.org/
Summary : An interpreted, interactive, object-oriented programming language
Description :
Python
is
an interpreted, interactive, object-oriented programming
language often compared to Tcl, Perl, Scheme or Java. Python includes
modules, classes, exceptions, very high level
dynamic
data types and
dynamic
typing. Python supports interfaces to many system calls and
libraries,
as
well
as
to
var
ious windowing systems (X11, Motif, Tk,
Mac and MFC).
Programmers can write
new
built-
in
modules
for
Python
in
C or C++.
Python can be used
as
an extension language
for
applications that need
a programmable
interface
.
Note that documentation
for
Python
is
provided
in
the python-docs
package
.
This
package
provides the
"python"
executable; most of the actual
implementation
is
within the
"python-libs"
package
.
|
1
2
3
|
[root@xpleaf ~]# rpm -qc logrotate
/etc/logrotate.conf
/
var
/lib/logrotate.status
|
1
2
3
4
5
|
[root@xpleaf ~]# rpm -qd logrotate
/usr/share/doc/logrotate-
3.7
.
8
/CHANGES
/usr/share/doc/logrotate-
3.7
.
8
/COPYING
/usr/share/man/man5/logrotate.conf.
5
.gz
/usr/share/man/man8/logrotate.
8
.gz
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@xpleaf ~]# rpm -qR python
/usr/bin/python2.
6
libc.so.
6
()(64bit)
libc.so.
6
(GLIBC_2.
2.5
)(64bit)
libdl.so.
2
()(64bit)
libm.so.
6
()(64bit)
libpthread.so.
0
()(64bit)
libpython2.
6
.so.
1.0
()(64bit)
libutil.so.
1
()(64bit)
python-libs(x86-
64
) =
2.6
.
6
-
51
.el6
rpmlib(CompressedFileNames) <=
3.0
.
4
-
1
rpmlib(FileDigests) <=
4.6
.
0
-
1
rpmlib(PartialHardlinkSets) <=
4.0
.
4
-
1
rpmlib(PayloadFilesHavePrefix) <=
4.0
-
1
rpmlib(VersionedDependencies) <=
3.0
.
3
-
1
rtld(GNU_HASH)
rpmlib(PayloadIsXz) <=
5.2
-
1
|
1
2
|
[root@xpleaf ~]# rpm -qf /usr/bin/python2.
6
python-
2.6
.
6
-
51
.el6.x86_64
|
1
2
3
4
5
6
7
8
|
[root@xpleaf ~]# rpm -qpR crontabs-
1.10
-
33
.el6.noarch.rpm
/bin/bash
/etc/cron.d
config(crontabs) =
1.10
-
33
.el6
rpmlib(CompressedFileNames) <=
3.0
.
4
-
1
rpmlib(FileDigests) <=
4.6
.
0
-
1
rpmlib(PayloadFilesHavePrefix) <=
4.0
-
1
rpmlib(PayloadIsXz) <=
5.2
-
1
|
1
2
|
[root@xpleaf ~]# rpm -qa | grep ^c | wc -l
52
|
1
|
[root@xpleaf ~]# rpm -e pam-devel
|
1
|
[root@xpleaf ~]# rpm --rebuilddb
|
1
2
|
--rebuild 对SRPM文件编译,并打包成为RPM包,但不安装
--recompile 对SRPM文件编译,打包成RPM包,并安装
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
root@xpleaf ~]# rpmbuild --rebuild setarch-
1.3
-
1
.src.rpm ===>使用--rebuild参数制作RPM包
Installing setarch-
1.3
-
1
.src.rpm
……省略输出
+ exit
0
[root@xpleaf ~]# ls -l rpmbuild/
total
24
drwxr-xr-x
2
root root
4096
Aug
17
20
:
08
BUILD
drwxr-xr-x
2
root root
4096
Aug
17
20
:
08
BUILDROOT
drwxr-xr-x
3
root root
4096
Aug
17
20
:
08
RPMS
drwxr-xr-x
2
root root
4096
Aug
17
20
:
08
SOURCES
drwxr-xr-x
2
root root
4096
Aug
17
20
:
08
SPECS
drwxr-xr-x
2
root root
4096
Aug
17
20
:
08
SRPMS
===>上面这些目录即是SRPM使用的路径
[root@xpleaf ~]# cd rpmbuild/RPMS/x86_64/ ===>RPM包放在这里
[root@xpleaf x86_64]# ll
total
12
-rw-r--r--
1
root root
6704
Aug
17
20
:
08
setarch-
1.3
-
1
.x86_64.rpm
-rw-r--r--
1
root root
1912
Aug
17
20
:
08
setarch-debuginfo-
1.3
-
1
.x86_64.rpm
|
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
|
[root@xpleaf ~]# rpmbuild --rebuild setarch-
1.3
-
1
.src.rpm
……
+ cd /root/rpmbuild/BUILD
+ rm -rf setarch-
1.3
……
+ rm -rf /root/rpmbuild/BUILDROOT/setarch-
1.3
-
1
.x86_64
……
+ rm -rf /root/rpmbuild/BUILDROOT/setarch-
1.3
-
1
.x86_64
……
+ cd /root/rpmbuild/BUILD
+ cd setarch-
1.3
+ rm -rf /root/rpmbuild/BUILDROOT/setarch-
1.3
-
1
.x86_64
……
+ cd /root/rpmbuild/BUILD
+ rm -rf setarch-
1.3
……
[root@xpleaf rpmbuild]# ls -l BUILD BUILDROOT/ RPMS/ SOURCES/ SPECS/ SRPMS/
BUILD:
total
0
BUILDROOT/:
total
0
RPMS/:
total
4
drwxr-xr-x
2
root root
4096
Aug
17
20
:
00
x86_64
SOURCES/:
total
4
-rw-r--r--.
1
root root
2220
Sep
2
2003
setarch-
1.3
.tar.gz
SPECS/:
total
4
-rw-r--r--.
1
root root
1440
Sep
2
2003
setarch.spec
SRPMS/:
total
0
|
目录 | 说明 |
SPECS | 放置软件的设置文件,如软件的信息参数、设置项目 |
SOURCES | 放置软件的源文件(*.tar.gz)及config设置文件 |
BUILD/BUILDROOT | 放置编译过程中产生的临时文件 |
RPMS | 编译完成后,放置RPM包。下面会有子目录如x86_64、i386等 |
SRPM | 放置自己制作的SRPM包 |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[root@xpleaf ~]# rpm -i logrotate-
3.7
.
8
-
12
.el6.src.rpm
……
[root@xpleaf ~]# cd rpmbuild/
[root@xpleaf rpmbuild]# ll
total
8
drwxr-xr-x
2
root root
4096
Aug
17
20
:
35
SOURCES
drwxr-xr-x
2
root root
4096
Aug
17
20
:
35
SPECS
[root@xpleaf rpmbuild]# find ./ -type f
./SPECS/logrotate.spec ===>设置文件
./SOURCES/logrotate-
3.7
.
8
-man5.patch ===>.patch的即是一些补丁文件
./SOURCES/logrotate-
3.7
.
8
-devnull.patch
./SOURCES/logrotate-
3.7
.
8
-configsize.patch
./SOURCES/logrotate-
3.7
.
7
-toolarge.patch
./SOURCES/logrotate-
3.7
.
8
.tar.gz ===>源代码文件压缩包
./SOURCES/logrotate-
3.7
.
8
-dont-remove-log.patch
./SOURCES/logrotate-
3.7
.
8
-handle-rename-error.patch
./SOURCES/logrotate-
3.7
.
8
-scripts-man.patch
./SOURCES/logrotate-
3.7
.
8
-missingok.patch
./SOURCES/logrotate-
3.7
.
8
-scripts-args.patch
./SOURCES/logrotate-
3.7
.
7
-curdir2.patch
===>如果还有其它文件,则可能是一些脚本文件
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
Summary: Rotates, compresses, removes and mails system log files
Name: logrotate ===>RPM名字类似:{Name}-{Version}-{Release}.rpm
Version:
3.7
.
8
Release:
12
%{?dist}
License: GPL+
URL: https:
//fedorahosted.org/logrotate/
Group: System Environment/Base
Source: https:
//fedorahosted.org/releases/l/o/logrotate/logrotate-%{version}.tar.gz
Patch1: logrotate-
3.7
.
7
-curdir2.patch ===>即是前面在SOURCES中看到的一些补丁文件
Patch2: logrotate-
3.7
.
7
-toolarge.patch ===>意在说明该软件SRPM包中含有的文件
Patch3: logrotate-
3.7
.
8
-devnull.patch
Patch4: logrotate-
3.7
.
8
-man5.patch
Patch5: logrotate-
3.7
.
8
-missingok.patch
Patch6: logrotate-
3.7
.
8
-configsize.patch
Patch7: logrotate-
3.7
.
8
-dont-remove-log.patch
Patch8: logrotate-
3.7
.
8
-scripts-args.patch
Patch9: logrotate-
3.7
.
8
-scripts-man.patch
Patch10: logrotate-
3.7
.
8
-handle-rename-error.patch
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
Requires: coreutils >=
5.92
libsepol libselinux popt ===>需要的软件,即依赖软件
BuildRequires: libselinux-devel popt-devel ===>编译时需求的工具软件
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)===>编译时临时文件存放的目录
%description ===>软件描述信息
The logrotate utility
is
designed to simplify the administration of
log files on a system which generates a lot of log files. Logrotate
allows
for
the automatic rotation compression, removal and mailing of
log files. Logrotate can be
set
to handle a log file daily, weekly,
monthly or when the log file gets to a certain size. Normally,
logrotate runs
as
a daily cron job.
Install the logrotate
package
if
you need a utility to deal
with
the
log files on your system.
|
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
|
%prep ===>预处理,就是上面的patch补丁文件
%setup -q
%patch1 -p1 -b .curdir
%patch2 -p1 -b .toolarge
%patch3 -p1 -b .devnull
%patch4 -p1 -b .man5
%patch5 -p1 -b .missingok
%patch6 -b .configsize
%patch7 -b .dont-remove-log
%patch8 -b .scripts-args
%patch9 -b .scripts-man
%patch10 -b .handle-rename-error
%build ===>编译
make %{?_smp_mflags} RPM_OPT_FLAGS=
"$RPM_OPT_FLAGS"
WITH_SELINUX=yes
%install ===>安装
rm -rf $RPM_BUILD_ROOT
make PREFIX=$RPM_BUILD_ROOT MANDIR=%{_mandir} install
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/cron.daily
mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib
install -p -m
644
examples/logrotate-
default
$RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.conf
install -p -m
755
examples/logrotate.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.daily/logrotate
touch $RPM_BUILD_ROOT/%{_localstatedir}/lib/logrotate.status
%clean ===>清理删除临时文件
rm -rf $RPM_BUILD_ROOT
|
1
2
3
4
5
6
7
8
9
10
|
%files
%defattr(-,root,root)
%doc CHANGES COPYING
%attr(
0755
, root, root) %{_sbindir}/logrotate
%attr(
0644
, root, root) %{_mandir}/man8/logrotate.
8
*
%attr(
0644
, root, root) %{_mandir}/man5/logrotate.conf.
5
*
%attr(
0755
, root, root) %{_sysconfdir}/cron.daily/logrotate
%attr(
0644
, root, root) %config(noreplace) %{_sysconfdir}/logrotate.conf
%attr(
0755
, root, root) %dir %{_sysconfdir}/logrotate.d
%attr(
0644
, root, root) %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/logrotate.status
|
1
2
3
4
5
6
7
8
9
10
11
|
……
Tue Jun
15
2010
Jan Kaluza <jkaluza@redhat.com>
3.7
.
8
-
9
- fix #
604073
-
do
not remove log
if
there
is
an error
in
rotate process
* Fri Jun
11
2010
Jan Kaluza <jkaluza@redhat.com>
3.7
.
8
-
8
- fix #
602654
- fix integer overflow
in
size and minsize
* Tue Apr
06
2010
Daniel Novotny <dnovotny@redhat.com>
3.7
.
8
-
7
- fix #
578116
- missingok problem
with
globs
……
|
1
2
|
[root@xpleaf SPECS]# rpmbuild -ba setarch.spec ===>编译并同时生成RPM与SRPM文件
[root@xpleaf SPECS]# rpmbuild -bb setarch.spec ===>编译只生成RPM文件
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@xpleaf ~]# cd rpmbuild/
[root@xpleaf rpmbuild]# ll
total
8
drwxr-xr-x
2
root root
4096
Aug
17
22
:
02
SOURCES
drwxr-xr-x
2
root root
4096
Aug
17
22
:
02
SPECS
[root@xpleaf rpmbuild]# cd SPECS/
[root@xpleaf SPECS]# ll
total
4
-rw-r--r--.
1
root root
1440
Sep
2
2003
setarch.spec
[root@xpleaf SPECS]# rpmbuild -ba setarch.spec
……
[root@xpleaf rpmbuild]# find ./ -name
"*.rpm"
./RPMS/x86_64/setarch-
1.3
-
1
.x86_64.rpm
./RPMS/x86_64/setarch-debuginfo-
1.3
-
1
.x86_64.rpm
./SRPMS/setarch-
1.3
-
1
.src.rpm
|
1
|
yum [option] [查询项目] [相关参数]
|
1
2
|
-y:响应安装过程中的提示输入
--installroot=/some/path:把软件安装在/some/path中
|
1
2
3
4
|
search:搜索软件相关信息,如名称、描述
list:列出yum管理的所有软件(包括安装与未安装的),rpm -qa列出的是本地已安装的
info:查询软件的相关系统
provides:由文件去找出软件
|
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@xpleaf ~]# yum search raid
……
dmraid.i686 : dmraid (Device-mapper RAID tool and library)
dmraid.x86_64 : dmraid (Device-mapper RAID tool and library)
dmraid-devel.x86_64 : Development libraries and headers
for
dmraid.
dmraid-events-logwatch.x86_64 : dmraid logwatch-based email reporting
dmraid-events.x86_64 : dmevent_tool (Device-mapper event tool) and DSO
firstaidkit-plugin-mdadm-conf.noarch : Firstaidkit plugin to diagnose software raid
: configuration file
mdadm.x86_64 : The mdadm program controls Linux md devices (software RAID arrays)
Name and summary matches only,
use
"search all"
for
everything.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[root@xpleaf ~]# yum info mdadm
……
Installed Packages ===>已经安装的软件版本
Name : mdadm
Arch : x86_64
Version :
3.2
.
6
Release :
7
.el6
Size :
847
k
Repo : installed
From repo : anaconda-CentOS-
201311272149
.x86_64
Summary : The mdadm program controls Linux md devices (software RAID arrays)
URL : http:
//www.kernel.org/pub/linux/utils/raid/mdadm/
License : GPLv2+
Description : The mdadm program
is
used to create, manage, and monitor Linux MD (software
: RAID) devices. As such, it provides similar functionality to the raidtools
:
package
. However, mdadm
is
a single program, and it can perform
: almost all functions without a configuration file, though a configuration
: file can be used to help
with
some common tasks.
Available Packages ===>还可以安装的软件版本
Name : mdadm
Arch : x86_64
……
|
1
2
3
4
5
6
7
8
9
10
|
[root@xpleaf ~]# yum list
Installed Packages ===>已经安装的软件
ConsoleKit.x86_64
0.4
.
1
-
3
.el6 @anaconda-CentOS-
201311272149
.x86_64/
6.5
ConsoleKit-libs.x86_64
0.4
.
1
-
3
.el6 @anaconda-CentOS-
201311272149
.x86_64/
6.5
……
Available Packages ===>还可以安装的软件
389
-ds-base.x86_64
1.2
.
11.15
-
60
.el6 base
389
-ds-base-devel.i686
1.2
.
11.15
-
60
.el6 base
389
-ds-base-devel.x86_64
1.2
.
11.15
-
60
.el6 base
……
|
1
2
3
4
5
6
7
|
[root@xpleaf ~]# yum list updates
Updated Packages
abrt.x86_64
2.0
.
8
-
34
.el6.centos base
abrt-addon-ccpp.x86_64
2.0
.
8
-
34
.el6.centos base
abrt-addon-kerneloops.x86_64
2.0
.
8
-
34
.el6.centos base
abrt-addon-python.x86_64
2.0
.
8
-
34
.el6.centos base
……
|
1
2
3
4
5
6
7
8
|
[root@xpleaf ~]# yum provides passwd
passwd-
0.77
-
4
.el6_2.
2
.x86_64 : An utility
for
setting or changing passwords using PAM
Repo : base
Matched from:
passwd-
0.77
-
4
.el6_2.
2
.x86_64 : An utility
for
setting or changing passwords using PAM
Repo : installed
Matched from:
Other : Provides-match: passwd
|
1
2
|
yum install 安装软件名称
yum update 升级软件名称
|
1
|
yum remove 软件名称
|
1
2
|
yum clean all ===>删除已下载过的所有容器的相关数据(含软件本身与列表)
yum makecache ===>生成缓存
|
1
2
3
4
|
grouplist:列出所有的组列表(软件组),包括安装和未安装的,如Development Tools
groupinfo:后面接软件组名称,可以了解软件组内的软件名称
groupinstall:后面接软件组,可以安装一整组软件组
groupremove:删除某个软件组
|