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


More 2¢ Tips!


Send Linux Tips and Tricks to gazette@ssc.com


Contents:


Spinning Down Unused HDs

Date: Sat, 8 Nov 1997 18:34:07 +0100 (MET)
From: Philipp Braunbeck 100.182763@germany.net

I guess there's no more need to emphasize how much we all like LG. Here's just my humble-newbie-one-and-a-half.

If You're like me and You've been upgrading for a couple of years now You're likely to have several HD's on Your IDE- or SCSI-Interfaces. Now there's probably some GNU-Linux-partition and one or more other partitions with M$-stuff on a separate disk. I've got a 120MB Conner (with actually nothing on it, I use it as a backup-device; it used to be win3.1, but I don't need it anymore :-) which is horribly loud. In the old days of DOS one friend of mine wrote a little Pascal-program which would stop the disk after a period of time, and it would only restart on some (hardware?)-interrupt. Some modern BIOSes can do that job for You, but people told me, that either it doesn't work on Linux (because the BIOS is only used on bootup in order to get some basic configuration) or it is not recommended to do so anyway.

When I was on some adventure-trip through /usr/sbin, I discovered some new species called "hdparm", which should be included on any major distribution. The manual page says that you can use it to spin down any drive on Your system! All You need to do now is putting a line like "hdparm -S1 /dev/hdb" in some boot-startup-script (I guess the filenames differ in different distributions) and You're done. What a silence!

However, You shouldn't do it with Your working /-partition, as it syncs the disk every now and then and the disk will keep starting and stopping, and this is definitely not good for any HD.

If You like my 2-cent just go ahead and publish it. If not, there will certainly be a good reason for this. As I am a newbie, i.e. I've been using GNU/Linux for about one year now, I'm humble enough to admit that this hint seems more than obvious to any experienced user. But if You decide to publish it, I'd prefer that I can stay anonymous, not because I got anything to hide, but because I don't want to pretend to be someone I'm not, like a sysadmin or I dunno. I've got too much respect for them guys who are lots more intelligent than I am, but would they ever consider to mail something as primitive as I suggest to LG? It really is a matter of getting started for unexperienced users, finding that GNU/Linux gets even more powerful while sorting it all out. So just put it in "Clueless at the prompt" or where You like. Sign with Your name, You knew the trick anyway, didn't You?


Finding What You Want with find

Date: Wed, 12 Nov 1997 16:14:43 +0000 (GMT)
From: Jon Rabone jkr@camcon.co.uk

In the October 97 issue, Dave Nelson suggests using

find . -type f -exec grep "string" /dev/null {} \;
to persuade grep to print the filenames that it finds the search expression in. This starts up a grep for each file, however. A shorter and more efficient way of doing it uses backticks:
grep "string" `find . -type f`

Note however, that if the find matches a large number of files you may exceed a command line buffer in the shell and cause it to complain.


Cutting and Pasting without a Mouse

From: fk5a005@rrz.uni-hamburg.de
Date: Wed, 5 Nov 1997 18:58:41 +0100

It is possible, I did think there was no way but there is a way to cut and paste without any mouse. Just use screen-3.6x to achieve what you may have wanted for a long time. you use screen already but did you know how to use this cut-and-paste tool?

This was pasting without leaving your keyboard for a while!

Control-a can be any key to achieve a screen-3.6 command. There are many more very useful features with screen but i guess that like me there are people out there who may not know this very useful feature. Another hint: It is really worth printing the Manual. If like me you are going by train you can read the Manual x. I found out there are so many important features in so many programs I did not know and that did help me a lot after discovering.

About vim and completion: there is a feature that lets you complete words which you did write before which is very, very useful. press control-n in Insert-mode and vim will complete your word if you typed it before. It is even better: You can get vim to complete words that are in a different file. Just tell vim what the name of the file is with :set dictionary=file Then complete the word with control-x-control-k. Now imagine how much easier it may be to get a list of words with a grep command than to write down all kinds of abbreviations and put them into a file. This is a Killer-feature IMO!

About emacs and completion:

Emacs was first with completion or at least this kind of completion mentioned for vim goes back to 1992. What you need is hippie-exp.el which can perform all kinds of completion.

About atchange

There is a very nice script out there written in perl. I like it very much because it lets you perform an action whenever you change the date of a file. The action can be almost anything like calling another program and executing things or whatever you want. The idea came from Tom Schneider who has a page about atchange out there: http://www-lmmb.ncifcrf.gov/~toms/atchange.html

I strongly encourage you to read it, this is an idea, that can really save your time. The perl-script itself is only 68 lines of code. almost one half is explanation, the most important thing is the idea itself but Tom has a good page. So I don't tell you more right now :)


Slow Modem

Date: Mon, 3 Nov 1997 17:45:13 -0600 (CST)
From:Michael J. Hammelmjhammel@long.emass.com
To: Larry E Scheib scheib@tenet.edu

In a previous message, Larry E Scheib says:

When I access a remote site with Linux my screens paint painfully slowly; a problem I don't experience with Windows95. When my modem connects under Linux it replys "Connected at 38,400", the actual speed of my modem. The modem runs off of cua1, IRQ 3.

I'm not very good at debugging modem connections. I've never really had any problems with my dial-ups except when the network itself is bogged down. To be honest, I have no idea how fast my modem connections are actually running. I just know they're tolerable (they actually seem to run quite fast - I have a 33.6 modem).

Things that might affect this would be:

  1. some other process sitting on cua0 - perhaps a getty?
  2. You didn't run setserial, a command to setup your serial ports for use with modems. I've never run this myself, but I know others have had to do so in order to get better throughput. Perhaps its because I don't use MS so my ports are not switched back and forth between MS and Linux settings.


Finding Strings with find

Date: Tue, 28 Oct 1997 16:31:47 +0100
From: Gordon Walker hellcat@easynet.fr

Being new to Linux I find the Tips section very useful in general and the tip about searching for a string with find inspired me to write my first conditional Bash script. It finds a string in the current or given directory

#!/bin/sh
## Recursively finds all strings in given or current directory
## Usage string_search <dir> <string> (dir is optional)
## For example:		 "string_search fish " finds string "fish" in current
directory
##	and 		"string_search /water fish " finds string "fish" in directory
/water
if [ "$2" = "" ]; then
	find . -type f -exec grep "$1" /dev/null {} \;
else
	find $1 -type f -exec grep "$2" /dev/null {} \;
fi


Another Calculator Tip

From: Frank Damgaard frank@diku.dk
Date: Thu, 23 Oct 1997 22:05:14 +0200 (METDST)

In issue 21 there was a smart perl based command line calculator, here is another one.

I have for some years used a simple alias for the calculator command. The alias only requires awk, and that tcsh (or csh) is the running shell. This alias will not work with bash/sh/ksh since these shells do not allow arguments in aliases.

Just place the following line in your ~/.tcshrc or type at the prompt:

alias calc 'awk "BEGIN{ print \!* }" '
# When calling calc do not escape "*":
# Example:  calc (3+5)*4/5


Upgrading a Laptop Hard Disk

Date: Fri, 24 Oct 1997 14:38:58 -0400
From: Peter Teuben teuben@astro.umd.edu

I wanted to upgrade the harddisk of my laptop, which had gotten a bit tight with 800Mb and maintaining both linux and W95 (don't ask).

I got a new 2Gb drive, and of course wanted to install W95 as well as linux. I decided, despite my die-hard Slackware, to try RedHat4.2 for linux and basically "copying" W95. Since the laptop is on a local ethernet at home, I could make a backup of W95 on the desktop, and after linux was braught up, restore W95 back over the network. Indeed this worked quite nice, but you have to remember a few tricks. Here were my basic steps:

  1. backup, using tar, the old /DOS partition accross the network
  2. replace drive, partitioned as dos on /dev/hda1, swap on hda2, ext2 on hda3 and hda4. Don't forget to toggle the bootable flags of hda1.
  3. installed linux on hda3, and did 'mkdosfs /dev/hda1' to format the dos partition from within linux (using DOS bootfloppy and FORMAT should work just as well, see my FAT32 caveat below) LILO was installed at this stage to boot linux as well as W95.
  4. by default RedHat mounts hda1 as 'dos', but you need to re-mount this still empty partition as 'vfat':
    umount /DOS
    		insmod vfat
            mount -t vfat /dev/hda1 /DOS
  5. untar the previously saved dos.tar back to /DOS, via the network from the desktop machine. Since /DOS is vfat, it will properly keep the long names.
  6. reboot the machine with a previously made 'emergency W95 bootfloppy' and run "SYS C:" to restore the bootimage
  7. reboot and select W95 from the LILO prompt, and it should all work nicely now (it did for me).

Caveat: For FAT32 versions of W95 (from OSR2 or W98) you may need to patch the 2.1.x kernels to include this.


Wallpaper

Date: Mon, 27 Oct 1997 14:38:35 +0100
From: Roger Irwin irwin@mail.com

Use netscape, got xv?

Try running this script in your home directory:

rm -f XVbaa
for foo in .netscape/cache/*
do
for baa in $foo/*.gif
do
echo $baa >>XVbaa
done
done
xv -root -quit -random -flist XVbaa

This will make you a custom wallpaper on the fly by fishing in netscapes cache.

I mapped this to my fvwm2 button bar by using the following lines in .fvwm2rc95:

*FvwmButtons(Title Mood, Icon exit.xpm, \
       Action 'Exec XVchange ')

This goes in the FVWM buttons section in the middle of the other lines that define the other buttons.... When I hit the Mood button, the wallpaper changes. I suppose a lazier person might use crontab....


PostScript

Date: Sun, 9 Nov 1997 22:00:31 +0000 (GMT)
From: Ivan Griffin [ TABLE OF 
CONTENTS ] [ FRONT 
PAGE ]  Next

This page written and maintained by the Editor of Linux Gazette, gazette@ssc.com
Copyright © 1997 Specialized Systems Consultants, Inc.

./usr/share/doc/lg/issue23/lg_tips23.html0100644000000000000000000005267206773442600017011 0ustar rootroot More 2 Cent Tips & Tricks Issue 23

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


More 2¢ Tips!


Send Linux Tips and Tricks to gazette@ssc.com


Contents:


Spinning Down Unused HDs

Date: Sat, 8 Nov 1997 18:34:07 +0100 (MET)
From: Philipp Braunbeck 100.182763@germany.net

I guess there's no more need to emphasize how much we all like LG. Here's just my humble-newbie-one-and-a-half.

If You're like me and You've been upgrading for a couple of years now You're likely to have several HD's on Your IDE- or SCSI-Interfaces. Now there's probably some GNU-Linux-partition and one or more other partitions with M$-stuff on a separate disk. I've got a 120MB Conner (with actually nothing on it, I use it as a backup-device; it used to be win3.1, but I don't need it anymore :-) which is horribly loud. In the old days of DOS one friend of mine wrote a little Pascal-program which would stop the disk after a period of time, and it would only restart on some (hardware?)-interrupt. Some modern BIOSes can do that job for You, but people told me, that either it doesn't work on Linux (because the BIOS is only used on bootup in order to get some basic configuration) or it is not recommended to do so anyway.

When I was on some adventure-trip through /usr/sbin, I discovered some new species called "hdparm", which should be included on any major distribution. The manual page says that you can use it to spin down any drive on Your system! All You need to do now is putting a line like "hdparm -S1 /dev/hdb" in some boot-startup-script (I guess the filenames differ in different distributions) and You're done. What a silence!

However, You shouldn't do it with Your working /-partition, as it syncs the disk every now and then and the disk will keep starting and stopping, and this is definitely not good for any HD.

If You like my 2-cent just go ahead and publish it. If not, there will certainly be a good reason for this. As I am a newbie, i.e. I've been using GNU/Linux for about one year now, I'm humble enough to admit that this hint seems more than obvious to any experienced user. But if You decide to publish it, I'd prefer that I can stay anonymous, not because I got anything to hide, but because I don't want to pretend to be someone I'm not, like a sysadmin or I dunno. I've got too much respect for them guys who are lots more intelligent than I am, but would they ever consider to mail something as primitive as I suggest to LG? It really is a matter of getting started for unexperienced users, finding that GNU/Linux gets even more powerful while sorting it all out. So just put it in "Clueless at the prompt" or where You like. Sign with Your name, You knew the trick anyway, didn't You?


Finding What You Want with find

Date: Wed, 12 Nov 1997 16:14:43 +0000 (GMT)
From: Jon Rabone jkr@camcon.co.uk

In the October 97 issue, Dave Nelson suggests using

find . -type f -exec grep "string" /dev/null {} \;
to persuade grep to print the filenames that it finds the search expression in. This starts up a grep for each file, however. A shorter and more efficient way of doing it uses backticks:
grep "string" `find . -type f`

Note however, that if the find matches a large number of files you may exceed a command line buffer in the shell and cause it to complain.


Cutting and Pasting without a Mouse

From: fk5a005@rrz.uni-hamburg.de
Date: Wed, 5 Nov 1997 18:58:41 +0100

It is possible, I did think there was no way but there is a way to cut a