Last time, we discussed some differences between the UNIX and Amiga operating systems that affect all users. We now discuss issues relevant to programmers and power-users: sophisticated UNIX use, programming, and systems administration.
Once you have mastered various UNIX programs, the power doesn't stop there. The UNIX shell lets you build sophisticated "pipelines" that send data from one program into another. As an example, let's find out the most common first name of all the users on a UNIX machine. In a single command, you can get a list of all user names from the file /etc/passwd, extract the first names, sort them, count adjacent identical names, sort the resulting numbers, and then find the largest:
Command: cut -d: -f5 /etc/passwd \ | cut -d' ' -f1 \ | sort \ | uniq -c \ | sort -nr \ | head -1 Response: 12 John(The forward slashes '\' mean "continued on the next line"; I used them to emphasize the different components of the command.) The command probably looks cryptic to you now, but this kind of operation quickly becomes second-nature as you use UNIX. Because all of the above programs (cut, sort, uniq, head) come standard with UNIX, you can expect the command to work on almost anybody's UNIX machine.
How does one become a UNIX power user? Mainly by exploring the system directories and becoming familiar with many programs. In my experience, if you spend time learning a new UNIX utility, you gain the time back (and more) in your first week of use.
All commercial Amiga C compilers come with a utility called "make" which helps the programmer keep track of large programs. Would you like to guess where "make" originated? It was written for UNIX by Stu Feldman of Bell Laboratories. UNIX provides a veritable arsenal of programmer's tools. There's "lex" and "yacc" to help you write complicated input routines, "sccs" and "rcs" for maintaining multiple versions of programs, "lint" to spot-check your C code for common errors, "ctags" for jumping quickly between functions in your text editor, "ctrace" for tracing program execution, "prof" for identifying the slowest parts of your code, various debuggers, and much more. Combine these tools with a powerful shell and a multitasking operating system, and you have one SERIOUS programming environment. (Some of these tools have been ported to the Amiga and are available on Fish Disks.)
Memory protection prevents one program from affecting the memory owned by another program. On the Amiga, this is not true: programs are free to scribble all over each other's memory. This is why individual programs are capable of crashing the computer (the famous guru meditation). When a UNIX program crashes, it doesn't bring down the whole machine; instead, UNIX takes a "photograph" of the program's memory, stores it in a file, and then terminates the program. This file, called a "core dump", may now be examined with a debugger to determine the cause of the crash.
Virtual memory allows a program to access more RAM than actually exists on the machine. This is done by causing a section of your hard disk act as if it were RAM. The operating system moves running programs between the hard disk and true RAM as needed.
Resource tracking means that the programmer doesn't have to free all the resources that she allocates. When a program exits, all of its allocated memory, files, devices, and so on, are deallocated automatically. This means that the operating system can kill a running program and be sure that everything gets cleaned up properly. On the Amiga, this is not the case: programs are required to keep track of their own allocated resources and explicitly deallocate them. There is no completely reliable way to make the operating system kill a running program, although some clever programs such as "xoper" make a good attempt.
According to rumors floating around the Amiga community, the Amiga operating system may one day incorporate memory protection, virtual memory, and/or resource tracking. However, the addition of some of these features would cause serious incompatibility with many existing programs, and some people do not want to sacrifice the CPU cycles that these features will require. Let's hope that Commodore comes up with a solution that makes most users and developers happy.
/* Given a filename as argv[1], print the name of the owner. */ #include < stdio.h> #include < sys/types.h> #include < sys/stat.h> #include < pwd.h> main(int argc, char *argv[]) { struct stat info; /* A buffer for file information. */ struct passwd *pw; /* Pointer to to user information. */ if (argc != 2) fprintf(stderr, "Usage: %s filename\n", argv[0]); else if (stat(argv[1], &info) < 0) fprintf(stderr, "File %s does not exist.\n", argv[1]); else if ((pw = getpwuid(info.st_uid)) == NULL) fprintf(stderr, "I can't find the owner's name!\n"); else printf("The owner of file %s is named %s.\n", argv[1], pw->pw_name); }A major programming advantage of UNIX is that the operating system itself may be modified conveniently: some or all of its source code comes supplied with the UNIX distribution. Recompiling the kernel (the low-level part of UNIX) requires just a few commands. The catch is that the kernel source code itself can be difficult to understand.
Under UNIX, this process of "systems administration" is much more complex than under the Amiga operating system, for several reasons. First of all, there is no consistent method for tailoring a UNIX machine. For example, printer setup is done totally differently from network management or electronic mail configuration. There's no equivalent of Preferences on UNIX. (Some companies have tried to make such programs, like IBM's "smit" program for AIX UNIX, but these have interestingly enough been accused of being "un-UNIX-like" by members of the UNIX community.)
What is the reason for this inconsistency? Realize that UNIX was written by hundreds of different people over a 20-year period. Although many of the individual programs were carefully crafted in advance, the overall framework was not. UNIX was originally written by programmers and for programmers.
Another reason that UNIX administration is more difficult than the Amiga's is that there simply are more things to administrate! You have multiple printers being used by many machines simultaneously, network connection and data routing, electronic mail, automatic lookup of other computer addresses ("name service"), adding and removing users, automatic startup of programs at regular intervals, system accounting and usage statistics, security tools, and more. And don't forget that these services may be used by many users at once, adding to the complication.
Don't let this difficultly discourage you from using UNIX! If you are a reasonably intelligent person with programming experience who likes to learn about computers, then UNIX systems administration is within your abilities. If you encounter problems that you do not know how to solve, don't panic. UNIX has been around long enough that many problems have already been solved by someone else. If you have access to USENET or other electronic news services, you will find thousands of people willing to help you.
INTERNET: barrett@cs.umass.edu COMPUSERVE: >internet:barrett@cs.umass.edu
- barrett@cs.umass.edu