Sailing Free

Linux Stuff

Useful shell scripts
My articles in the Linux Gazette

Sometime back in 1997, I downloaded a base Linux setup from the Debian site and installed it with much trepidation and many a furtive glance skyward. What would it be like, running Unix on my own machine? How could I possible think that I, a lowly human, could ever administer one? Would the Elder Gods send a lightning bolt and destroy me for my hubris?

"Whom the gods would destroy they first make mad."
 -- Euripides

Hmm. Well... yes and no. 'No', meaning that I'm still alive and well, and even mostly sane, although a significant number of psychologists would disagree strenuously. 'Yes', meaning that there were plenty of times when I felt like taking my clothes off and running gibbering down the streets, particularly when trying to get Linux to drive the sound hardware, or getting X-Windows up and running. Anyway, I've succeeded - and, in the process, have come to understand computer hardware and operating systems in general far better than I ever did before - and given my almost-quarter-century experience in the field, that's saying a lot.

Admittedly, there were easier ways to do all of the above: OSS sound utilities are available for about $30 and make audio setup totally painless; commercial video servers such as Metro are available which do the same thing for XFree86. The thing was, I wanted to learn, not just plug in something that someone else had made without a clue of what they had done - if I'd wanted that, I'd have stuck with Windows!

A turbulent couple of years later, I actually consider myself somewhat of a Linux micro-Guru, and still learning at top speed. Don't get me wrong - there are guys out there that could run circles around me in some areas - but, again, given my previous knowledge of computers, with Linux added on top of it, makes a pretty awesome package. I don't know The Answers To All Mysteries (yet)... but I can set up a Linux system in jig time, audio and X included - provided that the hardware isn't some horribly non-standard, one-off production from Outer Mongolia (the camel interfaces tend to be  troublesome) - tweak any configuration file in /etc, set up routers, firewalls, DNS servers, Web servers, MySQL databases, PPP dial-up and hard links, networking hardware and software... endless list of stuff. The capabilities of Linux - the major reason I'd switched to it in the first place - are effectively unlimited. As a "workhorse", a machine that has to perform serious work instead of just being a toy with a pretty interface, it's unbeatable - and the `pretty interfaces' are becoming available for it as well.

There are some Linux limitations... ones it shares with Windows NT, BeOS, and 99% of other OSes: weird hardware is usually not supported. These days, though, you have to go further and further afield to define "weird". I have an ATI `All-in-Wonder' video card on my desktop machine which includes TV-reception capability - and I can happily watch TV, at the very rare times that I do so, in a program that runs under X.

Recently, I had the interesting experience of setting up a network based around a Linux server for the only IPOP (Internet Point Of Presence) in St. Georges, Bermuda. The boss machine acts as an IP-Masquerade server and a dial-up server for an iMac and a Windows machine, meaning that all three get to share a single dial-up connection via so-called Network Address Translation (see diagram below). As well, when any of the three request a connection to the Net, the server honors that request and dials out.
 
ISP <------------> Server <---------------> Local machine
204.199.0.13 : 192.168.0.1 192.168.0.2
ISP-assigned LAN IP LAN IP 
The conversation goes something like this:

1) (Local machine) "Hey, server dude! How 'bout getting me that kewl porno site at 155.109.0.30?"
2) (Server) "It's that pervert, 192.168.0.2 - I'll remember that. Hey, ISP! 155.109.0.30, please?"
3) (ISP, seeing that the request comes from a known, valid IP) Sure! [Fetch, fetch. fetch...]
4) (Server) "Hey, traffic from 155.109.0.30; that was for 192.168.0.2. Here you go!"

The Linux machine also provides print services and file sharing over the network - and this is not as simple as it might appear at first glance, since all three machines "talk" to each other on the network in completely different and unrelated ways! Linux handles this via a "translator" package called Samba for the Windows machine and its equivalent for Apple, Netatalk. Setting up the iMac proved to be a bit of a challenge... but, with the help of the various Linux HOWTOs and looking up the various discussions that other Linux people have had in relation to this, I got through with minimal problems.
 
 

The network at Ocean Sails



Lots of other Linux-based services too numerous to mention - among them, netdate to synchronize the network to the Naval Observatory atomic clock; ipfwadm, providing firewall services; eql, to allow load-balancing between two dial-up lines (installed but, alas, not active - the Bermuda phone company had been promising that second line for six months...); a dynamically created web page, via a shell script that I wrote, that allows me to access the network remotely whenever it's up... tons of stuff. All completed and running smoothly in under a week.

Due to money restrictions, the server is also used as a surfing machine. The `guest' login restricts what they can do... and though there's no security in obscurity, Netscape is the only familiar-looking thing on their screen. To make it even more interesting, I've used icewm as the window manager and coolicon for the icons, which makes it look more-or-less like a Win95 interface. The only available icons are Netscape `shortcuts' to the various Web-mail providers, which is the reason 99.9% of these folks come into the shop.
 
 

Useful shell scripts

In the process of learning Linux, I've written a number of shell scripts (somewhat like DOS batch files, though infinitely more powerful and flexible). They are available here, all copylefted via the GNU Public License. In short, copy them, enjoy them, modify them - but do not restrict their distribution, and give me the credit for the original authorship. Simple.

Note: You'll probably need to right-click on these and choose `Save link as...' in Netscape, or whatever the equivalent is in your browser (due to strange Geocities ftp restrictions, all these files have ".txt" extensions - just save them without these). If you want them to actually run, you'll need to make them executable by typing chmod +x <file> . Otherwise, just read and enjoy them...
 
bkgr random background selector for X-Windows; I run it from .xinitrc and let it surprise me...
xlck random animated background selector that uses xlock - good fun, if you've got the speed...
recipe search engine for MealMaster-format recipe files. I've got about 300,000 of them, myself.
xwin simple way of starting X-Windows; lets you easily select the color depth (for games, etc)
fd mount/dismount utility for the floppy drive. Easily modified for any mountable device.
after executes a program after a given process is finished (e.g., halt after mp3 stops playing)
doc the easiest method of looking up info in the /usr/doc hierarchy yet!
grepfd no-mount method of searching DOS floppies for a given filename
howto *the* best way for a Linux newbie to find info in the "man" database!
sfx create self-extracting tarballs under Linux
tip run a system-wide tip repository where any user can contribute useful ideas
vol single-parameter volume control. When you play a CD and somebody's set the volume
THIS LOUD! 
<grin>

 
 

My articles for the Linux Gazette

These days, I'm also a Contributing Editor to the Linux Gazette, a terrific resource for any Linux newbie. I've written a number of things for them; a lot of them, including my "Introduction to Shell Scripting" and "Introduction to Perl", can be found here.
 
 

Main PagePersonal Stuff The Remembrance Day Page E-mail me



Graphics created using
The Ultimate Graphics Tool - The GIMP!
The WebMaster
© 1999 by
Benjamin Okopnik
The Choice of the GNU Generation!

 
1