old-www/LDP/LG/issue37/tag/43.html

469 lines
17 KiB
HTML

<!--startcut ======================================================= -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<META NAME="generator" CONTENT="lgazmail v1.1H.i">
<TITLE>The Answer Guy 37: 'fsck' Breaks 'man' Pages?</TITLE>
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000"
LINK="#3366FF" VLINK="#A000A0">
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<H4>"The Linux Gazette...<I>making Linux just a little more fun!</I>"</H4>
<P> <hr> <P>
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<center>
<H1><A NAME="answer">
<img src="../../gx/dennis/qbubble.gif" alt="(?)"
border="0" align="middle">
<font color="#B03060">The Answer Guy</font>
<img src="../../gx/dennis/bbubble.gif" alt="(!)"
border="0" align="middle">
</A></H1>
<BR>
<H4>By James T. Dennis,
<a href="mailto:linux-questions-only@ssc.com">linux-questions-only@ssc.com</a><BR>
Starshine Technical Services,
<A HREF="http://www.starshine.org/">http://www.starshine.org/</A>
</H4>
</center>
<p><hr><p>
<!-- endcut ======================================================= -->
<!-- begin 43 -->
<H3 align="left"><img src="../../gx/dennis/qbubble.gif"
height="50" width="60" alt="(?) " border="0"
>'fsck' Breaks 'man' Pages?</H3>
<p><strong>From DrDave on Wed, 27 Jan 1999
</strong></p>
<!-- ::
'fsck' Breaks 'man' Pages?
~~~~~~~~~~~~~~~~~~~~~~~~~~
:: -->
<P><STRONG>
Dear answer.guy.jim:
</STRONG></P>
<P><STRONG>
I'm not at all sure this is how one sends questions for the "Answer Guy"
column, so if I'm guessing wrong, please let me know how I should do
this before piping my message to <TT>/dev/rtfm.</TT>
</STRONG></P>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
Cute. You've guessed correctly on how to post questions.
However, you don't normally "pipe" data into "device nodes"
and you don't normally store scripts or executables under
the <TT>/dev/</TT> directory. So I might write a script to
autorespond with "RTFM" --- but I'd put it in <TT>/bin</TT> or (more
likely) <tt>~/bin</tt> (a.k.a. <tt>$HOME/bin</tt>). If I had a magic
"<tt>rtfm</tt>" device driver (sounds neat!) I'd <EM>redirect</EM> or
'<tt>cat</tt>' the message into it.
</BLOCKQUOTE>
<BLOCKQUOTE>
Still it's a clever turn of phrase.
<IMG SRC="../../gx/dennis/smily.gif" ALT=";)"
height="24" width="20" align="middle">
</BLOCKQUOTE>
<P><STRONG><IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
Anyway, I've been a Linux user for all of about 72 hours now. The first
24 or so were spent trying to figure out how to recover from some faulty
partitioning on my second drive, so we're really only looking at 48.
</STRONG></P>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
Do you ever sleep?
</BLOCKQUOTE>
<P><STRONG><IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
So, you can imagine that the "man" command is pretty vital to me...
</STRONG></P>
<P><STRONG>
Well, moments ago, I was running an X11 session and something terribly
evil happened which left me unable to properly shutdown my system. When
I rebooted, Linux complained about all sorts of problems. Through some
miracle (hey, the Pope is in town... coincidence?) I was able to figure
out how to manually run fsck as the boot messages suggested. It had to
fix a couple of problems in <TT>/root</TT>, and about 50 zillion in <TT>/hdb8</TT> which
looked like they were mostly Netscape cache files. Once that was done,
I was able to get back into Linux, and now everything seems (so far) to
be working fine. Miracles again? Hmmm...
</STRONG></P>
<P><STRONG>
Anyway... that was a bit of a lie. The one thing that isn't working
fine is my "man" command. Actually, the command runs just fine, but it
can't find any of the appropriate files. In other words, "man ls"
returns "No manual entry for ls." I tried locate man | less, thinking
that maybe some of the things fsck put in lost and found were actually
my man files, but no... those seem to be intact.
</STRONG></P>
<P><STRONG>
OK, you're the Answer Guy, so here's the question:
</STRONG></P>
<P><STRONG><BlockQuote>
How exactly does man look up a manual page that you request? Knowing
something about that procedure would help me trace my way to the
problem, methinks.
</BlockQuote></STRONG></P>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
I don't know <EM>exactly</EM> what the '<tt>man</tt>' command does.
You could read the sources to get some idea of that ---
or you could run '<tt>man</tt>' under the '<tt>strace</tt>' and/or
'<tt>ltrace</tt>'
programs (system call and library function trace utilities
for programming and debugging). I suppose you could run it
under '<tt>gdb</tt>' (the GNU interactive debugger), too.
</BLOCKQUOTE>
<BLOCKQUOTE>
However, I can give you some general ideas (which will be
far more productive than looking at the operations of '<tt>man</tt>'
through a microscope).
</BLOCKQUOTE>
<BLOCKQUOTE>
Your 'man' page sources (in groff format) are located
under <TT>/usr/man</TT> in "chapter" directories named:
<tt>man1</tt>, <tt>man2</tt>,
etc. These sources must be processed by the 'man' command
according to the method of access (printing or viewing).
</BLOCKQUOTE>
<BLOCKQUOTE>
The 'man' command maintains a set of cached pages that have
been processed by the viewer. Technically I think it uses
the 'catman' program to do this. Anyway, these are stored
under the <TT>/var/catman/</TT> hierarchy. One possibility is that
you have some corrupt files under <TT>/var/catman.</TT>
</BLOCKQUOTE>
<BLOCKQUOTE>
I supposed there are many others. Your <TT>/usr/bin/man</TT> binary
could be damaged, for example.
</BLOCKQUOTE>
<BLOCKQUOTE>
In any event it is probably easiest to simply re-install
the 'man' package. You don't specify which Linux
distribution you are using --- but I'll guess it might be
<A HREF="http://www.redhat.com/">Red Hat</A>. To re-install the man package under
Red Hat Linux --- mount your CD (probably by just
issuing the command 'mount <TT>/mnt/cdrom</TT>'), change into the
appropriate directory using the 'cd' command (no relation).
That directory is likely to be <TT>/mnt/cdrom/RedHat/RPMS.</TT>
Then issue a command like:
</BLOCKQUOTE>
<BLOCKQUOTE><BLOCKQUOTE><CODE>
rpm -i man-2.3.10-19.i386.rpm
</CODE></BLOCKQUOTE></BLOCKQUOTE>
<BLOCKQUOTE>
(where the actual filename will probably be different
--- since this particular example is from a <A HREF="http://www.suse.com/">S.u.S.E.</A>
system which maintains its own collection of RPM packages).
</BLOCKQUOTE>
<BLOCKQUOTE>
If you don't have a CD but you do have Internet access
you can use a command like:
</BLOCKQUOTE>
<BLOCKQUOTE><BLOCKQUOTE><CODE>
rpm -i ftp://$SOME_SITE/$SOME_PATH/man-X.Y.ZZ-X...rpm
</CODE></BLOCKQUOTE></BLOCKQUOTE>
<BLOCKQUOTE>
... and the 'rpm' command will fetch the file from the
site and install it in one operation.
</BLOCKQUOTE>
<BLOCKQUOTE>
The process is similar for any of the RPM based
distributions (<A HREF="http://www.caldera.com/">Caldera</A>, S.u.S.E.). For <A HREF="http://www.slackware.org/">Slackware</A> you
find the appropriate binary "tarball" on your CD (or
on any FTP mirror site). You'd then 'cd' to your root
directory and extract the contents of the .tar.gz file
using a command like:
</BLOCKQUOTE>
<BLOCKQUOTE><BlockQuote>
tar xzf <TT>/mnt/cdrom/.../man-X.YY.Z.tar.gz</TT>
</BlockQuote></BLOCKQUOTE>
<BLOCKQUOTE>
(or whatever).
</BLOCKQUOTE>
<BLOCKQUOTE>
Under <A HREF="http://www.debian.org/">Debian</A> you'd use the
'<tt>dpkg</tt>' command (which I
don't know well enough to provide an example of).
</BLOCKQUOTE>
<BLOCKQUOTE>
If you don't want to just blindly re-install; you'd
like to find out a bit more about what went wrong, you
can use any of the following:
</BLOCKQUOTE>
<BLOCKQUOTE>
Red Hat (and other RPM based systems):
</BLOCKQUOTE>
<BLOCKQUOTE><BLOCKQUOTE><CODE>
rpm -V man
</CODE></BLOCKQUOTE></BLOCKQUOTE>
<BLOCKQUOTE>
... this will query the RPM database for details
about the files that are supposed to be installed
as part of the man package and produce a
"verification" report (listing any files that are
missing, changed or have changed ownership, type or
permissions).
</BLOCKQUOTE>
<BLOCKQUOTE><BLOCKQUOTE><CODE>
rpm -Vp <TT>/mnt/cdrom/RedHat/RPMS/man-.....rpm</TT>
</CODE></BLOCKQUOTE></BLOCKQUOTE>
<BLOCKQUOTE>
... this will "verify" the installed files against
an RPM file. In other words, it doesn't rely on
the local databases but checks the installation
against an original source file.
</BLOCKQUOTE>
<BLOCKQUOTE>
Debian:
</BLOCKQUOTE>
<BLOCKQUOTE><BLOCKQUOTE><CODE>
dpkg -C $PACKAGE_NAME
</CODE></BLOCKQUOTE></BLOCKQUOTE>
<BLOCKQUOTE>
(I don't know most of the details on this. I'll
have to get another system to run Debian on).
</BLOCKQUOTE>
<BLOCKQUOTE>
Slackware and other "binary tarball" installations:
</BLOCKQUOTE>
<BLOCKQUOTE><BlockQuote><code>
cd / &amp;&amp; tar dzf $TARBALL_FILENAME
</code></BlockQuote></BLOCKQUOTE>
<BLOCKQUOTE>
(I hope it's obvious that these $XXXXs that I'm
using in these examples are placeholders where
you'll have to fill in real values as appropriate.
I'm following a common Unix documentation convention
of using placeholders that "look like" shell or
environment variable names).
</BLOCKQUOTE>
<BLOCKQUOTE>
The 'tar df' command is (with or without the -z
option) is an interesting one. It will describe
"differences" between the <tt>.tar</tt> file (<tt>.tar.gz</tt> if
used with <tt>-z</tt>, as in my example) and the filenames
relative to your current directory. Since
Slackware tarballs are relative to the root
directory we precede the command with a 'cd'
</BLOCKQUOTE>
<BLOCKQUOTE>
A practical consequence of this 'd' option to
GNU 'tar' (I don't think it's supported under
most older versions of 'tar') is that you can
also use it with your own backups. Thus if
you backup a system using the 'tar' command
to a tape drive, you can insert the tape,
(rewind it with the command '<tt>mt rewind</tt>' or
'<tt>mt -f /dev/st0 rewind</tt>') and use a command like:
</BLOCKQUOTE>
<BLOCKQUOTE><BlockQuote><code>
tar df /dev/st0
</code></BlockQuote></BLOCKQUOTE>
<BLOCKQUOTE>
... to report on all file changes since your
backup (or to verify the integrity of the backup
depending on what actually happened).
</BLOCKQUOTE>
<BLOCKQUOTE>
There are similar options to other forms of
backup. The 'cpio' command seems to have no
option for actually comparing full file contents
and meta-data (ownership, permissions, etc) ---
just a way to test "CRCs" (checksums). The
'restore' command can be used with its 'C'
directive to verify backups made with the 'dump'
command.
</BLOCKQUOTE>
<BLOCKQUOTE>
There are other, more sophisticated, ways to
perform filesystem integrity testing (to
isolate corrupted files, or detect sabotage).
'tripwire' is the most well known. After many
years of being freely available it has now
undergone a commercialization effort by one of
it's original authors.
</BLOCKQUOTE>
<P><STRONG><IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
Thanks in advance for the answer, or the redirection to a place more
appropriate to find it if that's the case.
</STRONG></P>
<P><STRONG>
David Brown
</STRONG></P>
<P><STRONG>
PS Supplemental Question: What do I need to know about all that stuff
that fsck did to fix my system? I'd try to look up the rudimentary info
about fsck in man, but...
</STRONG></P>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
Get your 'man' subsystem fixed or re-installed, then
read more about it. You can also read the source code
for the 'fsck' command --- and there is supposed to be a
very technical description of the low-level ext2 filesystem
internals in one of the LDP guides (probably the
Programmer's Guide).
</BLOCKQUOTE>
<BLOCKQUOTE>
To learn more about Linux you can start with the
guides on the Linux Documentation Project's web site
(<A HREF="http://metalab.unc.edu/LDP"
>http://metalab.unc.edu/LDP</A>). Also at this web site
are a couple of hundred HOWTOs, and a few FAQs. These
are the best introductory materials available for many
of the specific topics that they cover (they are written
by users for other users and generally give short
"real-world" examples).
</BLOCKQUOTE>
<!-- sig -->
<!-- end 43 -->
<hr width="40%" align="center"><!-- ................................ -->
<!-- begin 40 -->
<H3 align="left"><img src="../../gx/dennis/qbubble.gif"
height="50" width="60" alt="(?) " border="0"
>MANPATH was the Culprit</H3>
<H4 ALIGN="center">where'd my 'man' go?</H4>
<p><strong>From DrDave on Thu, 28 Jan 1999
</strong></p>
<!-- ::
MANPATH was the Culprit
~~~~~~~~~~~~~~~~~~~~~~~
(more on: "where'd my 'man' go?")
:: -->
<P><STRONG>
Jim:
</STRONG></P>
<P><STRONG>
I found the problem, which, it turns out, was unrelated to my
system burp and forced fsck activity. It was actually related to
a change I made in my <tt>~/.bash_profile</tt> before the badness happened.
</STRONG></P>
<P><STRONG>
I installed QT, when I was thinking it would be nice to have an
ICQ client running on my machine under Linux, and I was trying to
get LICQ to work for me (no luck there yet.) One of the
recommended changes to <tt>.bash_profile</tt> was improperly setting
$MANPATH so it included only the QT manfile path. I commented
those lines out, logged in again and now 'man' works fine.
</STRONG></P>
<P><STRONG>
I'm guessing that setting <tt>$MANPATH=/foo</tt> causes man to
automatically run as if you'd typed '<TT>man -M /foo</TT>', and
the <tt>-d</tt> option reports what it sees in the <tt>man.conf</tt> file
rather than what
it would use if it were actually going to try to fetch an entry.
</STRONG></P>
<P><STRONG>
Thanks one last time...
David
</STRONG></P>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
I should have mentioned <TT>MANPATH</TT> --- though I almost
never use it. I thought about it but it didn't relate
to the rest of your problem description at all.
</BLOCKQUOTE>
<BLOCKQUOTE>
In any event it's always a good idea to try commands
from a "test" account when they aren't working from your
normal login. There are a surprising number of problems
you can create for yourself with bad or corrupt dotfiles
in your home directory.
</BLOCKQUOTE>
<!-- sig -->
<!-- end 40 -->
<!--startcut ======================================================= -->
<P> <hr> <P>
<H5 align="center"><a href="http://www.linuxgazette.com/copying.html"
>Copyright &copy;</a> 1999, James T. Dennis
<BR>Published in <I>The Linux Gazette</I> Issue 37 February 1999</H5>
<P> <hr> <P>
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<P align="center">
<table width="98%"><tr valign="center" align="center">
<td rowspan="3" colspan="4"><A HREF="../lg_answer37.html"><IMG
SRC="../../gx/dennis/answernew.gif"
ALT="[ Answer Guy Index ]"></A></td>
<TD width="8%"><A HREF="./1.html">1</A></TD>
<TD width="8%"><A HREF="./2.html">2</A></TD>
<TD width="8%"><A HREF="./3.html">3</A></TD>
<TD width="8%"><A HREF="./4.html">4</A></TD>
<TD width="8%"><A HREF="./5.html">5</A></TD>
<TD width="8%"><A HREF="./6.html">6</A></TD>
<TD width="8%"><A HREF="./7.html">7</A></TD>
<TD width="8%"><A HREF="./8.html">8</A></TD>
<TD width="8%"><A HREF="./9.html">9</A></TD>
<TD width="8%"><A HREF="./10.html">10</A></TD>
</tr><tr valign="center" align="center">
<TD><A HREF="./11.html">11</A></TD>
<TD><A HREF="./12.html">12</A></TD>
<TD><A HREF="./14.html">14</A></TD>
<TD><A HREF="./15.html">15</A></TD>
<TD><A HREF="./16.html">16</A></TD>
<TD><A HREF="./17.html">17</A></TD>
<TD><A HREF="./18.html">18</A></TD>
<TD><A HREF="./19.html">19</A></TD>
<TD><A HREF="./21.html">21</A></TD>
<TD><A HREF="./22.html">22</A></TD>
</tr><tr valign="center" align="center">
<TD><A HREF="./23.html">23</A></TD>
<TD><A HREF="./28.html">28</A></TD>
<TD><A HREF="./29.html">29</A></TD>
<TD><A HREF="./30.html">30</A></TD>
<TD><A HREF="./31.html">31</A></TD>
<TD><A HREF="./32.html">32</A></TD>
<TD><A HREF="./33.html">33</A></TD>
<TD><A HREF="./34.html">34</A></TD>
<TD><A HREF="./37.html">37</A></TD>
<TD><A HREF="./38.html">38</A></TD>
</tr><tr valign="center" align="center">
<TD><A HREF="./39.html">39</A></TD>
<TD><A HREF="./41.html">41</A></TD>
<TD><A HREF="./42.html">42</A></TD>
<TD><A HREF="./43.html">43</A></TD>
<TD><A HREF="./44.html">44</A></TD>
<TD><A HREF="./45.html">45</A></TD>
<TD><A HREF="./46.html">46</A></TD>
<TD><A HREF="./47.html">47</A></TD>
<TD><A HREF="./48.html">48</A></TD>
<TD><A HREF="./49.html">49</A></TD>
</tr></table>
</P>
<P> <hr> <P>
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<P> <hr> <P>
<!-- begin lgnav ::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<A HREF="../index.html"
><IMG SRC="../../gx/indexnew.gif" ALT="[ Table Of Contents ]"></A>
<A HREF="../../index.html"
><IMG SRC="../../gx/homenew.gif" ALT="[ Front Page ]"></A>
<A HREF="../lg_bytes37.html"
><IMG SRC="../../gx/back2.gif" ALT="[ Previous Section ]"></A>
<A HREF="../york.html"
><IMG SRC="../../gx/fwd.gif" ALT="[ Next Section ]"></A>
<!-- end lgnav ::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
</BODY></HTML>
<!--endcut ========================================================= -->