歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux軟件 >> RedHat系Linux軟件包管理

RedHat系Linux軟件包管理

日期:2017/3/1 17:14:17   编辑:Linux軟件

一、RPM包的管理 www.2cto.com   rpm軟件包的一個例子: sudo-1.7.4p5-11.el6.i686.rpm   其中包括軟件名(sudo),版本號(1.7.4p5),發行號(11.el6)和硬件平台(i686)   1、卸載 [root@localhost ~]# rpm -e sudo   如果其它軟件包有依賴關系,卸載時會產生提示信息,可以使用--nodeps強行卸載 [root@localhost ~]# rpm -e --nodeps samba   2、安裝     光盤裡面帶有的軟件包,可以直接從光盤安裝     1)掛載光盤 [root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]#     2)rpm的安裝包都放在Packages目錄中
[root@localhost ~]# cd /mnt/cdrom
[root@localhost cdrom]# ls
CentOS_BuildTag 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
isolinux RPM-GPG-KEY-CentOS-Debug-6
[root@localhost cdrom]#
www.2cto.com     3)找到sudo的安裝包 [root@localhost cdrom]# cd Packages
[root@localhost Packages]# ls | grep sudo
sudo-1.7.4p5-11.el6.i686.rpm
[root@localhost Packages]#     4)執行安裝 [root@localhost Packages]# rpm -ivh sudo-1.7.4p5-11.el6.i686.rpm
warning: sudo-1.7.4p5-11.el6.i686.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:sudo ########################################### [100%]
[root@localhost Packages]#     5)查詢軟件包是否已安裝 [root@localhost Packages]# rpm -q sudo
sudo-1.7.4p5-11.el6.i686
[root@localhost Packages]#     沒有安裝的會給出提示 [root@localhost ~]# rpm -q samba
package samba is not installed
[root@localhost ~]#     6)--excludedocs 不安裝軟件包中的文檔文件 [root@localhost Packages]# rpm -ivh --excludedocs sudo-1.7.4p5-11.el6.i686.rpm     7)--prefix PATH 將軟件包安裝到由PATH指定的路徑下 [root@localhost Packages]# rpm -ivh --prefix=/usr/local/sudo sudo-1.7.4p5-11.el6.i686.rpm     不過指定rpm包的安裝路徑意義不大,rpm一般都不允許改變安裝目錄,rpm包在設計的時候就已經指定好相應的安裝目錄了 www.2cto.com     8)--test 只對安裝進行測試,並不實際安裝 [root@localhost Packages]# rpm -ivh --test sudo-1.7.4p5-11.el6.i686.rpm     9)軟件包已被安裝 [root@localhost Packages]# rpm -ivh sudo-1.7.4p5-11.el6.i686.rpm
warning: sudo-1.7.4p5-11.el6.i686.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
package sudo-1.7.4p5-11.el6.i686 is already installed
[root@localhost Packages]#     如果要覆蓋安裝該軟件包,可以使用--replacepkgs選項 [root@localhost Packages]# rpm -ivh --replacepkgs sudo-1.7.4p5-11.el6.i686.rpm
warning: sudo-1.7.4p5-11.el6.i686.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:sudo ########################################### [100%]
[root@localhost Packages]#     10)文件沖突     如果要安裝的軟件包中有一個文件已在安裝其它軟件包是安裝了,就會出現文件沖突,可以使用--replacefiles選項 [root@localhost Packages]# rpm -ivh --replacefiles sudo-1.7.4p5-11.el6.i686.rpm     11)未解決依賴關系     RPM軟件包可能依賴於其它軟件包,在安裝了依賴的軟件包之後才能安裝該軟件包。強制安裝使用--nodeps選項,如果依賴包沒安裝,強制安裝的軟件一般用不了。   3、升級     比如升級到 sudo-1.8.0p5-11.el6.i686.rpm [root@localhost Packages]# rpm -Uvh sudo-1.8.0p5-11.el6.i686.rpm 二、YUM包管理   應用yum包的好處:     自動解決軟件包依賴關系     方便的軟件包升級   1、安裝 yum install (需要網絡訪問)
[root@bogon ~]# yum install sudo
Loaded plugins: fastestmirror, security
Determining fastest mirrors
* base: mirror.neu.edu.cn
* extras: mirror.neu.edu.cn
* updates: mirror.neu.edu.cn
base | 3.7 kB 00:00
base/primary_db | 3.5 MB 00:07
extras | 3.5 kB 00:00
extras/primary_db | 24 kB 00:00
updates | 3.5 kB 00:00
updates/primary_db | 3.8 MB 00:08
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package sudo.i686 0:1.7.4p5-13.el6_3 will be installed
--> Finished Dependency Resolution Dependencies Resolved ================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
sudo i686 1.7.4p5-13.el6_3 updates 419 k Transaction Summary
================================================================================
Install 1 Package(s) Total download size: 419 k
Installed size: 1.0 M
Is this ok [y/N]: y
Downloading Packages:
sudo-1.7.4p5-13.el6_3.i686.rpm | 419 kB 00:01
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <[email protected]>
Package: centos-release-6-3.el6.centos.9.i686 (@anaconda-CentOS-201207051201.i386/6.3)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : sudo-1.7.4p5-13.el6_3.i686 1/1
Verifying : sudo-1.7.4p5-13.el6_3.i686 1/1 Installed:
sudo.i686 0:1.7.4p5-13.el6_3 Complete!
[root@bogon ~]#
  2、檢測升級 yum check-update [root@bogon ~]# yum check-update sudo
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirror.neu.edu.cn
* extras: mirror.neu.edu.cn
* updates: mirror.neu.edu.cn
[root@bogon ~]#
  3、升級 yum update [root@bogon ~]# yum update sudo
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirror.neu.edu.cn
* extras: mirror.neu.edu.cn
* updates: mirror.neu.edu.cn
Setting up Update Process
No Packages marked for Update
[root@bogon ~]#
  4、軟件包查詢yum list [root@bogon ~]# yum list | grep sudo
sudo.i686 1.7.4p5-13.el6_3 @updates
[root@bogon ~]#   5、軟件包信息yum info [root@bogon ~]# yum info sudo
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirror.neu.edu.cn
* extras: mirror.neu.edu.cn
* updates: mirror.neu.edu.cn
Installed Packages
Name : sudo
Arch : i686
Version : 1.7.4p5
Release : 13.el6_3
Size : 1.0 M
Repo : installed
From repo : updates
Summary : Allows restricted root access for specified users
URL : http://www.courtesan.com/sudo/
License : ISC
Description : Sudo (superuser do) allows a system administrator to give certain
: users (or groups of users) the ability to run some (or all)
: commands as root while logging all commands and arguments. Sudo
: operates on a per-command basis. It is not a replacement for the
: shell. Features include: the ability to restrict what commands a
: user may run on a per-host basis, copious logging of each command
: (providing a clear audit trail of who did what), a configurable
: timeout of the sudo command, and the ability to use the same
: configuration file (sudoers) on many different machines. [root@bogon ~]#
  6、卸載 yum remove
[root@bogon ~]# yum remove sudo
Loaded plugins: fastestmirror, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package sudo.i686 0:1.7.4p5-13.el6_3 will be erased
--> Finished Dependency Resolution Dependencies Resolved ================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
sudo i686 1.7.4p5-13.el6_3 @updates 1.0 M Transaction Summary
================================================================================
Remove 1 Package(s) Installed size: 1.0 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : sudo-1.7.4p5-13.el6_3.i686 1/1
Verifying : sudo-1.7.4p5-13.el6_3.i686 1/1 Removed:
sudo.i686 0:1.7.4p5-13.el6_3 Complete!
[root@bogon ~]#   7、幫助yum -help、man yum 三、RPM查詢應用案例   1、查詢文件隸屬的軟件包 rpm -qf [root@bogon ~]# rpm -qf /etc/services
setup-2.8.14-16.el6.noarch
[root@bogon ~]# rpm -qf /bin/ls
coreutils-8.4-19.el6.i686
[root@bogon ~]#   2、查詢軟件包信息 rpm -qi、rpm -qip(查詢還未安裝的軟件包)
[root@bogon ~]# rpm -qi sudo
Name : sudo Relocations: (not relocatable)
Version : 1.7.4p5 Vendor: CentOS
Release : 13.el6_3 Build Date: 2012年08月06日 星期一 22時43分51秒
Install Date: 2012年12月15日 星期六 15時24分40秒 Build Host: c6b7.bsys.dev.centos.org
Group : Applications/System Source RPM: sudo-1.7.4p5-13.el6_3.src.rpm
Size : 1078427 License: ISC
Signature : RSA/SHA1, 2012年08月06日 星期一 23時31分02秒, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org>
URL : http://www.courtesan.com/sudo/
Summary : Allows restricted root access for specified users
Description :
Sudo (superuser do) allows a system administrator to give certain
users (or groups of users) the ability to run some (or all) commands
as root while logging all commands and arguments. Sudo operates on a
per-command basis. It is not a replacement for the shell. Features
include: the ability to restrict what commands a user may run on a
per-host basis, copious logging of each command (providing a clear
audit trail of who did what), a configurable timeout of the sudo
command, and the ability to use the same configuration file (sudoers)
on many different machines.
[root@bogon ~]#
  3、查詢軟件包安裝文件rpm -ql、rpm -qlp(查詢還未安裝的軟件包) [root@bogon ~]# rpm -ql sudo
/etc/pam.d/sudo
/etc/pam.d/sudo-i
/etc/sudo-ldap.conf
/etc/sudoers
/etc/sudoers.d
/usr/bin/sudo
/usr/bin/sudoedit
/usr/bin/sudoreplay
/usr/libexec/sesh
/usr/libexec/sudo_noexec.so
/usr/sbin/visudo
/usr/share/doc/sudo-1.7.4p5
/usr/share/doc/sudo-1.7.4p5/ChangeLog
/usr/share/doc/sudo-1.7.4p5/HISTORY
/usr/share/doc/sudo-1.7.4p5/LICENSE
/usr/share/doc/sudo-1.7.4p5/NEWS
/usr/share/doc/sudo-1.7.4p5/README
/usr/share/doc/sudo-1.7.4p5/README.LDAP
/usr/share/doc/sudo-1.7.4p5/TROUBLESHOOTING
/usr/share/doc/sudo-1.7.4p5/UPGRADE
/usr/share/doc/sudo-1.7.4p5/sample.pam
/usr/share/doc/sudo-1.7.4p5/sample.sudoers
/usr/share/doc/sudo-1.7.4p5/sample.syslog.conf
/usr/share/doc/sudo-1.7.4p5/schema.ActiveDirectory
/usr/share/doc/sudo-1.7.4p5/schema.OpenLDAP
/usr/share/doc/sudo-1.7.4p5/schema.iPlanet
/usr/share/doc/sudo-1.7.4p5/sudoers2ldif
/usr/share/man/man5/sudoers.5.gz
/usr/share/man/man5/sudoers.ldap.5.gz
/usr/share/man/man8/sudo.8.gz
/usr/share/man/man8/sudoedit.8.gz
/usr/share/man/man8/sudoreplay.8.gz
/usr/share/man/man8/visudo.8.gz
/var/db/sudo
[root@bogon ~]#
  4、查詢軟件包幫助文檔rpm -qd [root@bogon ~]# rpm -qd sudo
/usr/share/doc/sudo-1.7.4p5/ChangeLog
/usr/share/doc/sudo-1.7.4p5/HISTORY
/usr/share/doc/sudo-1.7.4p5/LICENSE
/usr/share/doc/sudo-1.7.4p5/NEWS
/usr/share/doc/sudo-1.7.4p5/README
/usr/share/doc/sudo-1.7.4p5/README.LDAP
/usr/share/doc/sudo-1.7.4p5/TROUBLESHOOTING
/usr/share/doc/sudo-1.7.4p5/UPGRADE
/usr/share/doc/sudo-1.7.4p5/sample.pam
/usr/share/doc/sudo-1.7.4p5/sample.sudoers
/usr/share/doc/sudo-1.7.4p5/sample.syslog.conf
/usr/share/doc/sudo-1.7.4p5/schema.ActiveDirectory
/usr/share/doc/sudo-1.7.4p5/schema.OpenLDAP
/usr/share/doc/sudo-1.7.4p5/schema.iPlanet
/usr/share/doc/sudo-1.7.4p5/sudoers2ldif
/usr/share/man/man5/sudoers.5.gz
/usr/share/man/man5/sudoers.ldap.5.gz
/usr/share/man/man8/sudo.8.gz
/usr/share/man/man8/sudoedit.8.gz
/usr/share/man/man8/sudoreplay.8.gz
/usr/share/man/man8/visudo.8.gz
[root@bogon ~]#   5、查詢軟件包配置文件 [root@bogon ~]# rpm -qc sudo
/etc/pam.d/sudo
/etc/pam.d/sudo-i
/etc/sudo-ldap.conf
/etc/sudoers
[root@bogon ~]#   6、校驗 [root@bogon tutor]# rpm -V sudo
[root@bogon tutor]#   如果沒有任何內容顯示,說明sudo這個軟件沒有被改變過   7、軟件包文件提取     比如不小心把/etc/inittab文件刪除了,需要從軟件包中重新提取恢復     1)先查找/etc/inittab這個文件屬於哪個軟件包 [root@bogon backup]# rpm -qf /etc/inittab
initscripts-9.03.31-2.el6.centos.i686
[root@bogon backup]#     2)從軟件包中解壓/etc/inittab文件到當前目錄 [root@bogon backup]# rpm2cpio /mnt/cdrom/Packages/initscripts-9.03.31-2.el6.centos.i686.rpm | cpio -idv ./etc/inittab
./etc/inittab
11182 塊
[root@bogon backup]# ls
etc
[root@bogon backup]# ls etc
inittab
[root@bogon backup]#     3)然後從當前目錄復制到/etc/inittab [root@bogon backup]# cp etc/inittab /etc/inittab 四、源代碼包安裝   以安裝proftpd為例子:   1)解壓解包 [root@bogon softs]# ls
proftpd-1.3.4b.tar.gz
[root@bogon softs]# tar -xzvf proftpd-1.3.4b.tar.gz   2)進入解壓後的目錄 [root@bogon softs]# cd proftpd-1.3.4b
[root@bogon proftpd-1.3.4b]#   3)先看看這個源碼包中的文件 [root@bogon proftpd-1.3.4b]# ls
acconfig.h include README README.PAM
aclocal.m4 INSTALL README.AIX README.ports
ChangeLog install-sh README.capabilities README.Solaris2.5x
config.guess lib README.classes README.Unixware
config.h.in locale README.controls RELEASE_NOTES
config.sub ltmain.sh README.cygwin sample-configurations
configure m4 README.DSO src
configure.in Makefile.in README.facl stamp-h.in
contrib Make.rules.in README.FreeBSD tests
COPYING modules README.IPv6 utils
CREDITS NEWS README.LDAP
doc proftpd.spec README.modules
[root@bogon proftpd-1.3.4b]#   可以看到裡面有一個源碼包典型的可以執行文件 configure   4)配置 [root@bogon proftpd-1.3.4b]# ./configure --prefix=/usr/local/proftpd
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
[root@bogon proftpd-1.3.4b]#
  ./configure  在當前目錄下執行   --prefix  指定安裝目錄   執行上述的配置命令後,出現錯誤,沒有找到c編譯器   使用yum安裝gcc編譯器,可以方便的解決gcc依賴的問題 [root@bogon proftpd-1.3.4b]#yum install gcc   安裝好gcc編譯器之後,重新執行配置 [root@bogon proftpd-1.3.4b]# ./configure --prefix=/usr/local/proftpd   5)編譯 [root@bogon proftpd-1.3.4b]# make   把源代碼編譯成可執行文件   6)安裝 [root@bogon proftpd-1.3.4b]# make install 五、腳本安裝   以安裝webmin為例子:   1)解壓解包 [root@bogon softs]# tar -xzvf webmin-1.610.tar.gz   2)進入解壓目錄 [root@bogon softs]# cd webmin-1.610   3)可以查看一下README文件,路面有安裝方式的說明 [root@bogon webmin-1.610]# more README   4)執行腳本安裝 [root@bogon webmin-1.610]# ./setup.sh   安裝過程會有一些交互,安裝目錄、日志文件存放目錄、設置用戶名密碼之類的 [root@bogon webmin-1.610]# ./setup.sh
***********************************************************************
* Welcome to the Webmin setup script, version 1.610 *
***********************************************************************
Webmin is a web-based interface that allows Unix-like operating
systems and common Unix services to be easily administered. Installing Webmin in /softs/webmin-1.610 ... ***********************************************************************
Webmin uses separate directories for configuration files and log files.
Unless you want to run multiple versions of Webmin at the same time
you can just accept the defaults. Config file directory [/etc/webmin]:
Log file directory [/var/webmin]: ***********************************************************************
Webmin is written entirely in Perl. Please enter the full path to the
Perl 5 interpreter on your system. Full path to perl (default /usr/bin/perl): Testing Perl ...
Perl seems to be installed ok ***********************************************************************
Operating system name: CentOS Linux
Operating system version: 6.3 ***********************************************************************
Webmin uses its own password protected web server to provide access
to the administration programs. The setup script needs to know :
- What port to run the web server on. There must not be another
web server already using this port.
- The login name required to access the web server.
- The password required to access the web server.
- If the webserver should use SSL (if your system supports it).
- Whether to start webmin at boot time. Web server port (default 10000):
Login name (default admin):
Login password:
Password again:
The Perl SSLeay library is not installed. SSL not available.
Start Webmin at boot time (y/n): n
***********************************************************************
Creating web server config files..
..done   安裝完成我們就看見在遠程用浏覽器登錄來管理服務器了   webmin是一個非常強大基於Web的Unix/Linux系統管理工具
Copyright © Linux教程網 All Rights Reserved