The Linux Tips HOWTO Paul Anderson, panderso@ebtech.net v1.0, June 1996 This HOWTO contains those hard to find hints and tweekings that make Linux a bit nicer. 1. Introduction Welcome to the Linux Tips HOWTO, a list of neato tricks and optimizations that make Linux more fun. All I have in here right now are tips off of the top of my head, and tips from the old Tips- HOWTO(Why take out decent tips, right?). So send all your favorite hints and tips to me so I can put them in the next Tips-HOWTO. Paul Anderson Maintainer--Linux TIPS HOWTO panderso@ebtech.net 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. 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 -) 2.3. 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.4. Ted Stern, stern@amath.washington.edu Pointer to patch for GNU Make 3.70 to change VPATH behavior. 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 . He also posts the documentation and patch after every revision of GNU make on the newsgroup system I have access to. 2.5. 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.6. 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/brc or /sbin/brc, 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 pro­ cesses and umount the disks they will still be clean on reboot. Saves a lot of time at reboot for me 2.7. 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.8. Raul Deluth Miller, rockwell@nova.umd.edu A way to search through trees of files for a particular regular expression. 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.9. Barry Tolnas, tolnas@nestor.engr.utk.edu A script for cleaning up after programs that creat autosave and backup files. 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 {} \; ______________________________________________________________________ 3. Detailed Tips 3.1. Sharing swap partitions between Linux and Windows. Tony Acero, ace3@midway.uchicago.edu 1. 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). 2. Boot linux and save the partition into a file. For example if the partition was /dev/hda8: dd if=/dev/hda8 of=/etc/dosswap 3. Compress the dosswap file; since it is virtually all 0's it will compress very well gzip -9 /etc/dosswap 4. Add the following to the /etc/rc file to prepare and install the swap space under Linux: XXXXX is the number of blocks in the swap partition mkswap /dev/hda8 XXXXX swapon -av Make sure you add an entry for the swap partition in your /etc/fstab file 5. 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: swapoff -av zcat /etc/dosswap.gz | dd of=/dev/hda8 bs=1k count=100 # Note that this only writes the first 100 blocks back to the parti­ tion. I've found empirically that this is sufficient >> 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 :-) 3.2. How to configure xdm's chooser for host selection. Arrigo Tri­ ulzi, a.triulzi@ic.ac.uk 1. 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. /usr/bin/X11/xdm exec /usr/bin/X11/X -indirect hostname 2. Edit /usr/lib/X11/xdm/Xservers and comment out the line which starts the server on the local machine i.e. starting 0: 3. Reboot the machine and you're home and away. 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 NOT work for later releases.