Sie sind auf Seite 1von 19

Knowledge is Power

Commit to the LORD whatever you


do, and your plans will succeed.
(Proverbs 16:3)

Linux Package Management

Jeong Chul
tland12.wordpress.com
www.youtube.com/user/tland12

Computer Science
ITC and RUPP in Cambodia

Linux Package Management


Part 1 RPM

Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5

RPM Package Manager


Installing & Removing Software
RPM Queries
RPM Verification
Source RPM

Part 2 YUM

Chapter 6 YUM usage


Chapter 7 YUM configuration
Chapter 8 YUM Utils
Chapter 9 Creating a private repository

Part 3 Source File and Service

Chapter 10 Managing Source File Software


Chapter 11 GUI Package Management
Chapter 12 How to control Services

Chapter 1 RPM Package Manger


1.Getting and Installing Software Packages
Install DVD
Vendor Repository www.centos.org fedoraproject.org
Third-Party Repositories - rpmfind.net, sourceforge.net
2.RPM Components
Local database - /var/lib/rpm
rpm and related executables
name-version-release.architecture.rpm
RPM is a backend for other programs such as yum
YUM or system-config-packages provide significant advantages such
as automatic dependency resolution.
3. Primary Functions
install/remove
query
verify

Chapter 2 Installing & Removing software


1.Primary RPM options
a. Install: rpm -i, --install

# rpm ivh telnet-0.17-47.el6.i686.rpm


# rpm ivh http://mirror.nus.edu.sg/centos/6.4/os/i386/Packages/autofs-5.0.573.el6.i686.rpm

b. Upgrade: rpm -U, --upgrade


upgrades or installs the package currently installed to a newer version
# rpm Uvh telnet-0.17-47.el6.i686.rpm
c. Freshen: rpm -F, --freshen
upgrade packages, but only ones for which an earlier version is
installed.
# rpm F telnet-0.17-47.el6.i686.rpm
d. Erase: rpm -e, --erase
# rpm e telnet
# rpm q whatrequires httpd
# rpm evv test httpd

// dependency checking before delete


//testing before real deleting

Chapter 2 Installing & Removing software


2. Output options: -v, -h

a. rpm v - print package name


b. rpm h - print hash marks

3.Many other install options are available

a. --nodeps : dont do a dependency check before installing or upgrading a


package
b. --replacefiels: install the packages even if some of them are already
installed on this system
c. --force : forces the contents of the current package to be installed
d. replacepkgs: forces packages in this archive to be installed, even if
they are already installed on the system
e . oldpackage: forces the package to be installed, even if the current
package is older than the one already installed.
f. Example
# rpm ivh nodeps telnet-0.17-47.el6.i686.rpm

Chapter 3 RPM Queries


1. Syntax:
rpm -q what_packages what_information
2.Installed Package Options:
a. rpm -qa
lists installed all packages
# rpm qa | grep telnet
b. rpm -qf filename
shows owning package
# rpm qf /etc/passwd
c. rpm -qi package_name
general information
# rpm qi telnet
d. rpm -ql package_name
lists files in package
# rpm ql telnet
# rpm ql requires telnet
package prerequisites with dependency
3.Uninstalled Package Options:
# rpm -qip telnet-0.17-47.el6.i686.rpm

# rpm qRp telnet-0.17-47.el6.i686.rpm

in case of uninstalled package

Chapter 4 rpm Verification


1. Verification compares the files, permissions, type, owner, group,
MD5 checksum and modify time against the RPM database.
2. Installed RPM File Verification:
a. Verify the installed rpm package
# rpm V telnet
b. Verify the uninstalled rpm package
# rpm Vp telnet-0.17-47.el6.i686.rpm
c. Verifies all the installed RPMS

# rpm Va
3.Signature verification BEFORE package install:
a. All package files were signed with GPG private signature to verify the
integrity of any package file
b. rpm --import /mnt/cdrom/RPM-GPG-KEY
c. rpm -K telnet-0.17-47.el6.i686.rpm

Chapter 4 rpm Verification


4. Output of rpm V
[root@client ~]# rpm -V ppp
S.5....T. c /etc/ppp/chap-secrets

5 (MD5 Sum) An MD5 checksum indicates a change to the file contents.


S (File size) The number of characters in the file has changed.
L (Symlink) The file has become a symbolic link to another file.
T (Mtime) The modification time of the file has changed.
D (Device) The file has become a device special file.
U (User) The username that owns the file has changed.
G (Group) The group assigned to the file has changed.
M (Mode) The ownership or permission of the file changed

5.Removing lock files, check the database and rebuild the


database.
# rm -f /var/lib/rpm/___db*
# rpm --rebuilddb

Chapter 5 Source RPM


1.Download source rpm file www.rpmfind.net
ncftp-3.2.4-1.el6.src.rpm

2. Making rpm file using source rpm files


a. Source file install
# rpm ivh ncftp-3.2.4-1.el6.src.rpm
# ls /root/rpmbuild/SPECS/ncftp.spec
# ls /root/rpmbuild/SOURCES

// tar files and patch files

b. Extract tar source file (tar.gz) from SOURCES


# rpmbuild -bp /root/rpmbuild/SPECS/ncftp.spec
# ls /root/rpmbuild/BUILD/ncftp-3.2.4

c. Making rpm file

# rpmbuild ba ncftp.spec
# ls /root/rpmbuild/RPMS/i686/ncftp-3.2.4-1.el6.i686.rpm
# ls /root/rpmbuild/SRPMS/ncftp-3.2.4-1.el6.src.rpm

d. Install rpm package

# rpm ivh /root/rpmbuild/RPMS/i686/ncftp-3.2.4-1.el6.i686.rpm


# rpm qa | grep ncftp

Chapter 6 YUM usage


1.Yellowdog Updater Modified
RPM package management tool
Designed to resolve rpm package dependencies
Can locate packages across multiple repositories
Replacement for up2date
2. Using yum
yum install yum-utils
yum localinstall /var/ftp/pub/yum-utils*
yum remove yum-utils
yum update yum-utils
yum update
//update all packages
3. Searching packages/files
yum search ftp
yum list (all/available/extras/installed/recent/updates)
# yum list installed ftp
yum whatprovides yum-utils
yum info yum-utils

Chapter 7 YUM Configuration


1. Yum main configuration file - /etc/yum.conf
a. tolerant : configures yum to be tolerant of minor errors on the command
line, such as requesting to install a package that has already been installed
b. exactarch : makes yum update packages with only packages for the same
architecture that is installed
c. obsoletes : lets yum determine obsolete packages during updates
d. plugins turned on (set to 1), available extensions to yum are enabled

2. Adding yum Repositories - /etc/yum.repos.d/


a. Base : all the same packages on the installation DVD
b. Updates : As updates become available from CentOS, automatically access
those updates from this repository.
c. CentOS Extras : extend the functionality of CentOS system without
breaking upstream compatibility and do not update any base components.
d. CentOS Plus : updates to the packages in Base but are not part of the
upstream distribution.

Chapter 7 YUM Configuration


2. Adding yum Repositories - /etc/yum.repos.d/
e. # rpm ivh rpmforge-release-0.5.3-1.el6.rf.i686.rpm
# ls l /etc/yum.repo.d/rpmforge.repo
3. The cachedir - /var/cache/yum
Where the RPM files are downloaded to by yum when you ask
to install or upgrade packages.
keepcache=0 causes all downloaded packages and headers to be
erased after installed.
# yum clean all
4. Yum Log file in /etc/yum.conf
debuglevel=2
from 0 to 10
logfile=/var/log/yum.log

Chapter 8 Yum Utils


1. Yum utils installation
# yum install yum-utils
2. How to use yum-utils
a. yumdownloader download package without installation
# yumdownloader openssh-server
# yumdonwloader source zsh
//download source rpm
b. package-cleanup - helps to detect problems in the rpm database and to solve
# package-cleanup dupes
//duplicate Packages
# package-cleanup problems
//dependency Problems
c. yum-complete-transaction - offers the possibility to finish incomplete yum
transactions
# yum-complete-transaction
# yum-complete-transaction --cleanup-only //clean the history
d. yum-builddep - install the required RPMs to build the specified package
# yum-builddep --nogpgcheck ncftp-3.2.4-1.el6.src.rpm
e. yum-config-manager - adding, enabling and disabling a Yum Repository
# yum-config-manager --add-repo http://www.example.com/example.repo

Chapter 9 Creating a private repository


1. Purpose: create an example yum repository from a set of rpm packages
2. Process to create a private repository
a. # yum install createrepo
b. # mkdir /var/ftp/pub/package/
# cp a /media/CentOS_6.3_Final/Packages/yum* /var/ftp/pub/packages

c. # createrepo --verbose /var/ftp/pub/packages


# ls /var/ftp/pub/packages/repodata/
//metadata
d. # vim /etc/yum.repos.d/tland.repo
[tland]
name=Tland repo
baseurl=file:///var/ftp/pub/packages/
enabled=1
gpgcheck=0
e. # repoquery -q --repoid=tland a
//show package list
f. # yum repolist all
//show all repository list

Chapter 10 Managing Source File Software


1.Download source file - www.ncftp.com/download
ncftp-3.2.5-src.tar.bz2
ncftp-3.2.5-src.tar.gz
2. Extract source file
# cp ncftp* /usr/local/src/
# tar xvzf ncftp-3.2.5-src.tar.gz
# tar xvjf ncftp-3.2.5-src.tar.bz2
3. Compile and install
#./configure help
#./configure
# make ; make install
4. Using binary file
# which ncftp
# ncftp ftp-server

Chapter 11 GUI Package Management


1.Package installation
# rpm qa | grep gnome-packagekit
2. Execute GPK-Application
# gpk-application
3. Manage package using GPK-APPLICATION

Chapter 12 How to control services


1.Service start
# service httpd start| stop | reload| restart
# /etc/rc.d/init.d/httpd start
# ps ef | grep httpd
# netstat nat | grep :80

2. Service control
# ntsysv
# rpm qa | grep chkconfig
# chkconfig --list httpd
# chkconfig add httpd
# chkconfig level 35 httpd on
# chkconfig del httpd

3. system -> admin -> services

Linux Package Management

Thank you & God bless you


tland12.wordpress.com
www.youtube.com/user/tland12

Das könnte Ihnen auch gefallen