ALINK="#FF0000">

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


More 2¢ Tips!


Send Linux Tips and Tricks to gazette@linuxgazette.net


Contents:


Re: Shutdown and Root

Date: Wed, 1 Apr 1998 06:31:04 -0500
From: Buz Cory, adm@bzsys.dyn.ml.org

From the Linux Gazette, #27

Guido Socher, eedgus@eed.ericsson.se wrote:
I noticed that many people still login as root before they power down their system in order to run the command 'shutdown -h now'. This is really not necessary and it may cause problems if everybody working on a machine knows the root password.
Very true.
Most Linux distributions are configured to reboot if ctrl-alt-delete is pressed, but this can be changed to run 'shutdown -h now'. Edit your /etc/inittab ...
 
[snip inittab]
Now you can just press crtl-alt-delete as normal user and your system comes down clean and halts.
Not necessarily the best solution.

It is perfectly safe to simply do a "Three-finger salute", allow a normal shutdown, and then power down the machine anytime after you get the message "unmounting filesystems" until you get the message during reboot saying "mounting all filesystems". Probably the easiest time would be at the LILO boot prompt (assuming you are using LILO).

An alternative I used once on a system that did *not* have <ctrl-alt-del> enabled was to provide a special login that *just* did a shutdown. There is such a line in my /etc/passwd now that I didn't put there, so I guess it's from RedHat two years ago.

Regards, ==Buz :)


Re: Core Dumps

Date: Wed, 1 Apr 1998 14:31:24 -0500 (EST)
From: Claude Morin, klode@isgtec.com

Neat idea!

Christoph Spiel says: I'd like to paste some sample output here, but neither can I find a core dump on my machine, nor do I know a program that generates one.
How to generate a core dump in one easy lesson: You've just generated a core dump by sending SIGQUIT to cat.

If this doesn't work, you probably have core dumps disabled. To check:
within bash: ulimit -a
within tcsh: limit

Lastly, you can kill -QUIT various running processes; if they don't handle the signal, they'll dump core. Remember kids: don't try this as root :-)

Claude


Easter Egg in Netscape

Date: Thu, 2 Apr 1998 11:25:56 +0800 (HKT)
From: Romel Flores, rom@elsi.i-manila.com.ph

Remember the "about:mozilla" egg? Try it again and the usuall egg appears. Now, click on the "N" logo. This will open Netscape's home page as usuall but the meteor shower on the "N" logo is replaced with Godzilla.

--Romel Flores


Host Name Completion

Date: Fri, 3 Apr 1998 01:57:43 -0500 (EST)
From: John Taylor, john@pollux.cs.uga.edu

Host name completion with BASH.

Synopsis : This is how you can use host name completion, which is similar to file name completion.

Put your favorite telnet,ftp,rlogin hosts into $HOME/.hosts, in /etc/hosts format.

example :

 
206.184.214.34   linux.kernel.org  
then put into .bashrc :

------ cut here ------

 
export HOSTFILE="$HOME/.hosts"

# see HOSTFILE in bash man page 
UseHosts()
{
  for i in $* ; do
    eval `echo "$i() { local IFS=\"@\\$IFS\"; set -- \\$1; eval command $i \\\\\\${\\$#} ; }"`
  done
}

UseHosts telnet rlogin ftp
------ cut here ------

Now do a . .bashrc, to re-source the rc file. You should have new 3 shell functions defined...telnet,rlogin,ftp do a "set | less" to verify this

now try this [notice the @]:
ftp @lin<tab-key> which completes to linux.kernel.org

Well, this breaks doing just a "ftp", but this can be fixed by doing a "command ftp", (maybe alias this??) which will give you the ftp> prompt. Rlogin will also break if you have to use the -l switch. This could be incorporated into UseHosts(), I just haven't had time to do it.

If you change the .hosts file, you have to logout and login again to use the new hosts ... don't ask me why.x>

John Taylor


Running Without Logging In

Date: Thu, 2 Apr 1998 22:50:26 -0800 (PST)
From: Jakob Kaivo, jkaivo@nodomainname.net

I notice a lot of discussion in Issue 27 of running shells on vt's without logging in. I'm sure that there are some great solutions, but I would like to add my 1/50 of a dollar to the heap. A while ago I had a need to keep a telnet session open on a vt, so I hacked mingetty to do it. Then I figured, "Hey, why stop there?" So I hacked a little more and came up with rungetty, which can run any program on a vt. It also (in the newest release) can run as any user, so a login is no problem, but you can also tell it to, say, keep a top session running on another vt. It is available from ftp://ftp.nodomainname.net/pub/rungetty/current (home site), ftp://sunsite.unc.edu/pub/Linux/system/serial/getty, and should find it's way into ftp://ftp.redhat.com/pub/contrib soon. It is available in tarball, source RPM, and binary RPM for alpha (glibc2) and i386 (libc5 and glibc2) on nodomainname, and tarball on sunsite.

Jakob Kaivo


Animation Easter Eggs in Netscape

Date: Mon, 06 Apr 1998 12:03:41 +0100 (IST)
From: Caolan McNamara, Caolan.McNamara@ul.ie

with the release of the netscape source the most important fact is now known, if your web page is not under
http://home.netscape.com/people/
http://www.netscape.com/people/
http://people.netscape.com/

then you cant have a mozilla as the animation with the X version of netscape like http://people.netscape.com/briano and 20 others have and only jamie zawinski under that tree gets the compass http://people.netscape.com/jwz

sigh, and i really hoped that i could have one too, :-(

resource for this is lines 292-319 in ns/cmd/xfe/src/Logo.cpp list of names with possible animations easters follows akkana briano bstell converse djw dora dp francis kin jwz lwei mcafee radha ramiro rhess rodt slamm spence tao toshok zjanbay

list of urls under which animation can take place.
http://home.netscape.com/people/
http://www.netscape.com/people/
http://people.netscape.com/

and usual format is
http://people.netscape.com/username

Caolan McNamara


Re: Usershell on Console Without Logging In

Date: Wed, 08 Apr 1998 20:21:42 +0200
From: Soenke J. Peters, soenke@pc1.sjp.de

In LG 27, Kragen@pobox.com announced some utilities to do an automatic login. Besides the fact that this might be a security risk, I use his program "own-tty" to have my dosemu running on a tty. Add the following line (or something adequate) to "/etc/inittab":

 
  6:23:respawn:/sbin/own-tty /dev/tty6 /usr/bin/dos dos
From inside X, CTRL-ALT-F6 beams you into dosemu, from the console ALT-F6 does the same. Press CTRL-ALT-Fx from inside dosemu to go back to ttyx. But be warned: Doing this causes a pretty high cpu-load because dosemu is _always_ runnning. To solve this problem, I inserted a "getchar();" into the source "own-tty.c" right before the "execv()" is done. This makes "own-tty" wait for a key beeing pressed before firing up dosemu.

Soenke J. Peters, Hamburg, Germany


Backing Up Win95 Files

Date: Fri, 10 Apr 1998 07:51:38 -0400
From: Donald Harter Jr., harter@mufn.org

Here is a shell script that will back up some of the windows 95 registry files on your vfat partition. You may not want to backup all the files in the script since the *.da0 files are backups themselves. There may others that I do not know about. You can use cron to run this script on a regular basis.

Donald Harter Jr.

 
#!/bin/sh
#
# This script will backup your windows 95 registry.
# If you ever have problems with windows95, restoring the registry
# might fix the problem.
# By using this script you might not have to reinstall all your
software.
# BASE_DIR is the directory where you want the tar.gz archive to be
written.
# WIN_PATH is the base path of your windows 95 partition in the
/etc/fstab file.
# Change these to suit your own needs.
# written by Donald Harter Jr.
#
BASE_DIR=$HOME
WIN_PATH=/dosc
#
#
REGISTRY_STEM=registry_`date +%m_%d_%Y`
tar -c  -f /tmp/$REGISTRY_STEM.tar --files-from=/dev/null
# some of these files may not needed
#tar -rPf /tmp/$REGISTRY_STEM.tar  file_to_backup
tar -rPf /tmp/$REGISTRY_STEM.tar $WIN_PATH/windows/system.dat
tar -rPf /tmp/$REGISTRY_STEM.tar $WIN_PATH/windows/*.da0
tar -rPf /tmp/$REGISTRY_STEM.tar $WIN_PATH/windows/user.dat
tar -rPf /tmp/$REGISTRY_STEM.tar $WIN_PATH/windows/*.ini
tar -rPf /tmp/$REGISTRY_STEM.tar $WIN_PATH/autoexec.bat
tar -rPf /tmp/$REGISTRY_STEM.tar $WIN_PATH/*.sys
tar -rPf /tmp/$REGISTRY_STEM.tar $WIN_PATH/windows/command.com
tar -rPf /tmp/$REGISTRY_STEM.tar $WIN_PATH/Program\
Files/Netscape/Users/harter/bookmark.htm
gzip /tmp/$REGISTRY_STEM.tar
mv /tmp/$REGISTRY_STEM.tar.gz $BASE_DIR/$REGISTRY_STEM.tar.gz
echo "To restore your win95 registry type:"
echo  "tar -zPxvf $BASE_DIR/$REGISTRY_STEM.tar.gz  "


Re: X-term for MS-Windows

Date: Fri, 10 Apr 1998 23:47:44 +0000
From: Milton L. Hankins, mlh@swl.msd.ray.com

What it is sounds like you want is an X *server*.

You have several options. There are a few commercial X servers out there: Hummingbird eXceed and LAN Workplace are two I know of. There's also a free X server (with much fewer features) called MI/X. You should be able to find these on the web.

You may also opt to use something like VNC, the virtual network computer. You can also find that on the web.

Milton L. Hankins


Re: Shutdown and Root Again

Date: Wed, 15 Apr 1998 19:16:23 -0600
From: Bob van der Poel, bvdpoel@kootenay.com

In last months 2 cent tips:

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

In the March issue, you have a tip on using X programs when you've run su to root. By far the easiest method is to simply
 
setenv XAUTHORITY ~khera/.Xauthority
for your own user name, of course... No need to run any other programs or cut and paste anything.

Vivek Khera, Ph.D.

----------

Just adding the needed commands took me more than a few minutes. Part of the problem is that I'm using bash, not csh as Dr. Khera is. My solution was:

  1. Add the following to the .bashrc script for root:
     
    	eval OLDHOME=~$USER
    	RCFILE=$OLDHOME/.rootrc
    	if [ -e $RCFILE ] 
            	then source $RCFILE
    	fi
    
  2. Create a file in each user's home directory called .rootrc. In this have the following line:
     
    	export XAUTHORITY=$OLDHOME/.Xauthority
    
Hope this helps someone.

Bob van der Poel, bvdpoel@kootenay.com


Running an ATAPI Zip Drive

Date: Sun, 19 Apr 1998 01:41:34 +0000
From: Steve Beach, asb4@psu.edu

I just bought an IDE ATAPI iomega Zip drive, and I couldn't find any help at all on how to use it. So, I slogged through, got a great hint from Jeff Tranter (maintainer of the 'eject' utility), and managed to get it working. In the spirit of giving back to the community, here's my (maybe even) five cent tip.

Here's how to use an IDE ATAPI zip drive on Linux.

First, the kernel: Do _not_ use the "IDE FLOPPY" option (officially the name is CONFIG_BLK_DEV_IDEFLOPPY ). This will work perfectly for reading and writing, but it will not work for ejecting. What you need to do is say yes to the option CONFIG_BLK_DEV_IDESCSI. When this is set, you will treat the IDE ATAPI drive just like a SCSI drive, except without the SCSI card and all that other garbage.

After making your kernel, you should get these messages in your startup messages (type dmesg at the prompt if they go by too fast to read):

 
hda: WDC AC34000L, 3815MB w/256kB Cache, CHS=969/128/63
hdb: WDC AC34000L, 3815MB w/256kB Cache, CHS=969/128/63
hdc: TOSHIBA CD-ROM XM-6102B, ATAPI CDROM drive
hdd: IOMEGA ZIP 100 ATAPI, ATAPI FLOPPY drive - enabling SCSI emulation
ide2: ports already in use, skipping probe
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
ide1 at 0x170-0x177,0x376 on irq 15
Floppy drive(s): fd0 is 1.44M
FDC 0 is a post-1991 82077
scsi0 : SCSI host adapter emulation for IDE ATAPI devices
scsi : 1 host.
  Vendor: IOMEGA    Model: ZIP 100           Rev: 24.D
  Type:   Direct-Access                      ANSI SCSI revision: 00
Detected scsi removable disk sda at scsi0, channel 0, id 0, lun 0
scsi : detected 1 SCSI disk total.
SCSI device sda: hdwr sector= 512 bytes. Sectors= 196608 [96 MB] [0.1
GB]
sda: Write Protect is off
.
.
.
Partition check:
 sda: sda4
 hda: hda1 hda2 hda3 hda4
 hdb: hdb1 hdb2 hdb3
The key is that SCSI simulation will be used only if the native ATAPI driver for that device isn't found. So, since the ATAPI CD driver was compiled into the kernel, it used it. Since the ATAPI removable disk driver wasn't, SCSI emulation was used.

Second, the device: If you want to have non-root users be able to mount, unmount, and eject the Zip disks, you've got to make a couple of changes to the default configuration. First thing to do is to change the permissions on the device. As root, type the following:

 
chmod a+rw /dev/sda4
The next thing to do is set a shortcut (eject is easier). Again, as root, type the following:
 
ln -s /dev/sda4 /dev/zip
Third, the mount point: Create a mount point for your drive. I like /mnt/zip, so I just do a mkdir /mnt/zip. For ease, you now want to put this into your /etc/fstab. Put a line in that file that looks like
 
/dev/sda4                 /mnt/zip                  auto   user,noauto 0
0
The first column is the device, followed by the mount point. The first 'auto' means that it will check to see the file system type when it is mounted. (Hence, you can read not only ext2fs, but also FAT, VFAT, etc.) The 'user' keyword allows average users to mount the disk, and the 'noauto' means that it will not be mounted at startup. I don't know what the two zero's mean, but it works for me.

Now, at this point, any user should be able to mount the Zip disk by typing

 
mount /mnt/zip
Unmounting would just be umount /mnt/zip.

Fourth, formatting the disks: The Zip disks you buy at your corner computer store are formatted for MSDOS. Personally, I prefer to have ext2fs formatted disks, so I don't have to worry about file name conflicts. Hence, I have to reformat them. There are two other oddities. First, the writable partition will be number 4. This is a Macintosh-ism, which you might as well leave. You can run fdisk and change the partition, but it will be much easier to just leave all your disks the same, and that way you won't have to change the line in /etc/fstab for each disk. Second, the initial permissions are not set to be writeable by the user.

To handle all this, I do the following, as root (new disk, initially unmounted): (WARNING: This will erase all data on the disk!)

 
/sbin/mke2fs -m 0 /dev/sda4
mount /mnt/zip
chmod a+w /mnt/zip
umount /mnt/zip
Now, whenever the user mounts that disk, she will be able to write to it.

Fifth, ejecting: The entire reason for using SCSI emulation is to make it easy to eject the disk. It's easy now:

 
eject zip
You can also say 'eject /dev/sda4', but since you created the symbolic link '/dev/zip', eject knows what you mean when you just say 'zip'.

One thing about eject is that the average user does not have permission to use it. So, change the permission via setuid:

 
chmod a+s /usr/bin/eject
That should allow any user to eject any disk.

Sixth, zip tools: Jarrod A. Smith (jsmith@scripps.edu) has written a really nifty little program to make mounting, unmounting, ejecting, documenting, and write protecting Zip disks really easy. The name is jaZip, and it is available as an RPM package (jaZip-0.22-3.i386.rpm) from the usual download sites, including ftp://ftp.redhat.com. Go ahead and download it -- it's only 24 K!

I hope that covers everything -- if anybody has any questions, please let me know!

Steve Beach


New Binaries Script

Date: Sat, 25 Apr 1998 01:06:03 -0700
From: Keith Humphreys, keith@SpeakerKits.com

A friend installed linux and was mystified with the abundance of new binaries. This little script was written to help introduce him to the family members. May need bash >= 2.

 
#!/bin/bash
###########################################################################
#
# mkcontents.b (c) 1998 Keith Humphreys (keith@SpeakerKits.com)  GNUed
#
# 1988.04.22
#
# This little script will create a list of descriptions for your main bins.
# It depends on whatis which appeals to the binaries man pages.  
# Intended as a learning aid for newbies and as a memory crutch (for oldbies.)
#
###########################################################################

# These are the directories to scan:

checkhere='/sbin /bin /usr/sbin /usr/bin'

###########################################################################

if ! [ -f /usr/bin/whatis ]
then
  echo '
    You appear to be missing the /usr/bin/whatis program.

    Sorry charlie,
    only the finest tuna get to be Chicken of the Sea.
    '
  exit 1
fi

for dir in $checkhere
do
  outFile=contents${dir//\//.}

  echo '------------------------------------------------------'
  if [ -f $outFile ]
  then
    rm $outFile
    echo "Removing old $outFile"
  fi
  echo "Scanning $dir and creating $outFile"
  echo '------------------------------------------------------'

  sleep 1   #To see message.

  for file in $(ls $dir)
  do
    echo $file  #For entertainment
    whatis $file >> $outFile
  done
done

exit 0


Script Contributions

Date: Sat, 18 Apr 1998 20:52:07 +0200 (SAT)
From: Stefan van der Walt, trax@the-force.ml.org

In the last few months, I wrote these simple scripts to enhance my Linux environment. I believe some other users might find them useful too, so I send you a copy.

Here are the 4 scripts provided in tar files with a README.

Thanx a mil!
BTW Keep up the great work with the Gazette. You rule :)

Stefan


Re: Core Dumps Again

Date: Sun, 26 Apr 1998 21:21:50 -0700 (PDT)
From: macker, macker@netmagic.net

In issue #26, Marty was saying "I was annoyed on Linux that file(1) couldn't tell what file dumped core if a core dump was seen.", and mentioned size(1). gdb(1) will also do the job...

gdb -c core will show the program and calling arguments, as well as the signal generated when it died, usually signal 11 (segmentation fault). quit will exit the debugger.

-macker


Published in Linux Gazette Issue 28, May 1998


[ TABLE OF 
CONTENTS ] [ FRONT PAGE ]  Back  Next


This page maintained by the Editor of Linux Gazette, gazette@linuxgazette.net
Copyright © 1998 Specialized Systems Consultants, Inc.