Você está na página 1de 49

Linux Based Networks Zahid Shafique, Instructor

Linux Based Networks


Punjab University College of Information Technology

Instructor: Zahid Shafique


<z_shafique@hotmail.com>

Topic Heading Class Meeting # Slide : 1


Linux Based Networks Zahid Shafique, Instructor

Package Management with RPM

Topic Heading Class Meeting # Slide : 2


Linux Based Networks Zahid Shafique, Instructor

Introduction To Package Management

This section will introduce you to the basic concepts of package


management.

Which is the fundamental means for you to install and manage software
on your Red Hat Linux system.

Topic Heading Class Meeting # Slide : 3


Linux Based Networks Zahid Shafique, Instructor

What Is Package Management?

The package management system is the part of your Linux system that
enables you to install, uninstall, and manage the software on your
machine.

If you are familiar with Microsoft Windows 95, this is similar to the
Add/Remove Programs option in the Windows Control Panel.

Though in Linux, it is generally much more flexible and easier to query.

Topic Heading Class Meeting # Slide : 4


Linux Based Networks Zahid Shafique, Instructor

Red Hat Package Manager (RPM)

Almost all distributions of Linux include some kind of package


management system.

The most popular of these is the Red Hat package manager (RPM), and
this is the system discussed in this lecture.

Topic Heading Class Meeting # Slide : 5


Linux Based Networks Zahid Shafique, Instructor

The tasks you can perform with RPM…

RPM enables you to perform the basic tasks of


Installing and uninstalling packages.
Analyzing the disk space used by certain software
Verifying that a particular package's files have not been deleted or
corrupted.
To verify the package is installed or not and on which location

Topic Heading Class Meeting # Slide : 6


Linux Based Networks Zahid Shafique, Instructor

What Is a Package?

A package is a special file that contains the directories and files that are
part of a particular piece of software or system component.

It also contains additional information about the software that is used by


the package manager.

Two different kinds of packages exist: binary and source.

Topic Heading Class Meeting # Slide : 7


Linux Based Networks Zahid Shafique, Instructor

Binary Package

A binary package contains software components that have already been


built for a particular architecture and are ready to use. This is the kind
you normally install on your system.

Binary package filenames end in the suffix . rpm

Topic Heading Class Meeting # Slide : 8


Linux Based Networks Zahid Shafique, Instructor

Source Package

A source package contains the source code and other items used
to build the corresponding binary package.
Source packages are provided in the event that you want to
modify—and recompile—a program yourself.
Source Package filenames end in the suffix . src. rpm.

Topic Heading Class Meeting # Slide : 9


Linux Based Networks Zahid Shafique, Instructor

Note!

From now on in this lecture, wherever there is an unqualified reference


to a package, it is a reference to a binary package.

Topic Heading Class Meeting # Slide : 10


Linux Based Networks Zahid Shafique, Instructor

Syntax of RPM

You use RPM from the command line in the format

#rpm [options] package_name

Where options is one of many different flags used by RPM to


manipulate packages.

Package name indicates the software package to be used.

Topic Heading Class Meeting # Slide : 11


Linux Based Networks Zahid Shafique, Instructor

What's In a Name?

A binary package has a filename that looks similar to the one shown in
Figure

Topic Heading Class Meeting # Slide : 12


Linux Based Networks Zahid Shafique, Instructor

The Package

The first pan of the filename is a short string that identifies the package.

Topic Heading Class Meeting # Slide : 13


Linux Based Networks Zahid Shafique, Instructor

Version Number

After the name is the version number (in this case 0.2), which identifies
the version of the software contained in the package.

Topic Heading Class Meeting # Slide : 14


Linux Based Networks Zahid Shafique, Instructor

Release Number

This is followed by the package release number (5).

Topic Heading Class Meeting # Slide : 15


Linux Based Networks Zahid Shafique, Instructor

Distinguish between the


Software version, and the Package release

The version number is the version of the software that is provided by


the package. In the example in Figure, it is ed, version 0.2. This number
is set by the original author of the software, who is often different
from the person who created the package for the software. The version
number reflects the status of the software.

The release number refers to the version of this package of the


software. Sometimes, even if the original software inside the package has
not changed, it is necessary to repackage it. The release number
indicates which instance of the package this is.

Topic Heading Class Meeting # Slide : 16


Linux Based Networks Zahid Shafique, Instructor

Architecture for the Package

After the release number is a short string that indicates the architecture
for the package.

Software that has been compiled for a particular processor or machine


architecture.

For example, packages with programs compiled for Intel x86 or


compatible processors usually include the architecture string i386

Topic Heading Class Meeting # Slide : 17


Linux Based Networks Zahid Shafique, Instructor

noarch string

In some cases, the contents of a package are independent of any


machine architecture (for example, a package that only contains icons
and not executable programs). In these cases, the architecture string
noarch is used.

Topic Heading Class Meeting # Slide : 18


Linux Based Networks Zahid Shafique, Instructor

Some common Architecture strings


Table shows some common architecture strings.

String Processor

noarch Any
i386. i586. i686 Intel x86, Pentium, and compatibles
alpha DEC Alpha
sparc Sun Sparc
mips MIPS
ppc PowerPC
m68k Motorola 68000 family

Topic Heading Class Meeting # Slide : 19


Linux Based Networks Zahid Shafique, Instructor

Where To find Packages

If you are using an RPM-base distribution, your installation media or


download site will have appropriate packages.

Topic Heading Class Meeting # Slide : 20


Linux Based Networks Zahid Shafique, Instructor

Working with rpm


Just to get acquainted with the rpm command, try using it to examine the
contents of a package right now.
Table shows a basic summary of the important options for rpm.

Option Sub-Option Meaning


-q Query
-i Show detailed package information
-l List all files
-d List only documentation files
-c List only configuration files
-f Find which package owns a file
-p Operate on a package file
--scripts View install/uninstall scripts
-i Install
-e Erase (uninstall)
Topic Heading Class Meeting # Slide : 21
Linux Based Networks Zahid Shafique, Instructor

Working with rpm(cont…)

Option Sub-Option Meaning


-U Upgrade, or install if the package is not
already installed
-F Freshen (upgrades a package only if it is
already installed)
-V Verify a package installation
-b Build a package

Topic Heading Class Meeting # Slide : 22


Linux Based Networks Zahid Shafique, Instructor

The First Step

We'll use Red Hat Linux as an example for demonstration purposes.

Be sure that the Red Hat Linux Installation CD-ROM is in the CD-ROM
drive and that it is mounted.

If not, as superuser, mount it using the following command:


#mount /dev/cdrom /mnt/cdrom

Now, cd to the directory /mnt/cdrom/RedHat/RPMS, and list the files in


this directory. You see many packages listed.

Topic Heading Class Meeting # Slide : 23


Linux Based Networks Zahid Shafique, Instructor

How to examine the information about a package?

# rpm -qip quota-1.66-6.i386.rpm

Name : quota Relocations: (not relocateable)


Version : 1.66 Vendor: Red Hat Software
Release : 6 Build Date: Tue Apr 13 11:05:47 1999
Install date: (not installed) Build Host: porky.devel.redhat.com
Group : System Environment/Base Source RPM: quota-1.66-6.src.rpm
Size : 79332 License: BSD
Packager : Red Hat Software <http://developer.redhat.com/bugzilla>
Summary : System administration tools for monitoring users' disk usage.

Description :
The quota package contains system administration tools for
monitoring and limiting users' and or groups' disk usage, per
filesystem.

Topic Heading Class Meeting # Slide : 24


Linux Based Networks Zahid Shafique, Instructor

To see a listing of the files in the package

To see a listing of the files in this package, type the following:


#rpm -qpl quota-1.66-6.i386.rpm
This prints a listing of files included in the quota package.

Topic Heading Class Meeting # Slide : 25


Linux Based Networks Zahid Shafique, Instructor

Querying Packages with RPM

To see what packages are installed on your system, you can


use the following command:
#rpm -qa
This command lists every package currently installed on your
system.
To get information on a specific package, just use the -q
option.

Topic Heading Class Meeting # Slide : 26


Linux Based Networks Zahid Shafique, Instructor

Options you can use with rpm -q


Table below provides the various options you can use with the
rpm -q command to query RPM packages.
Option Description
-q name Provides the package name, version, and
release number
-qa Lists all packages currently installed
-qf file Queries the package associated with file
-qp package Queries package
-qi package Provides the name, description, release,
size, build date, installation date, and other
miscellaneous information about package
-ql package

Topic Heading Class Meeting # Slide : 27


Linux Based Networks Zahid Shafique, Instructor

Installing Packages with RPM


To install a package from the command line, you use the -i option like
this:

#rpm -i quota-1.66-6.i386.rpm
This command installs the quota package on your system. The -i
option instructs the rpm command to install the package quota-1.66-
6.i386.rpm onto the local system.

Topic Heading Class Meeting # Slide : 28


Linux Based Networks Zahid Shafique, Instructor

Steps RPM goes through during installation.

To run the installation, RPM goes through a series of steps:

Checks dependency: -Each package may depend on other software


already being installed.

Checks conflicts:-RPM checks to see whether a component is already


installed or that the component is not older than the one currently
installed.

Processes configuration files:- RPM attempts to provide a proper


configuration file, and if it finds a previous configuration file, it saves
that file for future reference.

Topic Heading Class Meeting # Slide : 29


Linux Based Networks Zahid Shafique, Instructor

RPM Steps (Cont…)

• Installs files:- RPM unpacks the various components from the


package and places them in the proper directories.
• Performs post-installation processing:- After installing the various
components, RPM performs any necessary tasks to properly configure
the system.
• Updates the database:- RPM keeps track of all its action via a
database.

Topic Heading Class Meeting # Slide : 30


Linux Based Networks Zahid Shafique, Instructor

No Feedback

The command provides no feedback during the installation, but you can
use the -v (verbose) option to get more information.

Topic Heading Class Meeting # Slide : 31


Linux Based Networks Zahid Shafique, Instructor

Install options used with RPM


Table provides a list of other options you can use during installation.

Option Description
-vv Provides very verbose information.
-h Prints hash marks (#) periodically during
installation. These marks allow you to see that RPM
is actually doing something and is not just hung.
-percent Prints the percent completed during installation
instead of #.
-test Does not install the package, but performs a dry run
to test installation and reports any errors.
-replacefiles Replaces files from other packages.
-force Tells RPM to ignore certain conflict errors and
install the package anyway.
Topic Heading Class Meeting # Slide : 32
Linux Based Networks Zahid Shafique, Instructor

Tip

You can also use the -nodeps


option to force an installation. Be
careful using the -nodeps option.
If you remove a package on
which another program depends,
that program might not work
correctly in the future.

Topic Heading Class Meeting # Slide : 33


Linux Based Networks Zahid Shafique, Instructor

Uninstalling Packages with RPM

Fortunately, RPM makes uninstalling a package just as easy as installing


one.
To uninstall a package, you use the -e option:

#rpm -e quota-1.66-6.i386.rpm

Topic Heading Class Meeting # Slide : 34


Linux Based Networks Zahid Shafique, Instructor

Tip

You can indicate the RPM package by name only such as

#rpm -e quota

without the version indicators and it will work.

The only exception is if you have more than one version of the
package installed.

Topic Heading Class Meeting # Slide : 35


Linux Based Networks Zahid Shafique, Instructor

Steps RPM goes through during uninstallation.

When erasing a package from your system, RPM goes through the
following sequence of actions:

Checks dependencies:- RPM checks its database to see whether any


other packages depend on this database. If so, RPM does not delete
the package unless explicitly told to do so.

Executes scripts:- RPM executes a pre-uninstall script.

Checks configuration files:- RPM saves a copy of any modified


configuration files.

Topic Heading Class Meeting # Slide : 36


Linux Based Networks Zahid Shafique, Instructor

RPM Steps (Cont…)

• Deletes files:- RPM deletes every file associated with the specified
package.

• Executes scripts:- RPM executes a post-uninstall script.

• Updates the database:- RPM removes all references to the package


from its database.

Topic Heading Class Meeting # Slide : 37


Linux Based Networks Zahid Shafique, Instructor

Tips

You can use the -v and -vv options to get


verbose information from the erase command.

You can also use the -test option to see what


problems might occur if you were to really
remove the package.

Finally, you can use the -nodeps option to tell


RPM to ignore dependencies and go ahead and
remove the package.

Topic Heading Class Meeting # Slide : 38


Linux Based Networks Zahid Shafique, Instructor

Updating Packages with RPM

With the -U (note the uppercase) option.

Say someone has added several new features to the quota program and
released a new package called quota-2.01-1.i386.rpm.

To upgrade to the new version, you would use the following command:

#rpm -Uvh quota-2.01-1.i386.rpm

Topic Heading Class Meeting # Slide : 39


Linux Based Networks Zahid Shafique, Instructor

Updating Packages with RPM (cont…)

While upgrading, RPM installs the specified package and then erases
all the older versions of the packages (if any exist).
While RPM is upgrading a package, you might see a message like the
following, indicating that a configuration file is being saved to a new
file:
#Saving syslog.conf to syslog.conf.rpmsave

Topic Heading Class Meeting # Slide : 40


Linux Based Networks Zahid Shafique, Instructor

Verifying Packages with RPM

The final RPM mode verifies a package.

Say you suspect that a file has been corrupted accidentally.

You need to compare the current files against the originals you installed.

RPM allows you to do so with the -V option (note the uppercase).

Topic Heading Class Meeting # Slide : 41


Linux Based Networks Zahid Shafique, Instructor

Verifying a package compares


The size
MD5 checksum
File permissions
File type
File owner
Group settings.
For example, to verify the quota package, you enter the following:

#rpm -V quota

Topic Heading Class Meeting # Slide : 42


Linux Based Networks Zahid Shafique, Instructor

Verifying Packages with RPM (cont…)

If nothing has changed, RPM does not display any output.


If something has changed, RPM displays a string of eight characters
indicating what has changed and the name of the file that has
changed.

Topic Heading Class Meeting # Slide : 43


Linux Based Networks Zahid Shafique, Instructor

Verification Failure Codes


Table lists the possible output codes.
Code Meaning
c The file is a configuration file.
5 The file failed the MD5 checksum test.
S The file size has changed since installation.
L A problem exists with the symbolic links.
T The file modification time does not match the original.
D This code indicates a device attribute.
U The user setting is different.
G The group setting is different.
M The mode differs, either in permission or file type.
Topic Heading Class Meeting # Slide : 44
Linux Based Networks Zahid Shafique, Instructor

Tip

The following command verifies


all installed packages on your
system:

#rpm -Va

Topic Heading Class Meeting # Slide : 45


Linux Based Networks Zahid Shafique, Instructor

Today’s Agenda

Topic Heading Class Meeting # Slide : 46


Linux Based Networks Zahid Shafique, Instructor

Topic Heading Class Meeting # Slide : 47


Linux Based Networks Zahid Shafique, Instructor

Exercise:

Topic Heading Class Meeting # Slide : 48


Linux Based Networks Zahid Shafique, Instructor

Homework
• Homework this week:

• Next week:

Topic Heading Class Meeting # Slide : 49

Você também pode gostar