Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X

Maybe because I'm a bit of an old-timer, or maybe because I like the speed, I often use mutt for my email. Knowing that, DD forwarded me this link of good mutt tips. As an old(er) friend might say, I'm all over that like green on a frog.

Here's a sample Perl CGI program I wrote that prints out all of the environment variables it knows. I've found this program to be very useful when first installing a web server, or when debugging a problem with a web server or new environment.

Perl CGI environment variables - example program

Here's the code:

Linux mkdir question: I'm about to go to work on a new server, and I want to create subdirectories named docs, bin, and lib, and the docs directory has two subdirectories named personal and business. How can I create these directories and subdirectories with one command?

Answer: Use the "-p" option of the Unix/Linux mkdir command. The answer is shown below:

Below I've included a sample Perl CGI program that I use to edit some files on my web sites. I've modified the file a little bit for the purposes of this example, but it's essentially what I use.

Very Important: This program by itself is not secure in any way. It does not require a user login, etc. At the very least you will want to secure access to this program with an Apache htaccess configuration, or something similar on other Perl CGI web servers. This program is shown here for demonstration purposes only.

Did you ever need to take one file on a Linux or Unix system and copy it to a whole bunch of other directories? I had this problem recently when I changed some of the header files on this website. I had a file named header.html, and I needed to copy it to a bunch of subdirectories.

Using Unix, Linux, or Cygwin this turns out to be really easy. I used the Linux find command, in combination with the cp command. Once I figured out the right syntax, I was able to copy the file to nearly 500 directories in just a few seconds.

Here's a link to a quick tip on using pax instead of tar to create a large archive. The thing that got me into this problem in the first place was the new Java source code warehouse, where you can "Learn Java by Example". I basically put a search engine on top of a bunch of good open source Java projects to create something that I hope is useful.

I had a problem using the tar command this morning while trying to create a large archive, and rather than figure out what in the world I was doing wrong with find, xargs, and tar, I decided to use pax instead. It worked great at creating an archive file that tar could still read, so instead of fighting with the find/xargs/tar three-headed monster to create a large archive, pax bailed me out.

Linux process question: How can I determine which files are open by a process on a Unix/Linux system?

It seems like a couple of times a year I run into a situation where I have a zombie process that I need to get rid of, but before killing it off, I want to make sure I'm killing the right thing. Some times when a Linux process is in a zombie state, you can't see the information you need with the ps command, so you need something else.

I don't know about the mental part, but physically I'm back from Alaska. While waiting for some sys-admin things to get done last night I wrote a few Unix/Linux tips in the "etc" section of the blog. This includes tips on extracting lines from the middle of a file, determining the free memory on a Linux system, using the nohup command, and displaying nonprintable characters from a file. Busy night.

Although I've written my own Perl program to extract lines from the middle of a file, I was just reminded that this can be done with the Linux sed command.

Here's a simple sed command example. Supposed you want to print lines 500 through 600 from a file named reallyBigFile.txt. Just issue this command and you'll get what you want:

sed -n '500,600p' reallyBigFile.txt


I'm often asked how you can determine the amount of free memory (RAM) available on a Linux computer system. Here are two ways I know:

cat /proc/meminfo



Linux nohup FAQ: What is the Linux nohup command? Can you share an example of how it's used?

So you want to log off and go home for the night, but you need to run a job (process) on your Linux or Unix system that's going to take a couple of hours? Fear not, the Linux nohup command ("no hangup") will help you out.

I just ran into a need to see what non-printable (non-visible?) characters were embedded in a text file in a Unix system, when I remembered this old sed command:

sed -n 'l' myfile.txt

Note that the character in that sed command is a lower-case letter "L", and not the number one ("1").

This command shows the contents of your file, and displays some of the nonprintable characters with the octal values. On some systems tab characters may also be shown as ">" characters.

Here's a quick example of how I create a box with borders using Latex. I also show how to include a box inside a table. My motivation for this is discussed there also.

Okay, now I'm getting into the crazy LaTeX code. I'm converting HTML UI prototype images into LaTeX so I can include the prototypes in my Requirements Specification docs.

So, that being my motivation, here's some LaTeX example code that shows how to display the equivalent of a textfield inside of a table. At the very least, this demonstrates how to use the LaTeX fbox command. :)

Unfortunately, time does not permit me the opportunity to delve deeply into my thoughts here. So, here's a short list of areas within the development process that developers think are "nonnegotiable":

  1. Code quality. No sloppy code, no repeated code.
  2. Source code control. Gotta have it.
  3. Repeatable build processes.
  4. Dedicated development, test, and production environments.

There is also a secondary list of items that are close to these ... but that will have to wait for another day.


One quality I've seen in great developers is that they are vigilant, merciless, and uncompromising in certain key areas. These are areas of the development process that are nonnegotiable. Even on their laziest days, these are the practices that they know that, if they break the rule once, they may break it again, or that this might open the door for another person to break this rule.

Big-time sick today, and I'm trying to slip in a little work between sleeping spells, but Flash is killing me on my slow home PC. Here's a link to uninstall the Flash plug-in. Seems like Macromedia could provide an uninstall program or otherwise make this easier (argh!). I don't think most people would be brave enough to follow these instructions ... but maybe that's the point.