[ Prev ][ Table of Contents ][ Front Page ][ FAQ ][ Next ]

More 2¢ Tips!

Send Linux Tips and Tricks to gazette@ssc.com

Let cron put backup files into your Gnome trashcan

Sat, 30 Dec 2000 01:02:24 -0500
From: Allan Peda (tl082@yahoo.com)
Cron to put bacup files in trash (if you have a gnome desktop):
I typed this up to keep my home dir clean, it assumes backup files over 1 day old should be moved to the trashcan. I run it every 5 minutes under cron
# script to move trash files to trash can
# use cron to run this every 5 minutes

if [ x"$HOME" = x ]; then
  echo "\$HOME not defined"
  exit 1

if [ ! -d $TRASHCAN ]; then
  echo "Need a trash can to work"
  exit 1

FARGS=' -maxdepth 1 -type f -mtime +1 '
find ~ $FARGS -name '.saves-*' -exec mv {} $TRASHCAN \;
find ~ $FARGS -name  '\#*\#'   -exec mv {} $TRASHCAN \;

Seeing what's changed since your tar backup

Fri, 29 Dec 2000 09:35:11 -0800
Jim Dennis (The Answer Guy)
(If you have a full tar backup of your root and /usr filesystems you can use the 'tar df' or 'tar dzf' directives to report on differences between your current files and those in your backup.

2cent tip: lynx mpg123 and mp3.com

Mon, 11 Dec 2000 19:58:01 -0800
From: collver@softhome.net(collver@softome.net)
mp3.com uses MIME to describe audio content to web browsers. A year or two ago, mp3.com had instructions to set up audio/mpeg and audio/mpegurl in Netscape. These MIME types no longer work because mp3.com now uses audio/x-mpeg and audio/x-mpegurl instead.
Two places to configure viewers for MIME types:
/etc/mailcap $HOME/.mailcap
I suggest editting $HOME/.mailcap as it overrides /etc/mailcap.
You might already have entries placed by Netscape. If so, they assume you only use X and they look like:
#mailcap entry added by Netscape Helper
audio/x-scpls;xmms %s
#mailcap entry added by Netscape Helper
audio/x-mpegurl;xmms %s
#mailcap entry added by Netscape Helper
audio/x-mpeg;xmms %s
If you don't want to use xmms, delete these lines. If you want to use xmms when in X, replace 'xmms %s' with 'xmms %s; test=test -n "$DISPLAY"'
Then add:
audio/x-scpls; mpg123 -@ %s
audio/x-mpegurl; mpg123 -@ %s
audio/x-mpeg; mpg123 $s

The Unattended Risk

Thu, 28 Dec 2000 18:57:54 -0800

I realized the other day that locking your screen is next to useless if you start your linux box in text mode, performing a "startx &" to begin an X session, unless you Ctrl-Alt-F1 to your text virtual console and Ctrl-D logout, then you can Ctrl-Alt-F7 back to the X console, and lock the screen. Otherwise all a passerby need do is switch virtual terminals and use you account.

It's sorta obvious when you think about it. Of course an unattended Linux machine is not really secure, but still, just switching virtual consoles is a little too easy.


I've been doing "exec startx" from non-xdm machines to save myself having to log out when I quit my X session. I think it would help with this situation too. -- Don Marti
... or
startx & vlock
... to ensure that your login session will not be inadvertantly be left unlocked and unattended.
Naturally you'll also want to look at xautolock --- adding it to your .Xclients, .xsession or other windowing system start-up/configuration files as necessary.
-- Jim Dennis

Modem Question - Easy One

Sun, 17 Dec 2000 19:59:45 EST
From: Franklyn (I3utane@aol.com)

Answer Guy,

I've read an response that you posted about a win modem running in linux, it wont'. But I it was posted on Feb 22, 1999. So I was hoping that came out and gave us the source and stuff. I have a US Robotics 56k Voice Win. If they haven't, i'm out to comp usa to buy a external 3 comm (or is a internal ok?).

Be good man - thanx in advance.


See if http://linmodems.org or the Linmodem Mini HOWTO www.linuxdoc.org/HOWTO/Linmodem-HOWTO.html+linmodem&hl=en help.
An external modem is usually better anyway because modems generate a lot of heat, plus external modems don't have any OS-specific idiosynchracies.
-- Mike Orr

Monitor goes blank

Sun, 24 Dec 2000 15:29:28 +0200
From: Marius Andreiana

I'd like to turn off blanking of the monitor in X. After 10 min or so it goes blank, so I have to move the mouse from time to time when watching movies :)

I've tried setterm -blank 0 before starting the movie (put that in rc.local too) but no effect. setterm -blank 60 won't work either.

setterm affects only the console. My ~/.xsession has the following command:
"` xset dpms 1800 2400 3600 "'
which blanks the screen at 30 minutes, goes into power-save mode at 40 minutes, and "off" at 60 minutes. I use such a long time so it doesn't blank out when I'm moving back and forth between the computer and the kitchen.
There are also some options in XF86Config you can try. See "man 5 XF86Config-v3" or "man 5 XF86Config". You have to put in a "power_saver" option; then set the BlankTime, StandbyTime, SuspendTime, and OffTime in the Screen section. These are overridden by xset.
-- Mike Orr
You're on the right track but in the wrong lane. The setterm command only affects the (virtual) terminal settings. You want the xset command.
Try the command:
     xset s off

... from any xterm. Then start your moving, kick back, and watch the show.
-- Jim Dennis

Tips: sendmail offline

Tue, 26 Dec 2000 23:35:19 +0100 (MET)
From: Karl-Heinz Herrmann (k.-h.herrmann@fz-juelich.de)
since I just solved a little nuisance with the newer Sendmail 8.9.3 on my system I thought it could help somebody else.
My setup: dialup connection, local sendmail is handling all outgoing e-mail and is
queuing them until online. In my ppp-start scripts sendmail will then be triggered by 'sendmail -q' to run the queue.
Now since the last upgrade this didn't always work for mails sent offline but would work for mails sent while I was online. I now found out that sendmail is keeping a persistent host status directory.
sendmail.cf says:
# persistent host status directory
O HostStatusDirectory=.hoststat
O Timeout.hoststatus=60m ---------
So if a mail was undeliverable (offline) sendmail would remember that for 60m. Only then it would ever try it again even if online and 'sendmail -q' is run. This status seems to be associated with each mail, so new ones go out, old ones stay.
Possible solutions:
  1. reduce the timeout to 1m or similar.
  2. run 'sendmail -bH' as well in the ppp-start script. This will purge the host status cache.
I Hope this helps others to get a similar setup working faster then me ;-)
-- Karl-Heinz Herrmann

Measure your modem connection - Bogospeed

Sat, 16 Dec 2000 11:44:11 -0500
From: Ben Okopnik (of The Answer Gang)
This one does a 'bogo-measurement' of the modem connection speed. Given that I'm in the process of playing with a rather shitful internal modem (bleagh!), it comes in very handy.
Several times, I've seen people write in to LG and ask "How can I tell how fast my modem connection is?" This little script will... well, it'll do _something_ that will at least give you an idea. :)
In the tradition of "BogoMIPS", "bogospeed" gives you a relative value of your connection speed. This means that the numbers you see do not represent the actual speed of your connection - in my experience, they are about 25% high - but give you a general idea of what you should expect. If, for example, you normally see "55000 bps" as your 'bogospeed', and you see "33000 bps" on a given connection, you'll know that the connection you've just made is about 40% slower than usual (and that you should probably try reconnecting.)
"bogospeed" normally takes about 10-15 seconds to do its stuff on a decent connection with a 56k modem, and MUCH longer on a very slow connection. To stop you from wasting your time, it prints the time that is required for the first 'ping' to reach your ISP, as well as the time that it takes to execute that ping. In my experience, if that execution time is much longer than 3 seconds, you've got a poor connection and should try redialing.
Ben Okopnik
#! /bin/bash
# Estimates connection speed to your ISP

# Be nice to MindSpring; put in your own ISP's name here

# Check if 'traceroute' is installed on the system
[ -z `which traceroute` ] && {
  echo "\"${0:2}\" requires 'traceroute' to be installed."

# Check if 'bing' is installed on the system
[ -z `which bing` ] && {
  echo "\"${0:2}\" requires 'bing' to be installed"

remote=`time traceroute -m 1 $ISP 2>/dev/null|awk '{gsub("\(|\)","");print $3 " " $4}'`
echo -e "Ping time to ISP:" ${remote:15} "ms\nMeasuring speed...\n"
bing -c 1 -e 20 -S 1024 localhost ${remote:0:14} 2>&1|grep throughput

2-cent tip - module resource detection

Sat, 16 Dec 2000 11:19:44 -0500
From: Ben Okopnik (of The Answer Gang)
Here's a rather nifty script I've crufted. Given the number of times I've seen people have problems with loading modules, I think it would be pretty useful.
Actually, this two-cent tip is more like a dime (hey, I worked hard on this thing! :) Recently, I installed Debian 2.2 (potato). For various reasons - namely, the fact that I've got a weird soundcard and decided to play around with an internal (yechhh) PnP modem - I needed to load several modules that required various combinations of IRQs, DMAs, and I/O addresses. Having suffered with this in the past, I decided, once and for all, to resolve the mess.
If you are trying to load a module, and failing with a "Device or resource busy" error, then 'shotgun' is just what you need. It will try to load your module with permutations of the three supplied lists for the above values. It's smart enough to figure out which modules don't require any parameters, as well as warning you about modules that require other things. It will, as a last resort, try to load the module with "auto" values, and will give you good advice on what to do if everything else fails. All in all, it's a very useful tool if you're going to load modules for strange hardware. It will also let you know what the correct values are when it does succeed; this allows you to write them into "/etc/modules" and forget them: they'll be auto-loaded the next time you boot.
Happy resource hunting to all! :)
Ben Okopnik
# Requires bash, basename, cat, find, grep, insmod/lsmod, strings

[ -z "$1" ] && {
  cat << @END@
* 'shotgun' - a parameter guessing routine for module loading *
*** Copyright Ben Okopnik 2000 - released under the GNU GPL ***
Syntax: `basename $0` module_name

# Parameter value lists - make sure the 'iolist' makes sense for your
# hardware!
# Note that '0' is not an actual value - it tells the module to try
# a default value. This usually works, but is not the best thing.

irqlist="3 4 5 6 7 8 9 10 11 12 13 14 15 0"
dmalist="1 2 3 4 5 6 7 0"
iolist="200 210 220 230 240 250 260 270 280 290 2a0 2b0 2c0 2d0 2e0 2f0 300 310 320 330 340 350 360 370 380 390 3a0 3b0 3c0 3d0 3e0 3f0"

# Clipping the ".o" for uniform syntax

fname=$(find /lib/modules -name ${module}.o)
[ -z "$fname" ] && {
  echo "No module called \"$module\" exists under /lib/modules."


parms="$(strings -a $fname|grep ^parm)"
for p in $parms
  echo ${par%=*}

[ -z $par ] && {
  echo "This module does not require any parameters. Loading..."
  insmod $module && echo -e "\n$module loaded.\n"
  exit 1
} || {
  echo -e "\nPress a key to start the test process or 'Ctrl-C' to quit."


echo -e "This might take a while...\n"
echo -n "Running"

for irq in $irqlist
  for dma in $dmalist
    for io in $iolist
    echo -n "."
    result="$(insmod $module irq=$irq dma=$dma io=0x$io 2>/dev/null)"
    invalid=$(echo "$result"|grep -c invalid)
    unresolved=$(echo "$result"|grep -c unresolved)
    if [ $(($invalid+$unresolved)) -eq 0 ]
      out=$(lsmod|grep ^$module)
      if [ -z "$out" ]
        echo "If the module loaded successfully, you should see"
        echo "its name on the following line:"
        echo ${out% *}
        echo "The parameter values were: irq=$irq dma=$dma io=0x$io"

function badnews()
cat << @END@
Oops. It didn't load. OK, try typing "insmod $module" and see what it
says - if you get a whole bunch of 'unresolved symbol' messages, that
means there's another module that needs to be loaded before this one;
take a look in "/lib/modules/<version>/modules.dep" to find out what
that might be. Other than that, here are a few things to try:

1) Modify the values in the parameter lists at the beginning of this
script: the IRQ and the DMA ranges are probably OK, but the IOs can vary
widely - make sure they make some kind of sense for your module. This
might mean looking at the paperwork that came with your hardware or
starting up Windows to see what I/O address it's been assigned there.

2) Load the values manually. The module you're trying to load may
require more than just IRQ, DMA, and IO - the parameter list at the
start of this program will show you all the possibilities.

3) Do some more research on what the appropriate value ranges for your
module might be. Search the Web for your hardware name plus "linux" - I've
usually had good success with Google and AltaVista's "advanced" search.

4) Often, reading the appropriate part of the kernel source - even if
you are not a programmer - can be very helpful. As a good example,
reading the source for the SoundBlaster/ESS module - 'sb_ess.c' in the
'/usr/src/kernel-source-<version>/drivers/sound/' directory - enabled me
to get my WAV files to play at normal speed, by using the "esstype=1688"
parameter; it was explained in the comments near the top of the file.
The source files tend to be about half code and half comments: the good
folks that write them *want* you to understand.

Good luck!

function warn()
cat << @END@
NOTE: The following is a list of parameters your module can accept; usually,
most of these are not required. Most often, 'irq', 'io', and 'dma' are all
that are necessary; this script will try to load your module with various
values of those parameters.

If after pressing a key you do not see all three of these - 'irq', 'dma',
_and_ 'io' - on the list, you should probably quit the script by pressing
'Control-C', as the module will almost certainly fail to load despite the
lack of error messages. If the module takes no parameters, the script
will notify you of that and load it properly.

* Press 'Enter' to see the parameter list *

Backup via shell script

Thu, 14 Dec 2000 11:27:58 -0600
From: Michael Williams (not from the answer gang)

How do you back up your home file system to a remote system using shell script

If the computers are connected via TCP/IP and you have rsync and ssh installed on both machines, do:
# backup.sh

rsync -av --delete -e ssh /local/dir/ user@remote_computer:/remote/dir
Put a slash at the end of the first argument but not on the second argument. Try it first running rsync on the command line with option -n added, to see what it would do. Otherwise you may discover you're specifying the wrong directory and deleting stuff you don't want to delete.
You will have to configure ssh to let your script login without a password. If you don't have an ssh public key yet, run "ssh-keygen". Then copy your local ~/.ssh/identity.pub to the remote ~/.ssh/authorized_keys . (Or append to authorized_keys if you already have some entries in it).
-- Mike Orr

devices list

Thu, 14 Dec 2000 12:15:11 +0100
From: Monserrat Seisdedos Nuņez

Hello those in the gazette:

My question is :

there is any /dev/devices list where it is pointed out which device belongs to??? that is
hdx--> hard disks
fdx--> floppy disks

Download the kernel source (any version) and look at Documentation/devices.txt .
-- Mike Orr

Linux core files

Wed, 13 Dec 2000 15:10:02 -0500
From: ken ramseyer

I read your article in http://www.ibiblio.org/mdw/LDP/LG/issue41/tag/4.html which talks about Linux core files.

Do you know of any reasons why a core file would go to a directory other than the current working directory (cwd)?

I thought core files always went to the current directory. Meaning, the current directory of the process that was killed.

Do you know if there is a way to tell the Linux kernel where to put core files?

Not that I know of.
I have "ulimit -c 0" in my .zshrc to prevent core files from being written at all. That affects the shell process and all its descendants. Since I'm not (much of) a C programmer, core files are useless to me.
Initscript(5) says that if you have a shell script called /etc/initscript, init will use it for every process it spawns. "This script can be used to set things like ulimit and umask default values for every process." Since init is the anscestor of everything, this would be a way to stamp out all core files at once.
-- Mike Orr

linux login problem

Wed, 27 Dec 2000 15:57:40 -0800
From: Joseph Cheek to Howard Hsu...

I have found posts of yours which seem to relate to a problem I am currently having. Any help which you might provide would be greatly appreciated.

We are having trouble logging into our linux server via the console or telnet, but are able to login using the same l/p for ftp.

what are the permissions on /etc/securetty?

networked machine goes to sleep?

Sun, 03 Dec 2000 18:41:56 -0500
From: Christopher Curtis
This problem exists, or used to exist, for several people, including myself. The concensus is that the problem has to do with a cisco router: The router expects chatty windows machines that crash - if your Linux box just sits around not saying anything, cisco assumes it's dead and stops routing traffic towards it. There's a config option in the router that can turn this 'feature' off, but, as for myself, I cron a ping since I can't access the router.

NT Log on a Linux Box

Wed, 13 Dec 2000 11:15:27 -0600
From: Jonathan Hutchins
Boy, talk about "think outside the box...". [Cesar] complained that he couldn't cron the dumpel.com program to dump the NT Event Log to a flat file for viewing on Linux. While it isn't called cron, NT does have a scheduler. The command line interface is "at", and a GUI interface comes with the Resource Kit. Yes, he needs admin privileges on NT to schedule it, but he'd need root if he were trying the same thing on a Linux box.
There are also various programs to give you a remote virtual console from an NT box. We use PCAnywhere within Windows environments, but the VNC project might be very useful... http://www.uk.research.att.com/vnc

Graphics Programming for Printing / Faxing (Issue 60)

Tue, 5 Dec 2000 01:50:32 -0500 (EST)
From: Anthony E. Greene <agreene@pobox.com>
The quick and easy way for a Perl programmer to do convert data to faxable invoices/reports is to output the data as HTML, convert it to Postscript using html2ps <http://www.tdb.uu.se/~jan/html2ps.html>;, then fax the result using efax or mgetty+sendfax.
-- Tony

About RS422

Fri, 1 Dec 2000 16:46:54 +0800
From: Elijah Pau (e.pau@tct.com.hk)
Hi James,
Stumble across you page while looking for some info on RS422 product. Sorry to say that you may be answering the wrong question. As far as I know, RS422 is a hardware spec. i.e., it's about how hardware talk amongst themselves. The original question seems to be about how Linux (software) talk to the adaptor card. The representative for the card would probably be a UART. Identify that, and you are almost home.
Just my 2cents.
Cheers, and keep the helping out spirit going.
=== Elijah Pau

x-base languages for Linux

Mon, 04 Dec 2000 22:55:06 -0500
From: Hiram & Patti Rosenberg
Dear Mr. Answer Guy,
I do not know if this is the correct venue for writing to you in relation to the Linux Gazette column, so please do not throw any brickbats my way. I just wanted to add one piece of knowledge to the puzzle raised by a Michael "Mookie" Kepler's inquiry from back in 1998. I've been programming in Recital, a 4GL xbase product that runs over our Sun Solaris network. They have a product for Linux; I can not recall the price but a developer kit was only a 3 digit number as I recall. I work in the tech pubs section of a major world-class helicopter factory and we use their Unix product as the backbone of the publication production and illustration tracking system.
Recital is in Danvers, MA, just north of Boston.
Hi Rosenberg

NT Event Reporting in Unix/Linux

Fri, 1 Dec 2000 13:58:37 -0500
From: Sheldon Dubrowin (sdubrowin@ibasis.net)
I was looking for something like this also and found an article in the September 2000 issue of SysAdmin Magazine (www.sysadminmag.com). In that article, they talk about a Perl Script that can be run on the NT box that will format NT Event Log messages in a syslog format and send them to a Unix/Linux syslog server. The article is by Joe Aguiar, I haven't tried this technique yet, but I will be looking into trying this out, just not yet. Anyways, I thought you might be interested in this article.
Sheldon M Dubrowin

Need info

Tue, 12 Dec 2000 12:26:11 +0200
From: Dori Adler


I don't know if this is the appropriate email address if not I'm truly sorry.

Question: Is there a MS Exchange Server Emulator for Linux?

We were given a Tip about Tradewinds in the last month or two. Not being Windows users ourselves, we don't know how good it is. But you can try it, and if it works for you, you could write an article for us.

I need to get MS Outlook Clients with MS Exchange server Services (Only) to connect to the linus server , do you know how / where?

Normal Linux mail servers are POP3 ... IMAP is a bit less common but certainly available. So if you are more concerned about the mail than about other Exchange features, MS Outlook should already work.

Thanks and sorry again Dori

Best of luck -- Heather

Fat 32 Linux instillation

Sat, 16 Dec 2000 01:25:47 -0600
From: (tomvanberkel@mindspring.com)

Can I install Linux on a FAT 32 partition with a dual boot configuration including windows ME on the primary partition? Thanks, TVB

Yeah, there's a handful of distros aimed at living on a FAT filesystem. You can find a bunch of them listed on Linux Weekly News (www.lwn.net) - Zipslack and PhatLinux have been around a while, with new ones like Lin4Win popping up occasionally.
-- Heather

Available spcae avail on Hd!

Tue, 12 Dec 2000 09:14:44 -0800
The Chief

Hi:Iam Newbie with Linux How do I find out how much space avail on Hd! My system I have mandrake 7.1 installed on my 3Gig Hd!

The "df" command shows the amount of free space on each filesystem.
% df
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hda5              1981000   1620129    258459  87% /
/dev/hda1                 7746      5141      2205  70% /boot
My total amount of free space is 258459 + 2205 = 260664 KB (260 MB).
Extra hint: to see how much space a particular directory and all its subdirectories use, run "du DIRECTORY". This lists each subdirectory separately and then a total at the bottom. To get just the total, run "du -s DIRECTORY".

This page edited and maintained by the Editors of Linux Gazette Copyright © 2001
Published in issue 61 of Linux Gazette January 2001
HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/