old-www/LDP/LG/issue32/lg_tips32.html

682 lines
22 KiB
HTML

<!--startcut ==========================================================-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>More 2 Cent Tips & Tricks LG #32</title>
</head>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#A000A0"
ALINK="#FF0000">
<!--endcut ============================================================-->
<H4>"Linux Gazette...<I>making Linux just a little more fun!</I>"
</H4>
<P> <hr> <P>
<!-- QUICK TIPS SECTION ================================================== -->
<center>
<H1><A NAME="tips"><IMG ALIGN=MIDDLE ALT="" SRC="../gx/twocent.gif">
More 2&#162; Tips!</A></H1> <BR>
Send Linux Tips and Tricks to <A HREF="mailto:gazette@ssc.com">
gazette@ssc.com
</A></center>
<p><hr><p>
<H3>Contents:</H3>
<ul>
<li><a HREF="./lg_tips32.html#hammel">2 Cent Tip from the 'Muse</a>
<li><a HREF="./lg_tips32.html#hristev">Tips and Tricks: Keeping track of your config files</a>
<li><a HREF="./lg_tips32.html#hefferson">2 cent tip: Cross platform text conversion.</a>
<li><a HREF="./lg_tips32.html#leggett">XFree86 and the S3ViRGE GX2 chipset</a>
<li><a HREF="./lg_tips32.html#peda">Clearing the Screen</a>
<li><a HREF="./lg_tips32.html#kelly">Re: Shell Scripting Resources <-- TIP</a>
<li><a HREF="./lg_tips32.html#kerr">Re: Recognising the AMD K5-PR166</a>
<li><a HREF="./lg_tips32.html#brooke">Your atapi CDROM</a>
<li><a HREF="./lg_tips32.html#looijaard">Tips: simulataneous kernel versions</a>
<li><a HREF="./lg_tips32.html#siew">Creating man pages made easy!</a>
<li><a HREF="./lg_tips32.html#samuelson">2c Tip Re: Cross-platform Text Conversions</a>
<li><a HREF="./lg_tips32.html#scgmille">Un-tar as you download</a>
<li><a HREF="./lg_tips32.html#burns">megaraid drivers</a>
<li><a HREF="./lg_tips32.html#wood">Re: simultaneous versions of Kernels</a>
</ul>
<P> <hr> <P>
<!--================================================================-->
<a name="hammel"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
2 Cent Tip from the 'Muse
</H3>
Date: Fri, 28 Aug 1998 00:13:07 -0600 (MDT)<BR>
From: Michael J. Hammel, <A HREF="mailto:mjhammel@fastlane.net">
mjhammel@fastlane.net</A>
<P>
You know, I don't think anyone's mentioned it before in the Gazette, but
there is this little program that is handy as all get out: units. You give
it the units you have and specify what you want it converted to and--viol&aacute;!
It converts it for you! It won't do Celsius/Fahrenheit conversions, but
handles Grams/Pounds conversions just fine. And for all those Linux cooks
out there, it converts cups to quarts, teaspoons to tablespoons and cups to
tablespoons.
<P>
It's the units freak's Swiss Army knife. No hacker forced to make his own
Thai curries should be without it.
<P>
Michael J. Hammel
<P> <hr> <P>
<!--================================================================-->
<a name="hristev"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Tips and Tricks: Keeping track of your config files
</H3>
Date: Mon, 03 Aug 1998 11:00:16 +1200<BR>
From: Ryurick M. Hristev<A HREF="mailto:physrmh@phys.canterbury.ac.nz">
physrmh@phys.canterbury.ac.nz</A>
<P>
This is my trick for keeping track of the many config files you find
on a Linux/Unix system.
<p>
Most config files are in the /etc directory. However, particularly on a
home machine, you won't change them all and sometimes you want to save
(e.g. on a floppy) only the files you have changed. Besides, you don't
want to have to remember the exact location for every one.
<p>
So here's what I do:
<ul>
<li>created a /root/config directory
<li>Each changed config file for whatever program gets a symlink
in the /root/config
</ul>
<p>
Then every time I want to change something, I go directly to /root/config.
If I want to back up my system configuration, I just copy the files
by dereferencing the symlinks, etc. ...
<p>
Cheers,<br>
Ryurick M. Hristev
<P> <hr> <P>
<!--================================================================-->
<a name="hefferson"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
2 cent tip: Cross platform text conversion.
</H3>
Date: Thu, 06 Aug 1998 13:07:59 -0400<BR>
From: Jim Hefferon, <A HREF="mailto:jim@joshua.smcvt.edu">
jim@joshua.smcvt.edu</A>
<P>
To convert to a DOS text file, mount a DOS floppy and copy the text
file.
<PRE>
$ su (you are prompted for a password)
# mount /dev/fd0 -t msdos /mnt/floppy (the # says that you are root
BE CAREFUL!)
# cp myfile.tex /mnt/floppy
# exit
$
</PRE>
For instance, after these, I can use SAMBA to get myfile.tex to an
NT network printer
(Z:> copy \\mymachinename\mnt\floppy\myfile.tex lpt2). It makes sense
if you do this often
to have a DOS disk always mounted, but if you mount as above, remember
to umount before
you try, say, mounting a different floppy.
<P>
I find this easier than a solution with the tr command, because I always
forget how to
do such solutions, but I can remember how to copy.
<P>
Jim Hefferon
<P> <hr> <P>
<!--================================================================-->
<a name="leggett"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
XFree86 and the S3ViRGE GX2 chipset
</H3>
Date: Wed, 05 Aug 1998 16:51:53 -0500<BR>
From: Ti Leggett, <A HREF="mailto:tlegget@mailhost.tcs.tulane.edu">
tlegget@mailhost.tcs.tulane.edu</A>
<P>
At work, we just got in a whole slew of computers that use the S3ViRGE
GX2 chipset. Upon trying to install X on these things, I found that the
default Red Hat 5.0 XFree doesn't cut it. This is how I've been able to
fix the XFree86 problems with the S3V GX/2 chipset. First, do not use
the S3V server despite what Xconfigurator says. The GX/2 chipset is not
supported for that server. You must use the SVGA server (besides, it's
accelerated and supports DPMS). Currently, these are the modes supported
as of XFree86-3.3.2pl3:
<PRE>
8bpp:
640x480 works
800x600 works
1024x768 works
1280x1024 works
15/16bpp:
640x480 works
800x600 works
1024x768 works
1280x1024 works
24 bpp:
640x480 works
800x600 works
1024x768 works
1280x1024 works (very picky about monitor modelines though)
32 bpp:
640x480 works
800x600 works
1024x768 does not work
1280x1024 does not work
</PRE>
The card I'm using to test this is a #9 9FX Reality 334 w/8MB RAM. Also,
I cannot verify that this works on any version less than
XFree86-3.3.2pl2. pl2 actually has less modes/depth combinations that
work - such as, no 16-bit depths work and 1280x1024 doesn't work in
almost all depths. I suggest upgrading to XFre86-3.3.2pl3. Now on to the
fix.
<P>
Step 1. Make sure you're using the SVGA server (ls -l /etc/X11/X for RH
users, maybe the same on other distros). It should point to
/usr/X11R6/bin/XF86_SVGA. If it's not, link it to it (ln -sf
/usr/X11R6/bin/XF86_SVGA /etc/X11/X).
<P>
Step 2. Open your /etc/X11/XF86Config file for editing.
<P>
Step 3. Find the Graphics Device Section.
<P>
Step 4. Find the device that is the Standard VGA Device (usually has the
line -
<PRE>
Identifier "Generic VGA"
</PRE>
Step 5. Remove the line that says:
<PRE>
Chipset "generic"
</PRE>
Step 6. Uncomment the line that says:
<PRE>
VideoRam "256"
</PRE>
and change it to recognize the amount of RAM your card has in kilo
<PRE>
VideoRam "8192" # 8MB RAM
</PRE>
Step 7. Add the following line (*CRUCIAL*):
<PRE>
Option "xaa_no_color_exp"
</PRE>
This turns off one of the accelerated option that gives trouble.
<P>
Step 8. Add whatever other options you want (for a list, see the man
pages on XF86Config, XF86_SVGA, and XF86_S3V)
<P>
Step 9. Change the bit depth and resolution to whatever you want.
<P>
Step 10. Save and close the file and (re)start X.
<P>
Note: I do not claim this will work for all cards using the GX2 chipset. I
can only verify for the video card I'm using. I'm interested to hear how
other video cards handle it. Hope that helps everyone involved. I've
heard from people on Usenet that it works perfectly, and from others it
doesn't.
<P>
Ti Leggett
<P> <hr> <P>
<!--================================================================-->
<a name="peda"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Clearing the Screen
</H3>
Date: Wed, 05 Aug 1998 12:59:13 -0400<BR>
From: Allan Peda, <A HREF="mailto:allan@interport.net">
allan@interport.net</A>
<P>
A few days ago a classmate "accidentally" cat'ed a file
to the screen. He asked asked me what he could do to
reset his confused vt100, as "clear" wasn't sufficient.
<P>
At first I figured he would need to close and re-open the
connection, but then I realized that there are codes to
reset a vt100.
<P>
Here is some C code that resets, and clears the screen.
Save it as vt.C, then run "make vt". Place the executable
in your path, and when the screen looks like heiroglyphics, type
(blindly at this point) "vt". That should clear it up.
<PRE>
/*
** Small program to reset a confused vt100 after
** `cat'ing a binary file.
*/
#include &lt;stdio.h&gt;
int main(void)
{
printf("\033c"); // reset terminal
printf("\033[2J"); // clear screeen
return(0);
}
/*
For more info, see the following URLs:
www.mhri.edu.au/~pdb/dataformats/vt100.html
www.sdsu.edu/doc/texi/screen_10.html
www.cs.utk.edu/~shuford/terminal/ansi_x3.64.html
They have more vt100 escape codes.
**
*/
</PRE>
<P> <hr> <P>
<!--================================================================-->
<a name="kelly"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Re: Shell Scripting Resources <-- TIP
</H3>
Date: Wed, 5 Aug 1998 17:34:50 +0100 (BST)<BR>
From: Sean Kelly, <A HREF="mailto:S.Kelly@newcastle.ac.uk">
S.Kelly@newcastle.ac.uk</A>
<P>
In issue 31 it was mentioned that someone had been looking for
some shell scripting help.
<P>
Take a look at http://www.oase-shareware.org/shell/ as I have
heard many people mention this site in response to shell scripting
queries.
<P>
Sean.
<P> <hr> <P>
<!--================================================================-->
<a name="kerr"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Re: Recognising the AMD K5-PR166
</H3>
Date: Wed, 05 Aug 1998 11:22:43 -0400<BR>
From: Shane Kerr, <A HREF="mailto:kerr@wizard.net">
kerr@wizard.net</A>
<blockquote> <font color="navy">
I'm wondering whether any other readers have used the AMD K5-PR166 with
Linux. It's just that my system seems to think it's a K5-PR133 and states
that it's running at 100MHz. Also, the BogoMips value indicates that the
processor is running at 100MHz.
Anyone any advice?
</font></blockquote>
I'm running a K5 P133+ on one of my systems - it actually is running at
100 MHz, that's why it's a "P133+". It's like the Cyrix processors, the
name is basically a lie for marketing.
<P>
I wouldn't put too much stock in the BogoMips value - it is bogus after
all! My system clocks in at an equivalent to a 112 MHz system when I run
the distributed.net client - the reason AMD claims a higher clock value
is probably because some instructions run faster, and those may just not
happen to be the instructions used in the BogoMips loop.
<P>
As for your system thinking your K5-PR166 is a K5-PR133, it's probably
because you have the motherboard jumpered wrong and/or the BIOS
configured wrong. Are you sure your motherboard & BIOS support the
chip?
<P>
Shani
<P> <hr> <P>
<!--================================================================-->
<a name="brooke"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Your atapi CDROM
</H3>
Date: Thu, 06 Aug 1998 16:50:04 -0500<BR>
From: Ian and Iris, <A HREF="mailto:brooke@mail.jump.net">
brooke@mail.jump.net</A>
<P>
Your /dev directory is the culprit. Current installs use:
<PRE>
/dev/hda
/dev/hdb
/dev/hdc
/dev/hdd
(/dev/hde)
(/dev/hdf)
</PRE>
for the first, second, (and third) ide interfaces, m,s,m,s(,m,s). Older installs
had the /dev directory written a little differently. You would have the old
standard, which was
<PRE>
/dev/hdnx
</PRE>
where n was interface, and x was a/b for master/slave.
<P>
The only difference is in the names of the files. If you rename them, you will
be in compliance. Alternatively, you could run makedev from a recent kernel,
though I do not pretend to know all the details of that.
<P> <hr> <P>
<!--================================================================-->
<a name="looijaard"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Tips: simulataneous kernel versions
</H3>
Date: Fri, 14 Aug 1998 17:35:14 +0200<BR>
From: Frodo Looijaard, <A HREF="mailto:frodol@dds.nl">frodol@dds.nl</A>
<P>
<blockquote> <font color="navy">
From: Renato Weiner, reweiner@yahoo.com<BR>
Recently I was looking at the Gazette and I think I have a good
suggestion of an article that will be very useful for the Linux
community. I have had some technical difficulties of having two
simultaneous versions of Kernels in my system. I mean a stable one
and a developing one. I searched the net looking for information of
how to co-exist both but it's completely fragmented. If somebody
more experienced could put all this information together, it will
certainly help a lot of people from kernels developers to
end-users.
</font></blockquote>
This may come a bit late, but I am in the process of writing a (mini)HOWTO
on this subject. It is not quite trivial, especially with modules lying
around, or if you want several kernels with the same version number.
<P>
Check out <A HREF="http://huizen.dds.nl/~frodol/howto.html">
http://huizen.dds.nl/~frodol/howto.html</A> for now. I am still in
the process of getting it approved as an official mini-HOWTO.
<P>
Frodo
<P> <hr> <P>
<!--================================================================-->
<a name="siew"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Creating man pages made easy!!!
</H3>
Date: Sun, 16 Aug 1998 16:14:34 +1000<BR>
From: Steven K.H. Siew, <A HREF="mailto:ksiew@tig.com.au">
ksiew@tig.com.au</A>
<P>
Below is something I wrote to help laypeople create their own man pages
easily.
<P>
----------------------------------------------------------------------------
----
<P>
If you ever wrote a program using gcc in Linux, you may have come across
this problem. You have just finished your wonderful little program which is
of great use to you and you need a man page for it.
<P>
Of course, you have absolutely no idea how to write a man page. Don't you
need to know how to use troff? Or is it nroff to write a man page? Luckily,
there is a much easier way to write a man page.
<P>
Here I shall describe an easy and quick (and dirty) way of writing a man
page without learning troff or nroff. In order to do so, you must have the
Perl version 5.004 (or higher) installed on your Linux box.
<P>
There is a man page in the various Perl man pages on the creation of a man
page using the Perl util "pod2man". It is called "perlpod.1". Below is a
step by step guide to finding the man page and the util.
<PRE>
ksiew> su
password:
#|/root>locate perlpod.1
/usr/man/man1/perlpod.1
#|/root>locate pod2man
/usr/bin/pod2man
</PRE>
Now, to write your own man pages, you must first read the perlpod.1 man page.
You can do this by "man perlpod". However, to read the pod2man man page, you
must first create it by using pod2man itself.
<PRE>
#|/root>pod2man /usr/bin/pod2man > pod2man.1
#|/root>ls -al pod2man.1
-rw-r--r-- 1 root root 13444 Aug 16 12:12 pod2man.1
#|/root>mv pod2man.1 /usr/man/man1/pod2man.1
</PRE>
Okay, now you can read the pod2man man page you have just created by using
the command "man pod2man". After reading it, you can now create your own man
pages. As an example, I shall describe a simple man page for one of my own
C programs called "addline". I first create a textfile called "addline.pod"
and then turn it into a manpage using 'pod2man --center="Addline program
manpage" addline.pod > addline.1'.
<P>
Finally, I move the addline man page into its proper place using "mv
addline.1 /usr/man/man1/addline.1". There; creating your own man page is
simple, isn't it?
<P>
Below is a sample addline.pod file
<PRE>
=head1 NAME
addline - addline numbers to textfiles
=head1 SYNOPSIS
B&lt;addline&gt;
[ B<-c> ]
[ B<-v> ]
[ B<-3> ]
[ B<--colon> ]
I&lt;inputfile&gt;
=head1 DESCRIPTION
B&lt;addline&gt; inserts line numbers into textfiles. It was written to automate
the insertion of numbers into a data file of results from a neural network
program.
=head1 OPTIONS
=over 8
=item -c
Ignores comments lines. A comment line is any line that starts with a '#'.
This makes it easier to insert comments in the textfile without messing up
the line numbers.
=item -v
Displays the version number of the addline.
=item -3
Uses 3 digits for the line numbers even if the number requires less than 3
digits. For example, 013 instead of 13. The default is to use as few
digits for the line number as possible.
=item --colon
Separates the line number from the rest of the line with a ':' character.
=back
=head1 EXAMPLES
addline textfile
addline -c textfile
addline -c --colon textfile
=head1 NOTES
Addline is written in C and compiled using gcc version 2.7.8. It uses the
standard C library and is designed to be fast and efficient.
=head1 RESTRICTIONS
Never ever use addline on a binary file.
=head1 BUGS
There are no bugs in addline, there are just some undocumented features.
=head1 AUTHORS
Original prototype by Steven Siew, but so massively hacked over by
his sister such that Steven Siew probably doesn't recognize it anymore.
</PRE>
<P> <hr> <P>
<!--================================================================-->
<a name="samuelson"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
2c Tip Re: Cross-platform Text Conversions
</H3>
Date: Sun, 16 Aug 1998 07:52:17 -0500 (CDT)<BR>
From: Peter Samuelson, <A HREF="mailto:psamuels@sampo.creighton.edu">
psamuels@sampo.creighton.edu</A>
<P>
In LG31 you published a 2c tip for a unix2dos replacement written in Tcl.
The author asserts that "It turned out to be really easy to do this in
Tcl." Even easier in Perl, I say. Symlink the following code to the
same names (d2u, u2d, m2d, m2u, u2m, d2m) Matt used. Make sure this
file has execute permission, of course.
<P>
Also, if you just want Perl to edit the input files in place, change
the "perl -wp" to something like "perl -wpi.orig"....
<P>
Peter Samuelson
<PRE>
#!/usr/bin/perl -wp
#
# Simpler unix2dos2mac utility for 2-cent tip, mainly because Tcl is ugly.
# No comments that Perl is ugly too, please.
#
# Usage: a standard Unix filter:
# input: filename(s) or stdin
# output: stdout
# Buglet: u2m leaves lone CR at the end of file if it didn't end in LF
# (Fixing it would use more memory.)
BEGIN {
$_=$0 =~ s|.*/||;
$pcmd='s/$/\r/' if ($0 eq 'u2d');
$pcmd='s/\r$//' if ($0 eq 'd2u');
$pcmd='s/$/\r/;chop' if ($0 eq 'u2m');
$pcmd='s/\r/\n/g' if ($0 eq 'm2u');
$pcmd='chomp' if ($0 eq 'd2m');
$pcmd='s/\r/\r\n/g' if ($0 eq 'm2d');
unless($pcmd) {
print STDERR "This script must be invoked under one of the names:\n",
" u2d, d2u, u2m, m2u, d2m, m2d\n";
exit 1;
}
}
eval $pcmd;
</PRE>
<P> <hr> <P>
<!--================================================================-->
<a name="scgmille"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Un-tar as you download
</H3>
Date: Wed, 19 Aug 1998 13:08:52 -0500<BR>
From: <A HREF="mailto:scgmille@indiana.edu">scgmille@indiana.edu</A>
<P>
It's time for fun with pipes. Recently, when downloading the latest kernel
over a ridiculously slow connection, I wanted to see where the download
was by checking which file in the tarball was being received. After
pondering the pipes and GNU utils, this thought came to mind.
<P>
You can decompress and un-tar your files as they download, sort of a
"streaming decompressor", if you will. From the command line:
<PRE>
tail -f --bytes=1m file-being-downloaded.tar.gz | tar -zxv
</PRE>
Tail will display downloaded portion of the file, then remain open
displaying bytes as they come. Make sure the 1m (1 megabyte in this case) is
LARGER than what you have already downloaded. The piped output of tail
goes to tar and the rest is history. Similarly, for bz2 files:
<PRE>
tail -f --bytes=1m file.tar.bz2 | bunzip2 - | tar -xv
</PRE>
Enjoy!
<P> <hr> <P>
<!--================================================================-->
<a name="burns"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
megaraid drivers
</H3>
Date: Thu, 20 Aug 1998 18:34:32 -0400<BR>
From: "Michael Burns2, <A HREF="mailto:rburns@shaw.wave.ca">
rburns@shaw.wave.ca</A>
<P>
Hi,<br>
It's been a long fight to get AMI to produce this
<A HREF="./megaraid.patch">patch</A> and the <A
HREF="./megaraid.doc">install documentation</A>.
<P>
Mike Burns
<P> <hr> <P>
<!--================================================================-->
<a name="wood"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Re: Suggestion for Article, simultaneous versions of Kernels
</H3>
Date: Sat, 29 Aug 1998 21:35:27 -0400 (EDT)<BR>
From: R Garth Wood<A HREF="mailto:rgwood@itactics.itactics.com">
rgwood@itactics.itactics.com</A>
<P>
I think Hans-Georg is talking about having a
stable Linux kernel version X and a dev version X
(i.e., not 2.0.34 and 2.1.101 but 2.0.34 and 2.0.34).
I assume when you issue:
# make modules_install
it tromples your old stable modules and gives
you errors when you use your stable version X.
This is not as trivial a problem as it first
seems. However, there is a solution. Have a
look at the make-kpkg docs (Debian distro);
specifically the "flavour" option. This will
solve your problem. It won't be easy, though.
<P>
Have a look at:<BR>
/etc/conf.modules<BR>
to see what I mean.
<P>
R Garth Wood
<P> <hr> <P>
<!--================================================================-->
<center>Published in <I>Linux Gazette</I> Issue 32, September 1998</center>
<P> <hr> <P>
<!--================================================================-->
<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_mail32.html"><IMG SRC="../gx/back2.gif" ALT=" Back "></A>
<A HREF="./lg_bytes32.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P>
<h5>This page maintained by the Editor of <I>Linux Gazette</I>,
<A HREF="mailto: gazette@ssc.com">gazette@ssc.com</A><BR>
Copyright &copy; 1998 Specialized Systems Consultants, Inc. </H5>
<P>
<!--startcut ==========================================================-->
</body>
</html>
<!--endcut ============================================================-->