<!doctype linuxdoc system> 

<article>

<title>The Linux Tips HOWTO
<author>Vince Reed, <tt/reedv@rpi.edu/
<date>v0.1, 30 August 1994
<abstract>
This document describes time-saving ideas and procedures intended to make linux
easier to configure and use. Items found here are too general to be included in
one of the other howtos.
</abstract>

<toc>

<sect>Introduction
<p>
Welcome to the <bf/Linux Tips HOWTO/, a place to find swift answers to questions not covered in the more specific linux howtos. In the tips howto, you'll also find neat little tricks that make managing and using Linux systems easier. However, as this is only the second release of the tips howto, the number of tips mentioned is still rather small. The next issue needn't be this way though... Please send me your ideas to be included in future howtos. Thanks in advance!

Vince Reed <em/Maintainer--Linux TIPS HOWTO/

<tt/reedv@rpi.edu/
<sect> Short Tips

<sect1> Moving directories between filesystems. <it/Alan Cox,/ 
<tt/A.Cox@swansea.ac.uk/

<p>
Quick way to move an entire tree of files from one disk to another
<tscreen><verb>
(cd /source/directory; tar cf - . ) | (cd /dest/directory; tar xvfp -)
</verb></tscreen>

<sect1> Pointer to patch for GNU Make 3.70 to change VPATH behavior.
<it/Ted Stern,/ <tt/stern@amath.washington.edu/

<p>
I don't know if many people have this problem, but there is a "feature" of GNU
make version 3.70 that I don't like. It is that VPATH acts funny if you give it
an absolute pathname.  There is an extremely solid patch that fixes this, which
you can get from Paul D. Smith <tt>&lt;psmith@wellfleet.com></tt>.  He also posts the
documentation and patch after every revision of GNU make on the newsgroup
'gnu.utils.bug'. Generally, I apply this patch and recompile gmake on every
system I have access to.

<sect1> How do I stop my system from fscking on each reboot? <it/Dale Lutz,/ 
<tt/dal@wimsey.com/

<p>
Q:  How do I stop e2fsck from checking my disk every time I boot up.

A:  When you rebuild the kernel, the filesystem is marked as 'dirty' and
    so your disk will be checked with each boot.  The fix is to run:

        rdev -R /zImage 1

    This fixes the kernel so that it is no longer convinced that the 
    filesystem is dirty.

<em/Note: If using lilo, then add /<tt/read-only/ <em>to your linux setup in your lilo config file (Usually /etc/lilo.conf) </em>

<sect1>How to avoid fscks caused by "device busy" at reboot time. 
<it/Jon Tombs,/ <tt/jon@gtex02.us.es/

<p>
If you often get device busy errors on shutdown that leave the filesystem in
need of an fsck upon reboot, here is a simple fix:

To <tt>/etc/brc</tt> or <tt>/sbin/brc</tt>, add the line
<tscreen><verb>
mount -o remount,ro /mount.dir
</verb></tscreen>
for all your mounted filesystems except /, before the call to umount -a. This
means if, for some reason, shutdown fails to kill all processes and umount the
disks they will still be clean on reboot. Saves a lot of time at reboot for
me



<sect1>How to print pages with a margin for hole punching. <it/Mike Dickey,/ 
<tt/mdickey@thorplus.lib.purdue.edu/

<p>
<tscreen><code>
        #!/bin/sh
        # /usr/local/bin/print
        # a simple formatted printout, to enable someone to
        # 3-hole punch the output and put it in a binder

        cat $1 | pr -t -o 5 -w 85 | lpr
</code></tscreen>

<sect1>A way to search through trees of files for a particular regular expression.
<it/Raul Deluth Miller,/ <tt/rockwell@nova.umd.edu/

<p>
I call this script 'forall'.  Use it like this:
<tscreen><verb>
forall /usr/include grep -i ioctl
forall /usr/man grep ioctl
</verb></tscreen>
Here's forall:
<tscreen><code>
#!/bin/sh
if [ 1 = `expr 2 \> $#` ]
then
        echo Usage: $0 dir cmd [optargs]
        exit 1
fi
dir=$1
shift
find $dir -type f -print | xargs "$@"
</code></tscreen>

<sect1>A script for cleaning up after programs that creat autosave and backup files.
<it/Barry Tolnas,/ <tt/tolnas@nestor.engr.utk.edu/
<p>
Here is a simple two-liner which recursively descends a
directory hierarchy removing emacs auto-save (~) and backup (&num;) files, .o 
files, and  TeX .log files. It also compresses .tex files and
README files. I call it 'squeeze' on my system.
<tscreen><code>
#!/bin/sh
#SQUEEZE removes unnecessary files and compresses .tex and README files
#By Barry tolnas, tolnas@sun1.engr.utk.edu
#
echo squeezing $PWD
find  $PWD \( -name \*~ -or -name \*.o -or -name \*.log -or -name \*\#\) -exec
rm -f {} \;
find $PWD \( -name \*.tex -or -name \*README\* -or -name \*readme\* \) -exec gzip -9 {} \;
</code></tscreen>

<sect> Detailed Tips

<sect1>Sharing swap partitions between Linux and Windows. <it/Tony Acero,/ 
<tt/ace3@midway.uchicago.edu/

<p><enum>
<item> Format the partition as a dos partition, and create the Windows
swap file on it, but don't run windows yet. (You want to keep the swap
file completely empty for now, so that it compresses well).

<item> Boot linux and save the partition into a file.  For example if the partition was /dev/hda8:
<tscreen><verb>
dd if=/dev/hda8 of=/etc/dosswap
</verb></tscreen>
<item> Compress the dosswap file; since it is virtually all 0's it will compress very well
<tscreen><verb>
gzip -9 /etc/dosswap
</verb></tscreen>
<item> Add the following to the /etc/rc file to prepare and install the swap space under Linux:

<em/XXXXX is the number of blocks in the swap partition/
<tscreen><verb>
mkswap /dev/hda8 XXXXX
swapon -av   
</verb></tscreen>
Make sure you add an entry for the swap partition in your /etc/fstab file

<item> If your init/reboot package supports /etc/brc or /sbin/brc add the
following to /etc/brc, else do this by hand when you want to boot to
dos|os/2 and you want to convert the swap partition back to the
dos/windows version:
</enum>
<tscreen><verb>
swapoff -av
zcat /etc/dosswap.gz | dd of=/dev/hda8 bs=1k count=100
</verb></tscreen>
# Note that this only writes the first 100 blocks back to the partition. I've found empirically that this is sufficient 

&gt
&gt  What are the pros and cons of doing this?

Pros: you save a substantial amount of disk space.

Cons: if step 5 is not automatic, you have to remember to do it by hand,
and it slows the reboot process by a nanosecond :-)


<sect1>How to configure xdm's chooser for host selection. 
<it/Arrigo Triulzi,/ <tt/a.triulzi@ic.ac.uk/

<p><enum>
<item> Edit the file that launches xdm 
most likely /etc/rc/rc.6 or /etc/rc.local) so that it contains the
following lines in the xdm startup section.<tscreen><verb>        
/usr/bin/X11/xdm
exec /usr/bin/X11/X -indirect hostname
</verb></tscreen>
<item> Edit /usr/lib/X11/xdm/Xservers and comment out the line which
starts the server on the local machine [i.e. starting 0:]

<item> Reboot the machine and you're home and away.
</enum>
<p>
I add this because when I was, desperately, trying to set it up for
my own subnet over here it took me about a week to suss out all the
problems.

Caveat: with old SLS (1.1.1) for some reason you can leave a -nodaemon
after the xdm line -- this does <bf/NOT/ work for later releases.
</article>

