Penguin Tricks



Rescue and Recovery Tricks

If kernel panics after repartitioning a disk:

The solution is to tell the kernel which partition is now its root partition.
For example, at the LILO prompt, type: linux root=/dev/hda5

If root partition is mounted read-only:

Type: mount -o remount,rw -n / to remount as read/write.

If you forgot (or don't know) the root password:

Boot in single-user (maintenance) mode by typing linux single at the LILO prompt.
Linux will skip the login phase, and just drop you straight into a shell.

To force fsck to be run on next reboot:

shutdown -F now

To cancel shutdown:

shutdown -c

To scan a disk for bad blocks:

Use the program badblocks.

File Tricks

Prevent modifying/deleting/renaming a file:

Change the file's attribute to immutable using chattr:
chattr -i myfile

Terminal/Console Tricks

If characters in the terminal become garbled:

stty sane

To prevent login erasing the boot messages:

Add --noclear to the line(s) with mingetty in /etc/inittab

To enable SVGA mode in a text-mode console:

One way is to change vga=normal to vga=extended in /etc/lilo.conf and then type lilo.
Another way is to run the SVGATextMode program, eg: SVGATextMode 132x50x8

X-Windows Tricks

TrueType fonts:

Web surfing is a prettier experience when TrueType fonts are available.
If you have Windoze, *.ttf files are in \WINDOWS\FONTS.
An XFree86 4.x server can render TrueType fonts when told the path to *.ttf files. - Create the file "fonts.dir":

 cd yourFontdir
 ttmkfdir -m 100 > fonts.dir
- Tell the X server the path to your fonts:

 xset fp+ yourFontDir
 xset fp rehash

To run programs when X starts:

This is known to work on Red Hat 8 using gdm.
1. Copy the script /etc/X11/xinit/Xclients as ~/.Xclients.
2. Insert lines near the top of ~/.Xclients to start programs, for example:
#--
xhost +host1
xhost +host2
xrdb ~/.Xdefaults
xset dpms 3600 4800 5600
# Delay to override default mouse settings.
sleep 10 && xset m 4 4 &
#--

Multimedia Tricks

Sound cards on kernel 2.6:

This trick pertains to kernel 2.4-based distros that have been upgraded to kernel 2.6.
If kernel 2.6 has a driver for your sound card but you hear no sound, try this trick.
which uses aumix to turn up the volume.

In my case, I have an Opti/MAD16 ISA PnP SoundBlaster clone, its ALSA driver is snd-opti93x,
and kernel 2.6 was compiled with ALSA, OSS-emulation, and OSS mixer/PCM.
UNAME=`uname -r`
KERNVER=${UNAME:0:3}
if [ "$KERNVER" = "2.6" ]; then
    # Kernel 2.6.
    # Load sound driver.
    modprobe EDITME_YOUR_SOUND_CARD_KERNEL_MODULE
    # Load sound mixer drivers (used for playing music CDs).
    modprobe snd-mixer-oss
    modprobe snd-pcm-oss
    # 90 means 90% volume
    aumix -v 90 -c 90 -o 90 -s 90 -w 90 -b 90 -t 90
fi

Networking Tricks

Round-robin packet queueing:

The default packet queueing discipline is FIFO which can cause starvation (on opposite ends)
if NFS or FTP blasts out a ton of packets. The sfq discipline is round-robin and
may mitigate such network starvation (congestion).
# If sfq is a kernel module.
modprobe sch_sfq

# sfq for eth0.
tc qdisc add dev eth0 root sfq perturb 10

Dialup Internet Tricks

Boost WWW and telnet responsiveness over FTP transfers:

iptables can be used to boot WWW/http/telnet/etc responsiveness somewhat over FTP transfers.
Note that ftp uses two ports: "ftp" is the interactive command channel and "ftp-data" is the data channel.
# See "15.4. Prioritizing interactive traffic"
# http://lartc.org/howto/lartc.cookbook.interactive-prio.html
iptables -A PREROUTING -t mangle -p tcp --sport telnet   -j TOS --set-tos Minimize-Delay
iptables -A PREROUTING -t mangle -p tcp --sport ftp      -j TOS --set-tos Minimize-Delay
iptables -A PREROUTING -t mangle -p tcp --sport http     -j TOS --set-tos Minimize-Delay
iptables -A PREROUTING -t mangle -p tcp --sport ssh      -j TOS --set-tos Minimize-Delay
# 8000 = your http proxy port
iptables -A PREROUTING -t mangle -p tcp --sport 8000     -j TOS --set-tos Minimize-Delay

iptables -A PREROUTING -t mangle -p tcp --sport ftp-data -j TOS --set-tos Maximize-Throughput

PPP script for a USB modem on kernel 2.4 and kernel 2.6:

You'll have to edit this appropriately for your system and ISP.
I used this on Red Hat 8 with a Diamond Supra Express 56K USB modem.
My modem won't work unless bConfiguration=2 (use vendor-neutral protocol).
Other modems may work only with the default bConfiguration (?).
#!/bin/sh

# USB modem
if [ ! -c /dev/ttyACM0 ]; then
    mknod /dev/ttyACM0 c 166 0
fi

UNAME=`uname -r`
KERNVER=${UNAME:0:3}
if [ "$KERNVER" = "2.4" ]; then
    # kernel 2.4
    DEV=/dev/ttyACM0
    modprobe usbcore
    modprobe usb-uhci
    modprobe acm
else
    # kernel 2.6
    DEV=/dev/ttyACM0
    modprobe pppox
    modprobe ppp_synctty
    modprobe ppp_deflate
    modprobe ppp_async
    if ! ( lsmod | grep -q cdc_acm ); then
        modprobe usbcore
        if ! ( grep -q usbdevfs /etc/mtab ); then
            mount -t usbdevfs usbdevfs /proc/bus/usb
        fi
        echo "(patience)"

        # uhci-hcd is for Intel.
        modprobe uhci-hcd

        # cdc_acm is USB modem driver
        modprobe cdc_acm

        # Give time to driver to probe USB modem (flickers LEDs).
        # With no delay, an invalid device error will happen.
        sleep 5

        # echo 2 is to tell the driver to use a vendor-neutral protocol.
        # In kernels after 2.6.0-test2 this is necessary.
        #DIR=/sys/bus/usb/devices/1-1
        #                         ^^^ EDITME find which subdir correlates to your USB modem
        #            VVV EDITME "Supra" is the product name of my modem 
        if ( grep -q Supra $DIR/product ); then
            echo 2 > $DIR/bConfigurationValue
        fi

        sleep 5
    fi
fi

# --- CHANGE editme FOR YOUR ISP ---
#pppd -detach connect 'chat -s -v "" ATZ OK ATL1DTeditme ogin: editme ssword: editme' $DEV 115200 debug crtscts modem defaultroute

index   home