"Linux Gazette...making Linux just a little more fun!"


More 2¢ Tips!


Send Linux Tips and Tricks to [email protected]


Contents:


2 Cent Tip from the 'Muse

Date: Fri, 28 Aug 1998 00:13:07 -0600 (MDT)
From: Michael J. Hammel, [email protected]

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á! 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.

It's the units freak's Swiss Army knife. No hacker forced to make his own Thai curries should be without it.

Michael J. Hammel


Tips and Tricks: Keeping track of your config files

Date: Mon, 03 Aug 1998 11:00:16 +1200
From: Ryurick M. Hristev [email protected]

This is my trick for keeping track of the many config files you find on a Linux/Unix system.

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.

So here's what I do:

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. ...

Cheers,
Ryurick M. Hristev


2 cent tip: Cross platform text conversion.

Date: Thu, 06 Aug 1998 13:07:59 -0400
From: Jim Hefferon, [email protected]

To convert to a DOS text file, mount a DOS floppy and copy the text file.

 
  $ 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
  $
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.

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.

Jim Hefferon


XFree86 and the S3ViRGE GX2 chipset

Date: Wed, 05 Aug 1998 16:51:53 -0500
From: Ti Leggett, [email protected]

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:

 
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
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.

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).

Step 2. Open your /etc/X11/XF86Config file for editing.

Step 3. Find the Graphics Device Section.

Step 4. Find the device that is the Standard VGA Device (usually has the line -

 
	Identifier      "Generic VGA"
Step 5. Remove the line that says:
 
	Chipset         "generic"
Step 6. Uncomment the line that says:
 
	VideoRam        "256"
and change it to recognize the amount of RAM your card has in kilo
 
	VideoRam        "8192" # 8MB RAM
Step 7. Add the following line (*CRUCIAL*):
 
	Option          "xaa_no_color_exp"
This turns off one of the accelerated option that gives trouble.

Step 8. Add whatever other options you want (for a list, see the man pages on XF86Config, XF86_SVGA, and XF86_S3V)

Step 9. Change the bit depth and resolution to whatever you want.

Step 10. Save and close the file and (re)start X.

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.

Ti Leggett


Clearing the Screen

Date: Wed, 05 Aug 1998 12:59:13 -0400
From: Allan Peda, [email protected]

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.

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.

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.

 
/*
** Small program to reset a confused vt100 after 
** `cat'ing a binary file.
*/
#include <stdio.h>

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.
**
*/


Re: Shell Scripting Resources <-- TIP

Date: Wed, 5 Aug 1998 17:34:50 +0100 (BST)
From: Sean Kelly, [email protected]

In issue 31 it was mentioned that someone had been looking for some shell scripting help.

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.

Sean.


Re: Recognising the AMD K5-PR166

Date: Wed, 05 Aug 1998 11:22:43 -0400
From: Shane Kerr, [email protected]
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?
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.

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.

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?

Shani


Your atapi CDROM

Date: Thu, 06 Aug 1998 16:50:04 -0500
From: Ian and Iris, [email protected]

Your /dev directory is the culprit. Current installs use:

 
/dev/hda
/dev/hdb
/dev/hdc
/dev/hdd
(/dev/hde)
(/dev/hdf)
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
 
/dev/hdnx
where n was interface, and x was a/b for master/slave.

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.


Tips: simulataneous kernel versions

Date: Fri, 14 Aug 1998 17:35:14 +0200
From: Frodo Looijaard, [email protected]

From: Renato Weiner, [email protected]
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.
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.

Check out http://huizen.dds.nl/~frodol/howto.html for now. I am still in the process of getting it approved as an official mini-HOWTO.

Frodo


Creating man pages made easy!!!

Date: Sun, 16 Aug 1998 16:14:34 +1000
From: Steven K.H. Siew, [email protected]

Below is something I wrote to help laypeople create their own man pages easily.

---------------------------------------------------------------------------- ----

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.

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.

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.

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.

 
ksiew> su
password: 

#|/root>locate perlpod.1
/usr/man/man1/perlpod.1

#|/root>locate pod2man
/usr/bin/pod2man
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.
 
#|/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
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'.

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?

Below is a sample addline.pod file

 

=head1 NAME

addline - addline numbers to textfiles

=head1 SYNOPSIS

B<addline>
[ B<-c> ]
[ B<-v> ]
[ B<-3> ]
[ B<--colon> ]
I<inputfile>

=head1 DESCRIPTION

B<addline> 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.


2c Tip Re: Cross-platform Text Conversions

Date: Sun, 16 Aug 1998 07:52:17 -0500 (CDT)
From: Peter Samuelson, [email protected]

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.

Also, if you just want Perl to edit the input files in place, change the "perl -wp" to something like "perl -wpi.orig"....

Peter Samuelson

 
#!/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;


Un-tar as you download

Date: Wed, 19 Aug 1998 13:08:52 -0500
From: [email protected]

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.

You can decompress and un-tar your files as they download, sort of a "streaming decompressor", if you will. From the command line:

 
tail -f --bytes=1m file-being-downloaded.tar.gz | tar -zxv
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:
 
tail -f --bytes=1m file.tar.bz2 | bunzip2 - | tar -xv
Enjoy!


megaraid drivers

Date: Thu, 20 Aug 1998 18:34:32 -0400
From: "Michael Burns2, [email protected]

Hi,
It's been a long fight to get AMI to produce this patch and the install documentation.

Mike Burns


Re: Suggestion for Article, simultaneous versions of Kernels

Date: Sat, 29 Aug 1998 21:35:27 -0400 (EDT)
From: R Garth Wood [email protected]

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.

Have a look at:
/etc/conf.modules
to see what I mean.

R Garth Wood


Published in Linux Gazette Issue 32, September 1998


[ TABLE OF 
CONTENTS ] [ FRONT PAGE ]  Back  Next


This page maintained by the Editor of Linux Gazette, [email protected]
Copyright © 1998 Specialized Systems Consultants, Inc.