More 2 Cent Tips & Tricks

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

## More 2¢ Tips!

### Contents:

- Emacs Control M Trick
- XTerm Title Trick 2
- VI Trick -- Commenting Code
- Newbie Tip on Find
- Masquerading with SendMail
- Linux Upgrade

### Emacs Control M Trick

Date: Fri, 09 Aug 1996 20:15:45 -0500
From: David Ishee <ishee@erc.msstate.edu>
To: fiskjm@ctrvax.Vanderbilt.Edu
Subject: $0.02 tip for removing Control M in emacs

After looking at issue 8 about how to remove the pesky Control-M character in vi (vim or whatever) I had to also tell how it could be done in emacs. Say you loaded up a file that has the ^M all over the place. No problem, say M-x replace-string RET C-q C-M RET RET and you're done. Emacs rulz!!

David

### XTerm Title Trick 2

Date: Tue, 13 Aug 1996 20:45:39 +0100
From: Caolan McNamara <9312811@ul.iea>
To: fiskjm@ctrvax.Vanderbilt.Edu
Subject: XTerm title tricks in Linux Gazette #6.

Just scanning through back issues and came across the tip to keep the hostname of the machine your currently logged into in your xterm titlebar (and wanted to add my 2 cents).

I work in a room of 30 linux boxes, so to keep track of which one I'm logged into despite logging in from one to another and logging out, I put

    alias precmd 'echo -n "\033]2;"`hostname`"\007"'

(course anything could be put here)
in my .cshrc. Keeps my titlebar updated at all times. As a precmd its run after every command but its a tiny overhead and steps around the issue of trying to detect log-outs.
C.

    --
    Real Life: Caolan McNamara                Local: caolan@skynet
    College:   9312811@ul.ie                  Quote: Happiness is a small sig.

### VI Trick--Commenting Code

Date: Fri, 23 Aug 96 10:30:06 EDT
From: dane@cci.com (Daniel Engel)
To: gazette@ssc.com
Subject: vi trick

This is how you comment in a block of code using vi:

    	:START,ENDs/^/# /

where START is the starting line number and END is the ending line number.

    	i.e. :10,30s/^/# /

comments in line 10 through line 30 of the current buffer (file).

same idea can be used for indentation and/or commenting out.

d. at Nortel (dane@cci.com)

### Newbie Tip on Find

Date: Tue, 20 Aug 1996 12:38:12 -0600 (MDT)
From: murphyc@cadvision.com(Jim Murphy)
To: gazette@ssc.com
Subject: Article submission: Newbie Tip on Finding

Hi,

As a new linuxer, I had a hard time finding my way around the filesystem, and discovered that I often had to find a file for some reason or other. I knew the find command was out there, but remembering all the options required to make it search the right places, find the right files, and print the right answers was something I couldn't do, at first. So I made up my own command, using a shell script, and called it "fnd".

"fnd" takes one argument, the name of the file you want to locate, complete with any wildcards you may wish to include, and pipes its output to "less", which then allows you to view a large list of results. What you get, on each line of output, is the complete path to anything which you're looking for! I find it amazingly useful (as is a rough familiarity with the "less" command.) Here's my script:

    #!/bin/bash
    find / -iname $1 -mount -print |less

That's it! The -iname option tells find to be case insensitive, the $1 is a variable which subs in your commandline argument, -mount tells find not to descend directories on other file systems like your cd-ROM (because mine is wonky and locks up the machine if it is accessed;). The -print option is required or you don't get any output! (Get used to it, it's *nix...) The | symbol tells find to direct its output to the "less" command so you can see your results in style! Don't forget the / right after the find command, or it won't know where to look. - Enjoy! You won't regret the time you spend keying in this little shortcut, and don't forget to put it in a "bin" or "sbin" directory after chmod'ing it to be executable.

Jim Murphy
murphyc@cadvision.com

### Masquerading with SendMail

Date: Tue, 27 Aug 1996 21:49:27 +0100 (GMT+0100)
From: "Robert S. Wolfram" <0wolfram01@Lelystad.Flnet.nl>
To: gazette@ssc.com
Subject: Masquerading with sendmail

Hi Marjorie,

First of all, I think it is wonderful that John devoted that much of his spare time to start and maintain the Linux Gazette. I am happy to see that it is being continued. Keep up this beautiful project!

I was very pleased with Leifs Queue-R-Mail Howto, published in issue 6 of the Gazette, but I was still left with one drawback. I have a PPP dialup account at a local provider, and when sending remote mail, the "From" address and "Return Path" should be masqueraded to match my address at the provider. If I would fill the $M macro in my 'sendmail.cf' (as installed by Slackware 3.0), it would only change my domain, so it needed some adjustment. I made some direct changes to 'sendmail.cf', but I did make a backup before trying anything! Here are the changes I made:

    > # Before the edits
    < # After the edits

First of all, I filled the $M macro for masquerading my domain and added a $N macro for masquerading my username:

    > DM
    < DMlelystad.flnet.nl
    < DN0wolfram01

Disable masquerading for the local mailer in ruleset 40:

    > R$*			$: $1 @ $M		add local qualification
    < #R$*			$: $1 @ $M		add local qualification

Include username in remote mail masquerading (rulesets 31 and 61):

    > R$* < @ $+ @ $+ >	$@ $1 < @ $3 >			$M is defined -- use it
    < R$* < @ $+ @ $+ >	$@ $N < @ $3 >			$M is defined -- use it
    > R$+			$: $1 < @ $M >			user w/o host
    < R$+			$: $N < @ $M >			user w/o host

If you send your mail as root, you might want to remove its special treatment:

    > #CLroot
    > CEroot
    < #CLroot
    < #CEroot

After sending 'sendmail' a HUP signal, my mail got masqueraded so that the receiver could just reply to the correct mailbox.
Two remarks:
First, to find ruleset xx, just search for Sxx in the beginning of a line. Secondly, tab characters between the fields in the rewriting rules are REQUIRED!!! Make sure you do not change those into spaces!

Well, those were my $0.02. I hope it was still readable.

Cheers,
Rob.

    Rob S. Wolfram   0wolfram01@lelystad.flnet.nl   rwolfram@wi.leidenuniv.nl
    W3:                                       http://www.flnet.nl/~0wolfram01
    =========================================================================
    L I N U X :   T H E   C H O I C E   O F   A   G N U   G E N E R A T I O N
    =========================================================================

### Linux Upgrade

Date: Tue, 20 Aug 1996 11:02:03 -0400
From: David Bourgin dbourgin@wsc.com
Organization: WSC Technologies, Inc.
To: linux@ssc.com
Subject: Linux upgrade

Hello,

Since this FAQ is comes up a very often in comp.os.linux.*, and since it's already mentioned in kernels 2.0.12+ in /linux/Documentation/Changes and in some News papers (still one contacting me today: The editor of the german magazine UNIXopen.) without any request from us. So I'm going to ask for you to put something in your interesting magazine. It's is how to avoid a lot of problem when upgrading a Linux box. There's a easy way, and some scripts to run. All the stuff is free, and is available by ftp, located at: ftp://ftp.wsc.com/pub/freeware/linux/update.linux/

The upgrade is full, it means it will upgrade any system from 1.2.x (sorry I didn't test any earlier setup). It will be right for anyone from new Linux users to experts (no knowledge is required, no questions are done: all is detected and worked fine for all people who tested, except non-Lilo users since I force Lilo v19 to install. This will change next.)

All the upgrade is always up to date, and only fully tested packages are included (!). For example, I didn't install kernel 2.0.5 when it comes out since I've found out a bug in the code (reported to Linus who did 2.0.6 as a patch). Current upgrade contains:

- New kernel: 2.0.x
- New gcc: 2.7.2
- New libc: 5.4.2
- New libg: 2.7.1.4
- New ld.so: 1.8.1
- New bin utils 86: 0.3
- New modules: 2.0.0
- New make: 3.74
- New lilo: 19
- New autoconf 2.10
- New binary utilities 2.6.0.15 (2.7 only works with kernel 2.0.8+)
- New dip 3.3.7o
- New fdisk 3.04
- New fdutils 4.2
- New fsck 1.04
- New ftape 2.08
- New gawk 3.0.0
- New getty_ps 2.0.7i
- New gpm 1.09
- New hd param 3.0
- New iBCS 2.0 960610
- New man 1.4h
- New man pages 1.12
- New mount 2.5k
- New mtools 3.0
- New ncurses 1.9.9e
- New net tools 1.32alpha
- New pcmcia modules 2.8.18
- New ppp 2.2.0f
- New ps,top,who,w 1.01
- New sendmail 8.7.5a
- New SysVinit 2.64
- New TermCap 2.0.8a
- New apache (HTML server) 1.1.1
- New boot sys 0.4a
- New DosEmu: 960807
- New ghostscript 3.33
- New IP masquerading ipfwadm 2.2
- New lclint 2.1b
- New loadlin 16
- New ntfs 951231a
- New quotas 1.51
- New samba
- New snd-util 3.5
- New socks 5b 0.16.4
- New Linux utilities: 2.5
- New WINE: 960717
- New Netscape: 3.0 (not a freeware!)

All is NOT installed when requested. For more details, see README file at
ftp://ftp.wsc.com/pub/freeware/linux/update.linux/

I know some mirrors exist in Europe as:
ftp://ftp.ibp.fr/pub/linux/update.linux/

Note: I'm French, and I've moved two months ago from France. So sorry if my American is not yet plain ;-)

Bye, David
--
Web: http://www.accescyb.fr/~rezo1/homepage.html
E-mail: dbourgin@wsc.com
David Bourgin - Netware/Unix administration/security.
I'm a netsurfer, and as such, a citizen of the worlda.

This page written and maintained by the Editor of Linux Gazette, gazette@ssc.com