Amiga UNIX - Is It for You?

Started by airship, August 24, 2007, 01:11 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

airship

These articles appeared in the October and November 1991 issues of INFO.

Taken from Daniel Barrett's site at: http://www.blazemonger.com/articles/unix1.html and http://www.blazemonger.com/articles/unix2.html

QuoteUNIX: Is It For You? Part I: For The User
Copyright 1991 Daniel J. Barrett. This article originally appeared in .INFO Magazine, October 1991. This article is freely distributable as long as it is not modified.

Commodore has released several Amiga computers that run an industry-standard, multitasking operating system called UNIX. What does UNIX have to offer the average Amiga owner, game player, power user, or programmer? How is UNIX different from the Amiga operating system (AmigaOS) that we get for free? Is UNIX "better"?

This is a series of two articles comparing and contrasting UNIX and AmigaOS. This month, we discuss these two operating systems from the point of view of an ordinary user. Part two will focus on topics for power users and programmers. These articles should serve as a quick introduction to the world of UNIX.
THE COMPONENTS OF UNIX
AmigaOS consists of two parts: a low-level program called Kickstart, plus a set of support programs and files found on the Workbench disk. UNIX also has this dual structure, but it is much larger. Its low-level "kernel" program could fit on 1-2 floppy disks, but the support programs and files can easily fill up 80 megabytes, so a hard disk is obviously needed!

So what do you get? HUNDREDS of programs: text editors, spelling checkers, document processing software, over a dozen compilers and interpreters, programming tools, programs for sorting and searching data, on-line documentation, networking software, electronic mail, window systems, games, tape backup programs, three or four user interfaces (shells), and day-to-day programs similar to your Amiga CLI commands. And if that's not enough, thousands of freely-distributable UNIX programs are available.
USER INTERFACES
On a standard Amiga, we can use graphical (Workbench) and command line (CLI) interfaces. UNIX has a command-line interface called the "shell", and many of today's UNIX workstations offer a window environment such as the "X" window system. Currently, there is no "standard" UNIX graphic interface, although "X" is probably the most popular.

UNIX GUI's tend to be more complicated and configurable than the Amiga Workbench. "X" allows a user to specify exactly what happens whenever the user presses any key or clicks the mouse anywhere on the screen. For example, you could easily design your own menu (both its look and its function) and cause it to pop up whenever you press the right mouse button or the F6 function key. This power comes with a price, though: "X" is a large and compute-intensive application, whereas Workbench is small and relatively speedy.

Now, let's compare and contrast the Amiga CLI and the UNIX shell. At first glance, they appear quite similar: they both have wildcards, script languages, command history, command-line editing, and so on. However, they have several important differences. The main one concerns the treatment of wildcard characters. Suppose you want to see your Amiga files whose names begin with 'A', so you type the CLI command

      list A#?

What happens now? In the Amiga CLI, wildcards are seen and interpreted by individual programs. This means that "list" itself must have the built-in ability to understand the "#?" characters; the CLI does not interpret them. In short, Amiga programs understand wildcards only if they are specifically written to do so.

In UNIX, wildcards are interpreted by the shell, not the programs. Here is a UNIX command like the AmigaOS command above:

      ls A*

The wildcard is interpreted by the shell before "ls" executes, becoming (let's say)

      ls Aardvark Amiga Anniversary.txt

Finally, "ls" executes as if you had typed the 3 arguments yourself. Thanks to the shell, every UNIX program automatically "understands" wildcards.

Here are some other shell/CLI differences:
# The user can easily send the output of one program as input to a second program, simply by typing a vertical bar ('|') between the two programs on the command line. For example, to view your file names one page at a time, you might send a directory listing as the input to the "more" program, like this:

         ls | more

These "pipelines" are also possible in the CLI, but the syntax is not as convenient.
# UNIX programs may be paused, restarted, pushed into the background, or brought into the foreground anytime. This is actually a feature of the operating system and not the shell, but it is the shell that gives the user access to this "job control" ability.
# It is not permissible to type CLI script commands directly at the command line. Have you every tried typing an IF statement directly at the CLI prompt? You get an error message:

         1> if EXISTS MyFile
         IF only valid within command files

However, the UNIX shell allows you to type script commands directly at the command line. In general, the shell's script language is more powerful and general than the CLI's. (Note that AmigaOS 2.0 makes vast improvements to the CLI, though.)
# Suppose you execute a CLI script that changes its directory using the "cd" command. When the script is finished, your original CLI will have "moved" to that new directory. This can surprise you if you didn't know that the script contained a "cd" command.

Under UNIX, every shell script executes in its own private "environment". Therefore, your scripts are free to "cd" all over the place and still have no effect on your original shell when they terminate.
There are several "shell" programs in the Amiga public domain that give the Amiga user many of the UNIX capabilities mentioned above. Some popular ones include Matt Dillon's "csh" and Steve Koren's "sksh".
FILE PROTECTION
Have you ever let a friend use your Amiga, only to find that he/she accidentally modified some of your files? This unfortunate experience is possible because AmigaOS does not prevent one user from affecting another user's files. In fact, AmigaOS does not have any concept of file "ownership" at all -- any file is accessible to any user.

On the other hand, UNIX was built to be a multi-user environment. Every file has an owner, and only the owner can modify it. This protection is enforced by UNIX, and there is no way around it (unless there is a bug in the operating system!). Of course, the owner can choose to share files with other users on the machine.

How do you identify yourself as the owner of your files? Simple: when you first sit down to use the computer, you type in your name (really, a designated "login name") and a secret password you have chosen previously. If you type the password correctly, then UNIX treats you as that user until you end the computing session ("log out").

There is one special user on every UNIX machine called the Superuser, or "root". The Superuser may access every file on the machine without restriction. Important system files are typically owned by the Superuser, so they cannot accidentally be deleted by casual users. Have you ever deleted your only copy of Deluxe Paint by mistake? UNIX guards against this error.

As you might imagine, the Superuser's password is almost always a closely-guarded secret. If you are the owner and only user of a UNIX Amiga, however, it is likely that you will be your machine's Superuser and have access to all files. Even so, it is wise for you to create and use a separate, "ordinary" login name. When you are the Superuser, you lose the extra protection UNIX gives you, and it is once again possible to delete system files accidentally.
MULTI-USER ENVIRONMENT
A major feature of UNIX, and many other mainframe operating systems, is that many users can use the computer at the same time. Each user requires a separate terminal which can be attached to the serial ports of a UNIX Amiga.

When a UNIX user "logs in", a private file similar to the Amiga's S:Startup-Sequence is executed. This allows each user to configure his/her UNIX environment differently from every other user's, even on the same machine. For example, one user's startup file might print a friendly HELLO message, while another's might automatically open four shell windows.

Having multiple users on the same machine opens the door for on-line communication. Electronic mail allows files and letters to be sent between users, and the programs "write" and "talk" allow users to carry on interactive conversations.
DO I NEED UNIX?
Is UNIX "better" than AmigaOS for the average user? The answer depends on your needs and your personality. If you use your Amiga primarily for playing games, then UNIX has little or nothing new to offer you. UNIX games, while fun, do not begin to approach the level of graphics and fast action found in a typical Amiga game.

If you use your Amiga for its strengths in graphics and video, then there probably isn't much reason to move to UNIX right now. Similarly, if you primarily use "canned" Amiga application programs, and you are happy with them, then you may not need UNIX at the moment.

If you are a programmer, however, you should give UNIX VERY serious consideration. I'll talk more about this next time.
SUGGESTED READING
There are dozens of UNIX books on the market, and it's difficult to know which ones to read. My general rule of thumb for new users is to buy a book written fewer than 5 years ago. A number of things about UNIX have changed during that time, and these differences can be very confusing for beginners.

Here are some of my favorite UNIX books. For a very quick introduction, try "Learning The UNIX Operating System" by Grace Todino and John Strang (O'Reilly & Associates, Inc., 1987). For a solid tutorial and reference, try "A Practical Guide to the UNIX System" by Mark G. Sobell (Benjamin-Cummings, 1989). Once you have been exposed to UNIX, check out "Life With UNIX" by Don Libes and Sandy Ressler (Prentice-Hall, 1989). Interesting, well-written and funny, this book traces the history of UNIX and offers a lot of good (and hard-to-get) advice.
About The Author
Daniel Barrett is a long-time Amiga user and UNIX systems administrator. You are welcome to contact him by e-mail:

   INTERNET:   barrett@cs.umass.edu
   COMPUSERVE:   >internet:barrett@cs.umass.edu

- barrett@cs.umass.edu
-------------------------------------------------------------------------------------------------------------------------
QuoteUNIX: Is It For You? Part II: For The Programmer
Copyright 1991 Daniel J. Barrett. This article originally appeared in .INFO Magazine, November 1991. This article is freely distributable as long as it is not modified.

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.
BEING A UNIX POWER USER
UNIX has lots of opportunities for users who like to get the most out of their computers. Most UNIX programs, including the shell user interface, are highly configurable. Some of them even let you define the behavior of every single keystroke and mouse-click (or you can accept the defaults).

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.
PROGRAM DEVELOPMENT
The most popular UNIX programming language is C. In fact, UNIX itself is written almost entirely in C. (Some assembly required.) Many people consider UNIX to be one of the most versatile and productive programming environments available, for several reasons. First, it has many programmer's tools. Second, it does not allow individual programs to crash the machine. Third, the source code for many UNIX utilities is generally available.

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.)
VIRTUALLY SPEAKING...
UNIX has three important features for programmers that AmigaOS does not: memory protection, virtual memory, and resource tracking. These features come at a price, however: UNIX has much more overhead than does the Amiga kernel, and therefore runs more slowly.

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.
SYSTEMS PROGRAMMING
Like AmigaOS, UNIX provides programmers with hundreds of system functions and structures for manipulating UNIX-specific information. For example, if you want to learn the username of the owner of a file, you can call stat() to find the user ID number of the owner, pass that value to getpwuid() to look up the user's name, and then print the answer.

/* 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.
SYSTEMS ADMINISTRATION
Remember when you first started using an Amiga? Although you could do some fun things right away, it probably took you a while to set up the Amiga just the way you like it: modifying the Startup-Sequence and the Mountlist files, setting up your printer with Preferences, changing the screen colors and fonts, installing commercial and public domain software packages, organizing files on the hard drive, making a search path, and so on. A similar process must be done on almost any other computer before you feel completely comfortable using it.

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.
DO I NEED UNIX?
Serious programmers should definitely check out UNIX. With its large selection of languages, tools, and shells, UNIX can be a great development environment. Amiga power users may also find UNIX to be useful and fun, especially if they like to explore and tailor the computer environment to its fullest.
SUGGESTED READING
Assuming that you already know C, here are some good UNIX programming books. "Using C On The UNIX System" by David A. Curry (O'Reilly & Associates, Inc., 1989) is an excellent guide containing many example programs. This book is one in a series of "Nutshell Handbooks" that are enjoyed and recommended by many UNIX programmers. After this introduction, check out "Advanced UNIX Programming" by Marc J. Rochkind (Prentice-Hall, 1985) for more in-depth information. Low-level operating system information may be found in "The Design Of The UNIX Operating System" by Maurice Bach (Prentice-Hall, 1986). To learn more about systems administration, see "UNIX System Administration" by David Fiedler and Bruce Hunter (Hayden Book Company, 1986).
About The Author
Daniel Barrett is a long-time Amiga user and UNIX systems administrator. You are welcome to contact him by e-mail:

   INTERNET:   barrett@cs.umass.edu
   COMPUSERVE:   >internet:barrett@cs.umass.edu
Serving up content-free posts on the Interwebs since 1983.
History of INFO Magazine