Barebones Unix for Using the Uniform Access Computers

George Dillon
University of Washington
Résumé :

Basic design and commands for using local and remote unix boxes on the University of Washington Uniform Access Accounts.

With JavaScript enhancements


Unix is vast: it has hundreds of commands (most of which you do not need to know), many nifty ways to customize its operation (which space does not allow us to more than hint at), and a great deal of online documentation (which you can read and grasp after you understand the program you're reading about). Unix is the ultimate programmer's operating system and, as they say, real programmers don't write documentation (just comments in the programs themselves)fn. Fortunately, there are now available a number of excellent reference books and guides to Unix fn. Most fortunately of all, if you know another command line operating system (say, MSDOS), you can get up and running in Unix with only a handful of commands and navigational advice. Section One gives the layout and commands for the computer where you have your user account; Section Two takes up accessing and manouvering on a remote computer in a network.2

1 the local box

1.1 design features

1.1.1 filenames

Today's Unices are very similar to MSDOS at the basic level, which is not surprising, considering that DOS borrowed a great deal from the Unix of the time (mid to late 1970s). Some differences really are small: the mark for "subdirectory of" in Unix is "/" (front slash); in MSDOS it slants the other way. One major difference hits you early and hard: in MSDOS, it doesn't matter whether you use upper or lower case letters or a mixture of them. So

copy \pix\picture.gif \gfx

is the same as

COPY \PIX\PICTURE.GIF \GFX

or

Copy \Mnt\Picture.gif |Gfx

but these are all different instructions in Unix--only the first would work, actually, since commands must be all lower case. Unix has virtually no canonical format for file names, so

picture.gif.blurry

or

nightmare.story

are legal file names, as is

nightmare_1st_draft

Just about any thing you can type from the keyboard is a valid file name:

you can forget about the MSDOS eight+three (maximum of eight characters plus three optional extension). You should not forget about it when you download into a MSDOS file system. Then the lovely, luxuriantly informative Unix file name will be mercilessly and mechanically hacked to the first eight before a dot and the first three after, so

nightmare.story --->nightmar.sto

This happens a lot when you download from the Net into a MSDOS FAT filesystem and that is why most programs let you re-title the file before copying it into your system. The VFAT system of Windows 95 allows long file names and so is less brutal in its chopping, but it is remains more restrictive than Unix in allowing only one dot separation per file name. Unix filesystems are like MSDOS FAT and unlike some others in disallowing spaces in the middle of file names. (If you want to give a title that makes sense as a phrase, you have to tie the words together with an underscore ("_") as in nightmare_1st_draft.

Unix does not give drive-name letters the tree-initiating status that they have in MSDOS. For example, one refers in MSDOS to the ``windows\system'' subdirectory as being under ``C'' and the file ``nightmar.sto'' being under ``A'':

C:\windows\system . . .          A:\nightmar.sto

If such MSDOS subdirectories and files are attached to a Unix system, they appear branching off of predetermined mount subdirectories of the main tree-root ``/'':

 /dos/windows/system ...         /mnt/nightmar.sto

where ``dos'' and ``mnt'' are the mount points. At the top of the Unix directory tree is no drive letter, just ``/'' (the root of the tree). So now you know why the dividers slant forward in an Internet address ( URL--Uniform Resource Locator): you are addressing a file in a Unix file system.

Special note on internet protocol (ip) addresses

IP addresses (e.g. www.w3.org) usually lead into Unix-style file systems, which are case-sensitive. So, even though the ip part is NOT case sensitive, the stuff following the root slash IS:

http://www.w3.org/

is the same as

http://WWW.W3.org/

but

http://www.w3.org/hypertext/ 

is different from

http://www.w3.org/Hypertext/ 
Extra special note for editing HTML on MSDOS

If you are editing an HTML file which you want to run on an MSDOS based serve r and you want to link to an image or other file by full path name, the address for it is not the expected:

HREF="file:C:\html\myfile.html"

or

SRC="C:\pix\me.gif"

but uses a triple front slash and a pipe:

HREF="file:///C|/html/myfile.html"

and

SRC="///C|/pix/me.gif"

So if you are trying to browse your work on a local MSDOS machine and you get broken images for your gifs and bad links, use the pipe!

1.1.2 Roots, Users, and Permissions

MSDOS was developed for individual computers with very limited resources: Unix was the system of choice for "big" computers with large resources shared by many users. These users were restricted in their ability to alter things all over the system; they were given different, limited privileges for handling files. That is, each Unix system has a "root" or superuser status defined along with multiple ("mere") users and a list of permissions to read, write and execute for each file. The root user can read and write any file and can change the permissions on any file; other users are more limited. Further, root and users can make files executable by giving a +x permission. More than this you do not need to know at the outset. For now the point to be borne in mind is that sometimes you cannot read a file you think you should be able to, or save or executeone, because the permissions of the file are not set +r, +w, or +x for you. Then you have to change the permissions of the file, or get the superuser to do it. These permissions are similar to MSDOS's file attributes (Read only, Archive, System, and Hidden). All Unix home directories have various housekeeping and configuration "dot" files (files whose names begin with a period) and these are not displayed (i.e., they are "hidden") with a simple list command (ls. There are options that will list everything, however: see the ls command 1.2.1).

So for example look at Figure 1.1, which is a captured screen of a typical unix subdirectory listing displayed in response to the command ls -l:

Anyone can read and copy or get (``download'') any of the files listed here. This subdirectory is /simtel/msdos/teaching and as you might guess from the file titles, contains various utility programs (grade books, quizzes, puzzles, seating charts) that teachers might find useful. (We have used one of the grade books found on this subdirectory.) The files are open to everyone to read or take (they are called "world-readable"), but they cannot be freely modified--"written" to the directory--hence the rows of "r's" (for read) with no "w's" with them in the right-hand columns; the superuser, however, has to be able to add and remove them to maintain the archive, so they have "w" permission along with "r" in the left column. None of these have "x's" in any column, since they are not executable files in their present form or purpose. This display was generated in response to the rather "verbose" command dir, which is really just an alias for the command ls -l (="list, long"). If you just gave the ls command, you would get a more succinct list of files without the permissions, dates of posting, person posting, and size. There will be more about reading and plundering other people's open directories in the section on ftp.

1.2 Commands

As noted earlier, Unix has hundreds of commands; it has hundreds of uses, too. The ones you need first to work on the Net are those for navigating, handling files, and exiting. These are the commands that drive you crazy until you get them in your fingers. We split these into navigating commands, file manipulation commands1.2.2 and exiting1.2.3 .

1.2.1 navigating

ls
This is your basic directory dump; it has several toggles or flags that give different lists.
ls -al
(``list all, long listing'') as we have seen generates the display with permissions, dates, owner, and so on. Note that it also gives the total number of bytes stored in the subdirectory--very useful for seeing how your space is being used. In Figure 1.1, for example, the fourth line ``Total'' is given in Kilobytes, so the ../teaching subdirectory has 5578 kbs of files in it, or 5.3 megabytes
ls -aF
puts an ``/'' after names that are directories, ``*'' after names that are executable files (have a +x permission), and ``@'' after names that are symbolic links to a file elsewhere.
The extra toggles obviously give you more information, but they may take three or four times as long as naked ls to display. These commands frequently produce several screensful of file names which scroll by faster than you can read. It is true that with Unix you can generally scroll back a few screensful by using the shift+PgUp command, but the list may even run beyond the limits of the scroll-back buffer (whatever it is set to). These long directory listings running by are most frustrating and vexing. You need to redirect the output to the pager, less or more, which will display the list one screenful at a time. (See below1.2.2)
cd
The command cd changes directory to that specified following the command (e.g.cd /simtel/msdos/teaching takes you to the subdirectory we were looking at above, at least on oak.oakland) You can move to the directory above you with cd ..(that's with a space before the dots). These commands are the same as those in MSDOS. However, plain cd takes you ``home'' to the subdirectory bearing your name (the one where you are when you log in). If you docd / the effect is the same as with MSDOS ``cd \'': it puts you at the top (``root''). [If you are the superuser (which you might well be on your own home or office system) then your ``home'' is the root, and plain cd has the same effect ascd /.]
pwd
With all this moving around, you may not be sure where you are in a tree; the command pwd (print working directory) displays your current directory.
find
You can search for a file with find; to be workable, it needs to be told what subdirector(ies) to search and how to search (e.g. by name, extension, etc.). So if we wanted to search the simtel subdirectory at oak.oakland for a file we had found a reference to called ``gradebok.zip'' we would type:
find /simtel/msdos -name gradebok.zip
and hope it would come back with something like
/simtel/msdos/teaching/gradebok.zip
tar
A file with a name ending in .tar is a tarred archive file, which means that it is a group of files (a mini-directory structure) which are travelling as a set. A tar file can be extracted with
tar xvf filename.tar
which will build the tree structure at the spot where the tar file is located. A file ending in .gz, .Z, or .tgz is compressed and can be unzipped using gzip, the GNU utility. The effect of unzipping and untarring is like that of pkunzipor unzip with the -d toggle; extensions such as .zip are almost certainly MSDOS files but can be unzipped under Unix withunzip which exists on Unix computers.

1.2.2 manipulating files

less (more)
You can browse (read) a text file with the commands more and usually less (``less is more'' the saying is, though it is better in some ways). To exit the more reader, you type Ctrl+C (control C--the basic ``abort'' command of Unix as well as MSDOS), but to exit less you type esc esc. Withless you can go up a screenful (or half a screenful, depending on the system setting) with u and down with either d or the spacebar. (less usually has many other options as well, but that's enough for starters).You can use more or less as a pager for scroll-happy commands like ls by piping the output of ls or dir to less. This is exactly how the screen listing in Figure 1.1 was obtained.
dir /simtel/msdos/teaching |less 
Sometimes this piping to less ormore will work for dir but not for ls -al. Try another one if the first you think of doesn't work.
rm
Unix uses rm to delete a file, not MSDOS "del". If uses cp to copy a file, not MSDOS "copy".
mv
Unix makes heavy use of mv "move" which you can use in the usual way to move a file ("copy-and-delete") but which is also used to change the name of a file ("rename") by "moving" it to a different name in the same spot:
mv gradebok.zip grdbook.zip
lpr/prt
If you are connected to a school (or office) network, there may be a printer you can send your documents to and have them printed (often at no cost to you). The exact command varies from place to place. While on a Uniform Access computer, you can print to printers in various places including ACC by giving the prt command, what printer's queue you want to sent it to, and the file name (as well as lots of other toggles). So
prt -queue xerox myfile.ps
Will send your file "myfile.ps" to the ACC for printing. Most printers will handle any old text file, a postscript file (myfile.ps) or a compiled TeX .dvi file. Something similar works within labs for local printers. For example, in the Odegaard Colab
prt -q ougl_uwired_hp myfile.ps
will do the trick.

1.2.3 exiting

Getting off line is not as easy sometimes as it seems it should be. You can escape from most processes and programs with the abort (Ctrl+c) and suspend (Ctrl+z) commands; similarly you can more properly exit them or quit them with (these are hard!) exit and quit or just q. But when you try to logout from your account (with logout, b'gorry), you may get a message ``There are processes active.'' This is an error message, folks, and the machine will not log you out. What you need to do is to kill the process or processes that you left in suspension sometime during the session. But how to know what these are, and how to kill them? The command ps (``process status'') will return a list of the processes currently active by name and with a process id number; you then can issue a kill command followed by the process number

In this end of a session, the first attempt to logout was thwarted by stopped processes, which ps determined to be two---the trn news reader and an attempt to read the directory at the sunsite ftp archive in North Carolina. These were killed, and then the logout attempt was successful.

That is a core of commands and moves given by every shell around for Unix. Now we turn to a core of useful programs that also are found at virtually every site.

1.3 simple editors and help programs

Just about anywhere you find Unix, you find these programs.

1.3.1 editors

vi
The small line editor vi is found on every Unix system and is a handy one to use to make small changes in files. The basic commands are quirky (compared to the increasingly standard issue word processor), but there are those who use it (or one of its off-shoots) to write substantial documents, even books. Such acts reflect a staggering ascetism (if not outright masochism). The basic commands of vi are nonetheless useful to enable you to make corrections and variations of files. vi is very simple: it requires a file name when invoked (that is, it has no directory menu or search procedures), it lets you make changes to that file, and to save it, either writing over the original file or as a new file.When vi comes up it is in the ``delete'' mode; pressing the letter x will delete the character upon which the cursor rests. You toggle to the "insert" mode by pressing the letter i and return to the delete mode with Esc. When you are ready to quit, you save from the deleting mode by typing ":wq '' --a colon, followed by w(rite)q(uit). If you just want to exit without saving, type ``q!'' after the colon. vi always saves to the subdirectory the file was/is on and saves without backup. If you want to save your revised file without writing over the original one (the ``save as'' scenario) (or, like a dummy, you have edited a read-only file) you can save the file under a new name with ``:w filename". The commands are strange and take a little getting used to, but vi is very small, quick, and found on every Unix computer. It is also the default editor for mail and news readers (for when you want to compose a response or new posting of your own) and the TeX typesetter as well. These few commands are worth knowing.
pico
Pico is the default editor for Pine, and so most UW students have used it, maybe without realizing it. It has menus and responds to keyboard insertion and deletion in the "normal" way without toggling between insert and delete modes as vi does. Like vi, it writes plain ascii text (the Save command is Ctrl-O) and is suitable for composing HTML on-line. It sometimes seems to break up words when scrolling, leaving spurious spaces, so if you find this a problem, you could move down to vi (or up to emacs, but that is beyond the basic level.)

1.3.2 help and info

Unix has a lot of on-line documentation that can remind you of the syntax of commands and give a clue as to why something is not working.

--help
A large number of Unix programs respond to the toggle --help (or -h) by giving one or two lines of their basic command syntax. This is always worth trying.
man
Man searches for and displays a manual page for most Unix commands, and often for programs also. Almost all programs are put up with a man page, which is usually stored with man pages from other programs in such subdirectories as /usr/man/man1 (and man2, man3, on to mann) and /usr/local/man. The command man searches a predetermined path through the directory tree looking for a page to format and display with the name you query. Thus to find the man page on the command prt you would type
man prt
and after a short while a screen of information on prt will come up giving the syntax of the command and a list of all the optional toggles and flags. Usually it goes to one of your pagers, either less or more, so you can scroll around in it. If you ever get to use Unix in a graphics mode, look for the program tkman. The bad news about man is that it goes nowhere if you don't have a MANPATH set for it to search. Even if you find a man file that you want to read in one of the normal places and try to use a text-file reader (like less) to read it, it will come up pestered with typesetting mark-up tags.
info
Another source of documentation is the "info" archive of files produced by the Free Software Foundation to document their programs (such as Emacs and the gcc compiler); they invite additions to this archive of hypertext documents, but such documentation generally exists on line only for the main FSF (aka GNU) programs.Like man, info needs to know how to find its files to browse, which are always on one or more . ./info subdirectories. If you just type info it will follow its own precoded INFOPATH information and you might get lucky. But if you can find the path to the subdirectory you want, you can tell it directly:
info --directory /public/lib/info
(or wherever) and it will read the ``top'' of tree of info files found there. If you forget (and you will forget), just remember info --help.

2 Networked machines

There are a number of different schemes or protocols which can be used to network computers together. Some, which we associate with Local Area Networks, mount some or all of the directories of one computer into the file system of another so it appears as a drive or subdirectory of the other one. (For Unix, this type of networking is done via a program known as the Network File System--NFS.) With this sort of mounting, the remote computer acts very much as though it were simply a part of your local one. Some of the Uniform Access computers are linked together so as to exhibit file structures branching from a single root. Mead and Saul, for example, share a common root with Weber and the anonymous ftp site. Others of the Uniform Access galaxy are not so connected and can only be reached from Saul etc. by remote login/telnet/ftp as if they were thousands of miles away.

The underlying mechanism for this sort of remote transfer is TCP/IP (Transportation Control Protocol/Internet Protocol, if you want to know). By means of telnet we can read directories and sometimes perform other limited operations on computers that we do not have user privileges on. (If we do have user privileges, then we can commence to move files around, rename or delete them and in general make ourselves right at home).

2.1 ip addresses

Every computer that communicates via TCP/IP has an IP address, which is a set of four three-place digit fields, the familiar 125.102.54.110 sort of thing. Since human memory works better with words than digits, most of these addresses are paired with spelled names such as goolagong.cs.oz. When you ftp or telnet to such an address, the message passes first through a computer that replaces the verbal address with the numerical one--a DNS, or Domain Nameserver, it is called. (If the DNServer is down, or incorrectly set up, you can send the numerical address if you know what it is).

2.2 ftp

TP stands for File Transfer Protocol, and is the basic means of up and down loading files to and from remote computers. There are a number of improved versions of ftp such as ncftp, wuftp, and fetch (for Macintosh). Mostly commonly we think of ftp as anonymous ftp--scanning directories and downloading files from remote computers which have been deliberately made available to anyone regardless of their name or address. When you ftp into a machine with anonymous ftp, you can just type "ftp" for your login name and password (or in a very few cases give your address as your password, as the site may instruct you).

You can also ftp using your user name and password to a machine on which you have an account. To up or down load from your account on a UA computer to another one via ftp, you can establish a link giving your login name and password. Then you can ls and cd to the subdirectory you want and get the files you want (if you are using an older ftp it would be a good idea to give a "bin" command first to tell it to send the file as a binary, not an ascii file). To upload to the account from the current directory of your local machine, use put plus the file name. To down load multiple files from the subdirectory, use mget and to upload, mput. Finally, to change your local directory so that arriving files will go where you want them to, or so that you can find the files you want to send, use lcd ("local change directory").

If your web browser supports ftp (as Netscape does, for example) you can go that route, but only for anonymous ftp. If you run into one of those sites which wants something besides "ftp, ftp" to log in, you are out of luck.

You cannot ftp to or from your account over a simple telephone connection, for in that case you have no local IP address. If you have a Slip, PPP, or other tricky connection (slirp, term, twinsock) you will have, or can fool the computer into treating you as if you have, an IP address.

That, for the time being, is enough bones.