⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0075-0078.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:




<HTML>

<HEAD>

<TITLE>Maximum RPM (RPM):Getting Information About Packages:EarthWeb Inc.-</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311054 //-->

<!-- TITLE=Maximum RPM (RPM)//-->

<!-- AUTHOR=Edward Bailey//-->

<!-- PUBLISHER=Macmillan Computer Publishing//-->

<!-- IMPRINT=Sams//-->

<!-- CHAPTER=05 //-->

<!-- PAGES=0053-0078 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="0072-0074.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="../ch06/0079-0082.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-75"><P>Page 75</P></A>







<H4><A NAME="ch05_ 7">

5.2.5. --rcfile &lt;rcfile&gt;: Use &lt;rcfile&gt; As an Alternate

rpmrc File

</A></H4>





<P>The --rcfile option is used to specify a file containing default settings for RPM.

Normally, this option is not needed. By default, RPM uses

/etc/rpmrc and a file named .rpmrc, located in your login directory.

</P>



<P>This option would be used if there were a need to switch between several sets of RPM

options. Software developers and package builders will be the people using

--rcfile. For more information on rpmrc files, see Appendix B, &quot;The

rpmrc Files&quot;

</P>



<H4><A NAME="ch05_ 8">

5.2.6. --dbpath &lt;path&gt;: Use &lt;path&gt; to Find an RPM Database

</A></H4>



<P>In order for RPM to do its work, it needs access to an RPM database. Normally, this

database exists in the directory specified by the

rpmrc file entry dbpath. By default, dbpath is set to

/var/lib/rpm.

</P>



<P>Although the dbpath entry can be modified in the appropriate

rpmrc file, the --dbpath option is probably a better choice when the database path needs to be changed temporarily. An

example of a time when the --dbpath option would come in handy is when it's necessary to

examine an RPM database copied from another system. Granted, it's not a common

occurrence, but it's difficult to handle any other way.

</P>



<H3><A NAME="ch05_ 9">

5.3. A Few Handy Queries

</A></H3>



<P>The following sections describe some examples of situations you might find yourself in,

and ways you can use RPM to get the information you need. Keep in mind that these are just

examples. Don't be afraid to experiment!

</P>



<H4><A NAME="ch05_ 10">

5.3.1. Finding Config Files Based on a Program Name

</A></H4>



<P>You're setting up a new system, and you'd like to implement some systemwide aliases for

people using the Bourne again shell, bash. The problem is you just can't remember the name of

the systemwide initialization file used by bash, or where it resides:

</P>

<!-- CODE SNIP //-->

<PRE>

# rpm -qcf /bin/bash

/etc/bashrc

#

</PRE>

<!-- END CODE SNIP //-->



<P>Rather than spend your time trying to hunt down the file, RPM finds it for you in seconds.

</P>



<A NAME="PAGENUM-76"><P>Page 76</P></A>







<H4><A NAME="ch05_ 11">

5.3.2. Learning More About an Uninstalled Package

</A></H4>



<P>Practically any option can be combined with

-qp to extract information from an .rpm file.

Let's say you have an unknown .rpm file, and you'd like to know a bit more before installing it:

</P>

<!-- CODE //-->

<PRE>

# rpm -qpil foo.bar

Name        : rpm               Distribution: Red Hat Linux Vanderbilt

Version     : 2.3                     Vendor: Red Hat Software

Release     : 1                   Build Date: Tue Dec 24 09:07:59 1996

Install date:    (none)           Build Host: porky.redhat.com

Group       : Utilities/System    Source RPM: rpm-2.3-1.src.rpm

Size        : 631157

Summary     : Red Hat Package Manager

Description :

RPM is a powerful package manager, which can be used to build, install,

query, verify, update, and uninstall individual software packages. A package

consists of an archive of files, and package information, including name,

version, and description.

/bin/rpm

/usr/bin/find-provides

/usr/bin/find-requires

/usr/bin/gendiff

/usr/bin/rpm2cpio

/usr/doc/rpm-2.3-1

...

 /usr/src/redhat/SOURCES

/usr/src/redhat/SPECS

/usr/src/redhat/SRPMS

#

</PRE>

<!-- END CODE //-->



<P>By displaying the package information, we know that we have a package file containing

RPM version 2.3. We can then peruse the file list and see exactly what it would install before

installing it.

</P>



<H4><A NAME="ch05_ 12">

5.3.3. Finding Documentation for a Specific Package

</A></H4>



<P>Picking on bash some more, you realize that your knowledge of the software is lacking.

You'd like to see when it was installed on your system and what documentation is available for it:

</P>

<!-- CODE //-->

<PRE>

# rpm -qid bash

Name        :bash                       Distribution: Red Hat Linux (Picasso)

Version     :1.14.6                           Vendor: Red Hat Software

Release     :2                            Build Date: Sun Feb 25 13:59:26 1996

Install date:    Mon May 13 12:47:22 1996 Build Host: porky.redhat.com

Group       :Shells                          Source RPM: bash-1.14.6-2.src.rpm

Size        :486557

Description :GNU Bourne Again Shell (bash)

/usr/doc/bash-1.14.6-2

/usr/doc/bash-1.14.6-2/NEWS

/usr/doc/bash-1.14.6-2/README

/usr/doc/bash-1.14.6-2/RELEASE

/usr/info/bash.info.gz

/usr/man/man1/bash.1

#

</PRE>

<!-- END CODE //-->



<P>You never realized that there could be so much documentation for a shell!

</P>



<A NAME="PAGENUM-77"><P>Page 77</P></A>







<H4><A NAME="ch05_ 13">

5.3.4. Finding Similar Packages

</A></H4>



<P>Looking at bash's information, we see that it belongs to the group

Shells. You're not sure what other shell packages are installed on your system. If you can find other packages in the

Shells group, you'll have found the other installed shells:

</P>

<!-- CODE //-->

<PRE>

# rpm -qa --queryformat `%10{NAME} %20{GROUP}\n' | grep -i shells

     ash    Shells

    bash    Shells

     csh    Shells

      mc    Shells

    tcsh    Shells

#

</PRE>

<!-- END CODE //-->



<P>Now you can query each of these packages and learn more about them, too.

</P>

<BR>

<P>



<CENTER>

<TABLE BGCOLOR="#FFFF99">

<TR><TD><B>

NOTE

</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

Did you see this example and say to yourself, &quot;Hey, they could've used the

-g option to query for that group directly&quot;? If you did, you've been paying

attention. This is a more general way of searching the RPM database for

information. We just happened to search by group in this example.

</BLOCKQUOTE></TD></TR>

</TABLE></CENTER>

</P>

<H4><A NAME="ch05_ 14">

5.3.5. Finding Recently Installed Packages, Part I

</A></H4>



<P>Let's say you installed a new package a few days ago. All you know for certain is that the

package installed a new command in the /bin directory. Let's try to find the package:

</P>

<!-- CODE SNIP //-->

<PRE>

# find /bin -type f -mtime -14 | rpm -qF

rpm-2.3-1

#

</PRE>

<!-- END CODE SNIP //-->



<P>Looks like RPM version 2.3 was installed sometime in the last two weeks.

</P>



<H4><A NAME="ch05_ 15">

5.3.6. Finding Recently Installed Packages, Part II

</A></H4>



<P>Another way to see which packages were recently installed is to use the

--queryformat option:

</P>

<!-- CODE //-->

<PRE>

# rpm -qa --queryformat\

&gt; `%{installtime} %{name}-%{version}-%{release} %{installtime:date}\n'\

&gt; | sort -nr +1 | sed -e `s/^[^ ]* //'

rpm-devel-2.3-1 Thu Dec 26 23:02:05 1996

rpm-2.3-1 Thu Dec 26 23:01:51 1996

pgp-2.6.3usa-2 Tue Oct 22 19:39:09 1996

...

 pamconfig-0.50-5 Tue Oct 15 17:23:22 1996

setup-1.5-1 Tue Oct 15 17:23:21 1996

#

</PRE>

<!-- END CODE //-->



<P>By having RPM include the installation time in numeric form, it was simple to sort the

packages and then use sed to remove the user-unfriendly numeric time.

</P>



<A NAME="PAGENUM-78"><P>Page 78</P></A>







<H4><A NAME="ch05_ 16">

5.3.7. Finding the Largest Installed Packages

</A></H4>



<P>Let's say that you're running low on disk space and you'd like to see what packages you

have installed, along with the amount of space each package takes up. You'd also like to see the

largest packages first so you can get back as much disk space as possible:

</P>

<!-- CODE //-->

<PRE>

# rpm -qa --queryformat\

&gt; `%{name}-%{version}-%{release} %{size}\n'\

&gt; | sort -nr +1

kernel-source-2.0.18-5 20608472

tetex-0.3.4-3 19757371

emacs-el-19.34-1 12259914

...

rootfiles-1.3-1 3494

mkinitrd-1.0-1 1898

redhat-release-4.0-1 22

#

</PRE>

<!-- END CODE //-->



<P>If you don't build custom kernels or use

T<SUB>E</SUB>X, it's easy to see how much space could be

reclaimed by removing those packages.

</P>

<BR><BR>

<P><CENTER>

<a href="0072-0074.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="../ch06/0079-0082.html">Next</A>

</CENTER></P>











</td>
</tr>
</table>

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -