Previous Next Contents

2. Short Tips

2.1 Handy Syslog Trick Paul Anderson, Tips-HOWTO maintainer

Edit your /etc/syslog.conf, and put in the following line:

# Dump everything on tty8
*.*                                     /dev/tty8
One caveat: REMEMBER TO USE TABS! syslog doesn't like spaces...

2.2 Handy Script to Clean Up Corefiles. Otto Hammersmith,ohammers@cu-online.com

Create a file called rmcores(the author calls it handle-cores) with the following in it:


#!/bin/sh
USAGE="$0 <directory> <message-file>"

if [ $# != 2 ] ; then
        echo $USAGE
        exit
fi

 echo Deleting...
find $1 -name core -atime 7 -print -exec rm {} \;

echo e-mailing
for name in `find $1 -name core -exec ls -l {} \; | cut -c16-24`
do
        echo $name
        cat $2 | mail $name
done

And have a cron job run it every so often.

2.3 Moving directories between filesystems. Alan Cox, A.Cox@swansea.ac.uk

Quick way to move an entire tree of files from one disk to another

(cd /source/directory && tar cf - . ) | (cd /dest/directory && tar xvfp -)
Change from cd /source/directory; tar....etc. to prevent possibility of trashing directory in case of disaster. Thanks to Jim Dennis, jadestar@rahul.net, for letting me know. -Maint.

2.4 Finding out which directories are the largest. Mick Ghazey,mghazey@miso.lowdown.com

Ever wondered which directories are the biggest on your computer? Here's how to find out.

du -S | sort -n

2.5 The Linux Gazette

Kudos go to John Fisk, creator of the Linux Gazette. This is an excellent e-zine plus, it's FREE!!! Now what more could you ask? Check it out at:

http://www.redhat.com/lg
While you're there, drop John Fisk a note telling him how wonderful an e-zine LG is.

2.6 Pointer to patch for GNU Make 3.70 to change VPATH behavior.Ted Stern, stern@amath.washington.edu

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 <psmith@wellfleet.com>. 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.

2.7 How do I stop my system from fscking on each reboot? Dale Lutz, dal@wimsey.com

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.

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

2.8 How to avoid fscks caused by "device busy" at reboot time. Jon Tombs, jon@gtex02.us.es

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 /etc/rc.d/init.d/halt or /etc/rc.d/rc.0, add the line

mount -o remount,ro /mount.dir
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.

2.9 How to find the biggest files on your hard-drive.

Simon Amor, simon@foobar.co.uk

ls -l | sort +4n

Or, for those of you really scrunched for space this takes awhile but works great:

cd /
ls -lR | sort +4n

2.10 How to print pages with a margin for hole punching. Mike Dickey, mdickey@thorplus.lib.purdue.edu


        #!/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

2.11 A way to search through trees of files for a particular regular expression.Raul Deluth Miller, rockwell@nova.umd.edu

I call this script 'forall'. Use it like this:

forall /usr/include grep -i ioctl
forall /usr/man grep ioctl
Here's forall:

#!/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 "$@"

2.12 A script for cleaning up after programs that create autosave and backup files.Barry Tolnas, tolnas@nestor.engr.utk.edu

Here is a simple two-liner which recursively descends a directory hierarchy removing emacs auto-save (#) and backup (~) files, .o files, and TeX .log files. It also compresses .tex files and README files. I call it 'squeeze' on my system.


#!/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 {} \;

2.13 How to find out what process is eating the most memory. Simon Amor,simon@foobar.co.uk

ps -aux | sort +4n
-OR-
ps -aux | sort +5n


Previous Next Contents