Linux all in one desk reference for dummies phần 7 - Pdf 19

Working with RPM Files
424
You can see a list of all installed RPMs by using the following command:
rpm -qa
You see a long list of RPMs scroll by your screen. To view the list one screen
at a time, type
rpm -qa | more
If you want to search for a specific package, feed the output of rpm -qa to
the grep command. For example, to see all packages with kernel in their
names, type
rpm -qa | grep kernel
The result depends on what parts of the kernel RPMs are installed on a
system.
You can query much more than a package’s version number with the
rpm -q
command. By adding single-letter options, you can find out other useful
information. For example, try the following command to see the files in the
cups package:
rpm -ql cups
Here are a few more useful forms of the rpm -q commands to query informa-
tion about a package (to use any of these
rpm -q commands, type the com-
mand, followed by the package name):

rpm -qc: Lists all configuration files in a package.

rpm -qd: Lists all documentation files in a package. These are usually
the online manual pages (also known as man pages).

rpm -qf: Displays the name of the package (if any) to which a specified
file belongs.

rpm -q whatprovides filename
For example, to see which RPM provides the file /etc/vsftpd.conf, type
rpm -q whatprovides /etc/vsftpd.conf
RPM then prints the name of the package that provides the file, like this:
vsftpd-1.2.1-69
If you provide the name of a package instead of a filename, RPM displays the
name of the RPM package that contains the specified package.
On the other hand, to find the names of RPMs that need a specific package,
use the following command:
rpm -q whatrequires packagename
For example, to see which packages need the openssl package, type
rpm -q whatrequires openssl
The output from this command shows all the RPM packages that need the
openssl package.
Installing an RPM
To install an RPM, use the rpm -i command. You have to provide the name
of the RPM file as the argument. If you want to view the progress of the RPM
installation, use
rpm -ivh. A series of hash marks (#) displays as the pack-
age is unpacked.
TEAM LinG - Live, Informative, Non-cost and Genuine !
Working with RPM Files
426
For example, to install the kernel-source RPM (which contains the source
files for the Linux operating system) for Fedora Core from the companion
DVD-ROM, I insert the DVD and after it’s mounted, I type the following
commands:
cd /mnt/cdrom/Fedora/RPMS
rpm -ivh kernel-source*
You don’t have to type the full RPM filename — you can use a few characters

-) before the
version number.
The
rpm -e command does not remove a package that other packages need.
TEAM LinG - Live, Informative, Non-cost and Genuine !
Book V
Chapter 4
Installing and
Updating
Applications
Working with RPM Files
427
Upgrading an RPM
Use the rpm -U command to upgrade an RPM. You must provide the name of
the RPM file that contains the new software. For example, if I have version
1.1.19 of
cups (printing system) installed on my system but I want to upgrade
to version 1.1.20, I download the RPM file cups-1.1.20-103.i586.rpm from
a repository and use the following command:
rpm -U cups-1.1.20-103.i586.rpm
The rpm command performs the upgrade by removing the old version of the
cups package and installing the new RPM.
Whenever possible, upgrade rather than remove the old package and install
a new one. Upgrading automatically saves your old configuration files, which
saves you the hassle of reconfiguring the software after a fresh installation.
When you’re upgrading the
kernel packages that contain a ready-to-run
Linux kernel, install it by using the
rpm -i command (instead of the rpm -U
command). That way, you won’t overwrite the current kernel.

That’s how you can tell whether or not a file is a configuration file.
Typically, you don’t worry if a configuration file has changed; you proba-
bly made the changes yourself.
✦ The last part of the line is the full pathname of the file. From this part,
you can tell exactly where the file is located.
Table 4-1 Characters Used in RPM Verification Reports
Character Meaning
S Size has changed
M Permissions and file type are different
5 Checksum computed with the MD5 algorithm is different
D Device type is different
L Symbolic link is different
U File’s user is different
G File’s group is different
T File’s modification time is different
Working with DEB Files
Debian packages with .deb file extensions store executable files together
with configuration files, online documentation, and other information. You
can unpack and manipulate these DEB files using the Debian utility
dpkg,
which is a command-line program that takes many options. A text-mode,
menu-driven program called
dselect is also available for you to manage the
packages without having to type
dpkg commands.
You typically use a higher-level utility called APT (Advanced Packaging Tool)
to work with packages in Debian. For example, instead of downloading a DEB
file and installing it with the
dpkg command, you can simply use the apt-get
command to install the package. The apt-get command can even download

Using the dpkg command
To get a feel for the dpkg command, type dpkg help | more. The output
shows the large number of options that
dpkg accepts. You can also type man
dpkg to read the online man page for
dpkg.
You can use
dpkg to perform a whole lot of operations on packages, but you
have to work at a shell prompt in a terminal window or a text console. The
format of a dpkg command is
dpkg [options] action package
with zero or more options, an action indicating what dpkg has to do, and
the name of a
package, a DEB file, or a directory (depends on the action
argument). Sometimes the dpkg command does not need any name of pack-
age or file, just an
action.
Here are some examples of actions you can perform with
dpkg:
✦ Install a package from a DEB file with the command
dpkg -i
packagefile
where packagefile is the name of the DEB file (for
example, vsftpd-*.deb).
✦ Remove a package but retain the configuration files with the command
dpkg -r packagename where packagename is the name of the package
(for example, vsftpd)
✦ Configure a package with the command
dpkg configure
packagename

that the package contains (for example,
stdio*)
✦ List files installed from a package with the command
dpkg -L
packagename
where packagename is the name of a package (for
example,
vsftpd)
You can try these commands out on a Debian system or any system that
uses DEB packages. For example, to look for all packages matching names
that begin with
mozilla, type dpkg -l mozilla* in a terminal window. Here is
the relevant portion of this command’s output on my Debian system:
||/ Name Version Description
+++-==============-==============-============================================
ii mozilla-browse 1.6-5 Mozilla Web Browser - core and browser
ii mozilla-firefo 0.8-12 lightweight web browser based on Mozilla
ii mozilla-mailne 1.6-5 Mozilla Web Browser - mail and news support
ii mozilla-psm 1.6-5 Mozilla Web Browser - Personal Security Mana
un mozilla-xft <none> (no description available)
The ii in the first column indicates that the package is installed; un means
the package is not installed.
Another common use of
dpkg -l is to list all packages and use grep to find
lines that match a search string. For example, to find anything containing
kernel, type dpkg -l | grep kernel. If the package names (in the second
column of the
dpkg -l output) are truncated, adjust the width of the output
lines with a command like this:
COLUMNS=132 dpkg -l | grep kernel

and then upgrade all packages for which updates are available. You can, of
course, perform that same task with a simple APT command as well.
Figure 4-1:
You can use
dselect
to manage
packages in
Debian.
TEAM LinG - Live, Informative, Non-cost and Genuine !
Working with DEB Files
432
Using APT to manage DEB packages
APT stands for Advanced Packaging Tool, and it’s truly an advanced utility
for keeping your Debian system up to date. You can use a number of APT
utilities to manage DEB packages. The two commonly used commands are
apt-get and apt-cache.
To install a package with
apt-get, simply type apt-get install packagename
where packagename is the name of the package that you want to install. For
example, to install the
vsftpd package, type apt-get install vsftpd.
Removing a package is equally simple. Type apt-get remove packagename
where packagename is the name of the package you want to remove.
If you want to find the name of a package and you know some terms associ-
ated with the package, you can look for it with the
apt-cache utility. For
example, to look for a CD/DVD burner package, I type apt-cache search burn
| more to search through the APT’s package cache (list of Debian packages
that APT downloads from the servers listed in the
/etc/apt/sources.list

names-only
option like this: apt-cache search names-only keyword where
keyword is something that appears in the package’s name. For example, if I
want to find packages that contain
selinux in their names, I type apt-cache
search names-only selinux.
TEAM LinG - Live, Informative, Non-cost and Genuine !
Book V
Chapter 4
Installing and
Updating
Applications
Building Software Packages from Source Files
433
Run apt-get clean periodically to clean out the local repository (in the
/var/cache/apt/archives directory) of DEB files that have already been
installed. You can free up some disk space by removing these DEB files.
Building Software Packages from Source Files
Many open-source software packages are distributed in source-code form,
without executable binaries. Before you can use such software, you have to
build the executable binary files by compiling, and you have to follow some
instructions to install the package. In this section, I show you how to build
software packages from source files.
Downloading and unpacking the software
Open-source software source files are typically distributed in compressed
tar archives. These archives are created by the tar program and com-
pressed with the gzip program. The distribution is in the form of a single
large file with the .tar.gz or .tar.Z extension — often referred to as a
compressed tarball. If you want the software, you have to download the com-
pressed tarball and unpack it.

xmms-1.2.10/intl/ref-del.sin
xmms-1.2.10/intl/gmo.h
xmms-1.2.10/intl/gettextP.h
xmms-1.2.10/intl/hash-string.h
xmms-1.2.10/intl/loadinfo.h
rest of the output not shown
The output of this tar command shows you what’s in the archive and gives
you an idea of the directories that are created after you unpack the archive.
In this case, a directory named
xmms-1.2.10 is created in the current direc-
tory, which, in my case, is
/usr/local/src. From the listing, you also figure
out the programming language used to write the package. If you see
.c and
.h files, the source files are in the C programming language used to write
many open-source software packages.
To extract the contents of the compressed
tar archive, type the following
tar command:
tar zxvf xmms*.gz
You again see the long list of files as they extract from the archive and copy
to the appropriate directories on your hard drive.
Now you’re ready to build the software.
Building the software from source files
After you unpack the compressed tar archive, all source files are in a direc-
tory whose name is usually that of the software package with a version-
number suffix. For example, the XMMS version 1.2.10 source files extract to
the
xmms-1.2.10 directory. To start building the software, change directories
with the following command:

ration and creates a file named Makefile — a file the make command
uses to build and install the package. (You can type ./configure help
to see a list of options that
configure accepts.)
If you get any errors about missing packages, you have to install those
missing packages. Use your distribution’s software installation tools to
add the missing packages. For example, in Debian use the
apt-get
install
command. In Fedora Core, select Main Menu➪System Settings➪
Add/Remove Applications. In SUSE, use the YaST GUI tool.
2. Type make to build the software.
This step compiles the source files in all the subdirectories. (Compiling
source code converts each source file into an object file — a file contain-
ing binary instructions that your PC’s processor can understand.)
3. Type make install to install the software.
This step copies libraries and executable binary files to appropriate
directories on your system.
Although these steps are specific to XMMS, most other packages follow these
steps —
configure, make, and install. The configure shell script guesses
system-dependent variables and creates a
Makefile with commands needed
to build and install the software.
Usually, you don’t have to do anything but type the commands to build the
software, but you must install the software-development tools on your
system. In Fedora Core, you must install the Development Tools and the
GNOME Software Development packages. In Debian, to build and run XMMS,
you must also install the X Software Development package because it’s an
X application.

further before using it.
Installing SRPMS
If you have the source CDs for Fedora Core (you can download the source
CD images from one of the sites listed at
fedora.redhat.com/download/
mirrors.html
), you can install the source files and build various applica-
tions directly from the source files. Fedora Core source-code files also come
in RPMs, just as the executable binary files, and these source-code RPM files
are generally known as SRPMS (for source RPMs).
To install a specific source RPM and build the application, follow these steps:
1. Mount the DVD-ROM by typing mount /mnt/cdrom or waiting for the
GNOME desktop to mount the DVD.
TEAM LinG - Live, Informative, Non-cost and Genuine !
Book V
Chapter 4
Installing and
Updating
Applications
Updating Linux Applications Online
437
2. Typically, source RPMs are in the SRPMS directory. Change to that
directory by typing the following command:
cd /mnt/cdrom/SRPMS
3. Install the source RPM file by using the rpm -i command. For exam-
ple, to install the Web server (httpd) source, type
rpm -ivh httpd*.src.rpm
The files install in the /usr/src/redhat/SOURCES directory. A spec file
with a .spec extension is placed in the /usr/src/redhat/SPECS direc-
tory. The spec file describes the software and also contains information

file and gathers information about new versions of installed packages.
The
apt-get upgrade command actually installs any available new ver-
sions of the packages installed in your Debian system. You must perform
apt-get upgrade to install any available upgrades.
To install new packages in Debian, use
apt-cache search to find the pack-
age name in APT’s package cache and then use apt-get install to install
the package.
Updating Fedora Core Applications
Fedora Core comes with Up2date — a graphical Update Agent that can
download any new RPM files your system requires and install those files for
you. Up2date is also known as the Red Hat Update Agent because Red Hat
developed it for its Red Hat Network through which Red Hat provides serv-
ices to its commercial customers.
To update Fedora Core software packages using Up2date, follow these steps:
1. Log in as root, and choose Main Menu➪System Tools➪Red Hat
Network. You can also type up2date in a terminal window.
The Red Hat Update Agent starts, and, if you’re using Up2date for the
first time, a dialog box prompts you to install a public key in your GPG
key ring. (GPG refers to GNU Privacy Guard or GnuPG, a program for
encrypting, decrypting, and signing e-mail and other data using the
OpenPGP Internet standard.) That public GPG key verifies that the pack-
age developer has securely signed the package that Up2date has down-
loaded. If prompted to do so, click Yes to install the public key.
2. Up2date displays a window with a welcome message. Click the
Forward button to proceed.
3. Up2date displays a list of what it calls channels — repositories from
where the agent downloads package headers. Click Forward to
continue.

In Fedora Core, you can also use the Yellow dog Updater, Modified (Yum) —
a command-line utility for updating as well as installing and removing RPM
packages. Yum downloads RPM package headers from a specified Web site
and then uses the
rpm utility to figure out any interdependencies among
packages and what needs to be installed on your system. Then it downloads
and uses
rpm to install the necessary packages. Yum downloads just the
headers to do its job and the headers are much smaller in size than the com-
plete RPM packages. Yum is much faster than the alternative, where you
manually download the complete RPM packages using the
rpm command.
Typically, you keep your system up to date with the graphical Update Agent
because it’s easy to use. However, knowing how to run Yum from the com-
mand line is good, just in case you have problems with the Update Agent.
You can read more about Yum and keep up with Yum news by visiting the
Yum Web page at
linux.duke.edu/projects/yum.
The command line for Yum has the following syntax:
yum [options] command [packagenames]
options
is a list of Yum options, command specifies what you want Yum to
do, and packagenames are the names of a packages on which Yum performs
that action. You must provide the command, but the options and package-
names
are optional. That’s why I show them in square brackets in the syntax.
Table 4-2 summarizes the Yum commands and Table 4-3 lists some common
Yum options.
TEAM LinG - Live, Informative, Non-cost and Genuine !
Updating Linux Applications Online

needed to update the packages installed on your system.
You can specify package names to update only some packages. For example,
to update the kernel and
xorg-x11 packages, use the following Yum
command:
yum update kernel* xorg-x11*
TEAM LinG - Live, Informative, Non-cost and Genuine !
Book V
Chapter 4
Installing and
Updating
Applications
Updating Linux Applications Online
441
This command updates all packages whose names begin with kernel and
xorg-x11.
You may use the options to further instruct Yum what to do. For example, if
you want to download the updated packages, but not install them, type
yum download-only update
Another typical option is exclude, which enables you to exclude one or
more packages from the update process. Suppose you want to update every-
thing except the GNOME packages (whose names begin with
gnome) and the
rhythmbox package. Then you type the following Yum command:
yum exclude=gnome* exclude=rhythmbox upd
Updating SUSE online
SUSE comes with YOU — YaST Online Update — for online software updates.
To access YOU, select Main Menu➪System➪YaST and from the YaST Control
Center’s Software category, click Online Update. This brings up the YaST
Online Update window, as shown in Figure 4-2.

packages to be downloaded and the disk space needed to install them.
Figure 4-3:
Select YOU
patches and
click Accept
to install
them.
TEAM LinG - Live, Informative, Non-cost and Genuine !
Book V
Chapter 4
Installing and
Updating
Applications
Updating Linux Applications Online
443
Click Ok. Xandros Networks then downloads the software updates and
installs them.
Behind the scenes, Xandros Networks uses Debian’s
apt-get command to
download and install the software updates.
The Xandros Networks window also offers options to install new software.
You can even shop for new applications through Xandros Networks. If you
have RPM or DEB files to install, you can do so in Xandros Networks by
selecting File➪Install RPM File or File➪Install DEB File.
Figure 4-5:
Xandros
Networks
displays
summary
information

upgrade simply because the new version corrects some problems or sup-
ports your hardware better. On the other hand, if an earlier kernel version
has everything you need, you don’t have to rush out and upgrade.
Sometimes, you may want to rebuild the kernel even when it has no fixes or
enhancements. The Linux kernel on the companion DVD-ROM is generic and
uses modules to support all types of hardware. You may want to build a new
kernel that links in — incorporates into the kernel’s binary file — the drivers
for only the devices installed on your system. In particular, if you have a
SCSI hard drive, you may want to create a kernel that supports your SCSI
adapter. Depending on your needs, you may also want to change some of
the kernel-configuration options, such as creating a kernel that’s specific for
your processor (instead of a generic Intel 386 processor).
In this chapter, I explain how to rebuild and install a new Linux kernel.
Rebuilding the Kernel
Rebuilding the kernel refers to creating a new binary file for the core Linux
operating system. This binary file is the one that runs when Linux boots.
TEAM LinG - Live, Informative, Non-cost and Genuine !
Rebuilding the Kernel
446
You may wonder why you would ever want to rebuild the kernel. Well, here
are a few reasons:
✦ After you initially install Linux, you may want to create a new kernel that
includes support for only the hardware installed on your system. In par-
ticular, if you have a SCSI adapter, you may want to create a kernel that
links in the SCSI driver. The kernel on the companion DVD-ROM includes
the SCSI driver as an external module that the kernel loads at startup.
✦ If you have a system with hardware for which only experimental support
is available, you have to rebuild the kernel to include that support into
the operating system.
✦ You may want to recompile the kernel and generate code that works well

✦ Building a new initial RAM disk (
initrd) file
✦ Installing the kernel and setting up GRUB
TEAM LinG - Live, Informative, Non-cost and Genuine !
Book V
Chapter 5
Customizing the
Linux Kernel
Rebuilding the Kernel
447
I explain these phases in the next few sections, but first you need to know the
difference between linking in a driver versus building a driver as a loadable
module.
Creating a monolithic versus a modular kernel
You have two options for the device drivers needed to support various hard-
ware devices in Linux:
✦ Link in support: You can link the drivers for all hardware on your
system into the kernel. The size of the kernel grows as device-driver
code incorporates into the kernel. A kernel that links in all necessary
code is called a monolithic kernel because it’s one big file.
✦ Use modules: You can create the device drivers in the form of loadable
kernel modules. A module is a block of code that the kernel can load after
it starts running. A typical use of modules is to add support for a device
without having to rebuild the kernel for each new device. Modules don’t
have to be device drivers; they can also add new functionality to the
kernel. A kernel that uses modules is called a modular kernel.
You don’t have to create a fully monolithic or fully modular kernel. In fact,
linking some support directly into the kernel but building infrequently used
device drivers in the form of modules is common practice. For a Linux distri-
bution, including a mostly modular kernel makes sense, along with a large

ters. For each question, respond with a y to link support into the kernel,
m to build a module, and n to skip the support for that specific device.
✦ Type make oldconfig to use a shell script to reconfigure the kernel after
upgrading the sources. This configuration script keeps the existing
options and prompts you only for new or changed options.
The
make menuconfig, make xconfig, make config, and make oldconfig
commands achieve the same end result — each stores your choices in a text
file named
.config located in the /usr/src/linux* directory. Because the
filename starts with a period, you don’t see it when you use the
ls command
alone to list the directory. Instead, type ls -a to see the
.config file in the
directory listing.
The kernel-configuration step merely captures your choices in the
.config
file. (In fact, the .config file does not exist until you configure the kernel
once.) The kernel file does not change until you compile the kernel with the
make command. That means you can go through the kernel-configuration
option as many times as you want. If you want to start over with default set-
tings, type the following command before you start configuring the kernel:
make mrproper
For an overview of the kernel configuration build steps that you can perform
with the
make command, type the following in a terminal window (after
you type cd /usr/src/linux* to change the current directory to the correct
location):
make help | more
Before starting to reconfigure the kernel, take a look at a typical .config


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status