The Guide

Copyright (C) 1993 Portland State University

This is Edition 0.1 of The Guide,
last updated 7 September 1993 .
Printed 2 September 1994.

Published by Portland State University
P.O. Box 751, CMPS
Portland, OR 97207

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation.

Preface

This document was adapted from File 901, version 2.0, from the Computer Science Department at OSU. It was originally written by Jon Krueger (University of Rochester) and John Sechrest (OSU).

Contributors to version 1 at OSU were: Joel Corcoran, Edward A. Dains, Chris Hansen, Bryce Jasmer, Cory Jones, Marilyn Jordan, Lothar Kaul, Saeed Sedatian, Dex Smith, Scott Starr, Doug Strauss, Terralyn Udell and Don Willits.

Contributors to version 2 at OSU were: Marcos Barajas, Dan Nixon, Anthony Coughran, Steve Fulling, Dana Jacobsen, Cory Jones, Shahid Khan, Rajeev Pandey, Sheryl Parker, Erik Peteresen, Jason Robbins, Rebecca Ryden, AJ Schricker, John Sechrest, Satish Srinivas and Ricardo Uribe.

With John Sechrest's kind permission, The Portland State University Computer Science Systems Group (Sysgroup) began work on their own version. Initially this was done by converting the document to Texinfo and then omitting or altering local (OSU-specific) information.

The primary work at PSU was done by Lynnette Ahmed, Mihail Blaj, George A. Christian, Roger Conley, Anthony Fiarito, Trent A. Fisher, John Jendro, Laurentiu Popescu and Darrell K. Root.

Some sections are edited versions of documents available on the Internet. They are section News Etiquette, which is adapted from A Primer on How to Work With the Usenet Community, by Chuq Von Rospach; and section nn, which is adapted from an article by Rohit Gupta (rohit@uiuc.edu), University of Illinois at Urbana-Champaign, Computing Services Office.

Introduction

This manual was written to help acquaint you with the UNIX computer systems available at PSU. It is intended to be an introduction--not a complete guide. If you wish more information about UNIX systems in general, you should read one or more of the books listed in section Books.

This manual is available for checkout at the Reserve Library under the title The Guide.

NOTE: This is still an early version of this document. Please report any factual, typographical or formatting errors to the-guide@cs.pdx.edu.

How to get to a UNIX account

This section is a copy of the instructions included with the account application form (The Form).

Getting an account on a Computer Science UNIX machine is a two step process: you must fill out an account application, and then run the addme program. If either step is not completed, then you will not receive your account. Once you have finished both steps, you should be able to use your account within one business day.

Step One: The Account Application

Account application forms can be obtained from the CS Main office in PCAT 120. You must read this form entirely, and determine what type of account you are eligible for.

If your account just needs to be renewed, just fill out and sign the form and turn it in. Otherwise, have this form with you for the next step.

Step Two: The Addme program

ADDME is PSU's automated account request system. The easiest way to run addme is to use an X Windows terminal in the CS Lab (MSB 120). Sit down at a terminal, and login as `addme'.

If you are dialing in, press ENTER until you see the prompt `malach>'. Then, type addme twice (once to reach the right machine and the second time to begin the addme program).

Users who wish to telnet in should telnet to addme.cs.pdx.edu [131.252.20.183] At the `login:' prompt, type addme.

Simply press return if it asks you for a password. It will then ask you some questions about yourself including asking you to create a password which you will need to remember in order to log in to your account.

Do not choose a password that appears in the dictionary! Make sure your password is difficult to guess. It should have some digits and punctuation in it. It should be at least six characters long, and it shouldn't be anything like your login name or telephone number. addme should make sure that you don't choose such a password.

As you give the information to addme you should fill out the form. When you are done with both, turn the form in to the CS Office. You should have your account by the end of the next day.

Go to the Tutors Room in Mill Street Building if you need help with either of these steps. See section Getting Help, for more info.

Acceptable Use Policy

The Acceptable Use Policy is the primary policy statement for the CS Systems. Some important clauses from this document are on the account form that you fill out and sign in order to receive a UNIX account. Other policies are laid down from time to time in order to give more detail, or elaborate on system specifics. However, this policy has precedence. These other policies can be found in `/folklore' on most CS Systems.

Definitions

The CS Systems consist of all computer systems owned by, or on loan to, the CS Department.

Sysgroup is the body responsible for maintenance of the CS Systems. The CS Systems Manager is in charge of Sysgroup and, ultimately, responsible for their actions. For further information see section `Introduction' in The Sysgroup Handbook, and see section `Systems Manager' in The Sysgroup Handbook.

Who can get access to CS Systems

The account application form (The Form) specifies the exact policies for who can get accounts and how to do so. See section How to get to a UNIX account for more info.

The general policy is that CS faculty, staff and students (graduate and undergraduate), can easily get accounts. Faculty and staff in other departments may be given courtesy accounts. All others must get special approval from the Department Head.

Users Rights and Responsibilities

Operating Guidelines for the CS Systems

Sysgroup, in general, has the right to do whatever is necessary to carry out its responsibility to keep the computing resources operating and available.

Proper Use of the CS Systems

The CS Systems are provided for use by faculty, staff and students in support of programs of the CS department. All faculty, staff and students (as well as guest users) are responsible for seeing that these computing facilities are used in an effective, efficient, ethical and lawful manner.

The following list is not exhaustive.

Software Copyrights and Licenses

The software used on the CS Systems is operated under license agreements with AT&T, Sun Microsystems, The University of California at Berkeley and others.

Penalties for infractions

Minor infractions of this policy, when likely accidental in nature, are typically handled internally, in an informal manner. More serious infractions are handled via formal procedure. The CS Systems Committee determines the penalty or rules on whether the case should be referred to another authority.

In general, Sysgroup's first responsibility is to stop the violation (by disabling the user's account pending in-person conference) and then to prevent the violation from happening in the future (by issuing formal warnings, punitive measures, etc.)

Etiquette

Just like in many public establishments, there is a certain level of etiquette that we, as the public, are expected to follow. It is wise to understand what is and isn't acceptable. Failure to behave in a reasonable fashion could result in the loss of computer privileges.

Conventions Used

The conventions in this manual are identical to any other manual written using the Texinfo system:

Getting Help

This chapter explains several ways to get help. When you need help, you should go through the following steps in this order:

  1. Check the on-line documentation. Use the man, info / xinfo, and gopher commands.
  2. Bulletin boards. The newsgroups `psu.systems, psu.dialups, psu.TeX' (and others) may have answers.
  3. Read the manuals. Manuals are available in the CS lab and in the CS Systems Office.
  4. Ask the Tutors.
  5. Ask your TA or instructor about class and system information.
  6. Ask Sysgroup.

On-line Help

Several ways to get help are available while you are logged in to a UNIX system. Most of these require typing one of the following commands:

man
info or xinfo
gopher
rn psu.systems

man and info are used to get on-the-spot help when you don't know what to do or you want more information. section Man Command and section Info Command explains them. Gopher is another way to get more information and is described in section Gopher Command. The last one, rn psu.systems, is used to look at files of current information about the UNIX systems. Section section News explains how to use it.

Man Command

How to use Man

The man command prints pages of the UNIX Programmers Manual on the screen. Each page, called "a man page," describes one command. To use the man command, type the following:

man command

The man command responds by printing on the screen the man page for the command you typed in place of command. For example, if you wished to learn more about the man command, you could try:

man man

Once you have a man page on your screen, you'll want to know the information listed below.

If you don't know the exact name of the UNIX command you're looking for, you can use: man -k something man -k responds by printing on the screen a list of all the commands it finds that are similar to the word you typed in place of something or that contain that word in the description of the command. You can then use the man command to get information about the command you're interested in.

For example, here are the results of using man -k compiler to find compiler man pages.

cccp, cpp (1)        - The GNU C-Compatible Compiler Preprocessor.
g++ (1)              - GNU project C++ Compiler (v2 preliminary)
gcc, g++ (1)         - GNU project C and C++ Compiler (v2 preliminary)
cc (1v)              - C compiler
error (1)            - categorize compiler error messages, insert at
                       responsible source file lines
rpcgen (1)           - RPC protocol compiler
tic (8v)             - terminfo compiler
yacc (1)             - yet another compiler-compiler
zic (8)              - time zone compiler
bdftosnf (1)         - BDF to SNF font compiler for X11
cfc (8)              - Sendmail cf file compiler
ease (8)             - precompiler for sendmail configuration files
f77 (1)              - Sun FORTRAN compiler
f90 (1)              - Fortran 90 compiler
fp (1)               - Functional Programming language compiler/interpreter
fpc (1)              - fp to C compiler
orc (1)              - The Oregon C++ compiler 
pc (1)               - Pascal compiler
sicstus2.1 (1)       - SICS Prolog compiler/interpreter
sml, smld, smlc (1)  - Standard ML compiler

Then you can look at the man page for the C compiler, called cc, by typing: man cc

This command should come up with a page with the following sections:

NAME
command---brief description of what it does

SYNOPSIS
command op files: what the command has to offer and how it is invoked/used.

DESCRIPTION
a more in-depth explanation of what the command has to offer as well as to give examples of how to use the command. In this section you will also get the explanation of what options the command has and how to properly use them.

FILES
this is a list of the files which the command utilizes to perform correctly.

SEE ALSO
these are references to other commands that can give related information on the topic you are referencing.

There are other sections that are sometimes used: WARNINGS, BUGS, and others.

Man Pages Organization

On-line man pages are organized into eight specific sections based on the actual commands' purpose. Some systems organize the sections slightly differently. The original eight sections are:

  1. Commands
  2. System Calls
  3. Library Functions
  4. Special Files, Device Info
  5. File Formats and Conventions
  6. Games
  7. Macro Packages and Language Conventions
  8. Maintenance Commands and Procedures

In addition there is a separate hierarchy for each type of software, one for standard UNIX utilities, one for local commands, one for GNU utilities, etc.

The man command will always try to show you the manual entry from the correct hierarchy. If you want to see all available manual pages with a given name use the `-A' argument.

Info Command

The info command is part of the Texinfo documentation system, which is the documentation system used by the GNU Project. It uses a single source file to produce both on-line help (and other information) and a printed manual. This means that instead of writing two different documents, one providing on-line information and the other for a printed manual, you need write only one complete document.

Most Texinfo documents are intended to be both a reference manual (like the man command in UNIX) and a tutorial. The on-line version of the manual is referred to as an info file, there are several programs available to read them. Currently, the only local machine with up-to-date info files is `rigel'.

There are several commands that allow you to read info-files:

With all of these info readers, typing ? will give a listing of available commands. The commands are very similar among all three of these. Typing h will bring up a simple tutorial to show you how to use the info readers.

The entire Info system is organized in an hierarchal fashion, with information at each node. At each level there is a menu of the sub-topics available. At the top level is a listing of the documents available, at the next level down you can select chapters, etc. You can select a menu entry with the m command followed by the name of the node you wish to visit.

The info system also allows you to follow cross references. To do this, use the f command followed by the name of cross reference node.

In either of these cases, you do not need to type a complete nodename; if you type a few letters and then a space or tab, info will will try to fill in the rest of the nodename. If you ask for further completion without typing any more characters you'll be given a list of possibilities; you can also get the list with ?. If you type a few characters and then hit return info will try to do a completion, and if it is ambiguous use the first possibility.

Gopher Command

The gopher program is used to talk to gopher servers.(1)

The Internet Gopher is a distributed document delivery service. It allows a neophyte user to access various types of data residing on multiple hosts in a seamless fashion. This is accomplished by presenting the user a hierarchical arrangement of documents and by using a client-server communications model. The Internet Gopher Server accepts simple queries, and responds by sending the client a document.

Internal Help

Most UNIX interactive utilities have some sort of help function builtin. For most commands the ? key will give you a help screen. Some commands may also use h. There are still other possibilities, but you should be informed of them when the program starts

Help Through Newsgroups

Another way to get answers is to read the news groups `psu.msgs', `psu.systems' and `psu.general'. The CS department systems staff uses the newsgroup for systems information, and answers to common questions. In particular, important systems announcements are posted to `psu.msgs'.

To read these newsgroups use either the rn or nn commands. In the case of `psu.msgs' the same information can accessed via the msgs command. See section News, for more information.

Manuals and Books

Everything you try to do (almost) on these systems is described in a manual somewhere. Relevant manuals are referred to by name throughout this manual, usually at the beginning of the chapter that describes that topic. Some of these manuals can be purchased at Clean Copy or Copyman, and many are available for viewing in the CS Lab (MSB Rm 120).

Publications you may find helpful are:

UNIX BSD Quick Reference Guide

The UNIX BSD Quick Reference Guide, sold at the PSU Book Store, is a good quick-reference guide to UNIX commands. It gives syntax and brief descriptions of commands similar to those provided in section Basic UNIX Commands.

UNIX Programmers Manual

The definitive published document about UNIX is the UNIX Programmer's Manual. System V, HP-UX, and BSD UNIX have slightly different versions of it.

Volume 1 of the UNIX Programmers Manual consists mostly of documentation written for programmers. It documents mainly software in little space.

Most of Volume 1 of the UNIX Programmers Manual is kept on-line. section Man Command explains how to utilize it.

Books

Recently, a number of paperback books about UNIX have come out. These books can give you a broader perspective on UNIX than the manuals provide.

In addition, there is a series of books called the Nutshell Handbooks published by O'Reilly. Titles in this series include:

O'Reilly also publishes a series of books on the X Window System (see section X Environment, for more info.)

You can purchase most of these at the Powell's Technical Bookstore, 503-228-3906, or check with O'REILLY and ASSOCIATES, INC., 632 Petaluma Avenue, Sebastopol, CA 95472 or mail nuts@ora.com or phone 1-800-338-6887(NUTS).

Tutors and Sysgroup

In a highly networked group of computers such as the one that the Computer Science Department runs, troubleshooting users' problems can be a complex task. This section is intended to help users report problems to the appropriate people. It tells them what information to supply about their problem, and what they should expect.

It is vitally important that these guidelines be followed. If they are not, your problem may not get solved or you may take time away from Sysgroup members (which will prevent other systems work from being done).

The CS Tutoring Staff should be the first place to report problems or ask questions. If they cannot resolve the problem, they will refer you to someone who can (or they will do it themselves).

Before You Go

If you have a specific problem with UNIX and you wish to see a tutor, be sure you have the following before you see him or her:

Tutors

Tutors are available to help you. They are there to help you find the resources you need to do your work. They are not available to do your homework for you or as a substitute for the manual. They are there to provide as much direction as possible and to help you over places where you might have become stuck. It will help you (and the tutor) if you come prepared: see section Before You Go, for more information.

The student tutors can be found in the Tutor Office in the CS Lab (MSB Rm 120). During school sessions, they are available whenever the lab is open. (A full list of hours is posted by the door.) If the student tutors are unable to answer your question, they will refer you to someone who can.

They can also be contacted via telephone at 725-4023.

If you don't need an immediate answer, or if the lab is closed, you can send email to `tutors' with a detailed description of your question or problem.

Sysgroup

If you are able to send E-Mail, send it to `sysgroup'. This mail will go to the entire Systems Staff and to the Tutoring Staff. If you only want to report it to the Tutors, send mail to `tutors'. E-Mail sent anywhere else may not get answered at all, as there are people and programs monitoring both `tutors' and `sysgroup' to make sure that mail is responded to in a timely manner.

All mail to or from Sysgroup is now monitored by a program called GIPR. There is little the user should need to know about this, except that its role is to keep track of what is being done within Sysgroup and to make sure that deadlines are met, messages get responded to, and that no messages get "lost". When you get a response from a Sysgroup member, there may be header elements which indicate the priority for your problem and the estimated date of completion: `Priority:' and `Estimate:', respectively. Also, you should use the reply function of your mailer when responding to messages from Sysgroup members; this way GIPR can automatically corelate your message to an existing task and keep the statistics accurate. More information on GIPR is available in the section `Task System' in Sysgroup Handbook.

If you have a problem which needs attention immediately, put the keyword `[URGENT]' on the subject line of your message. However, this can result in someone getting paged; therefore, please read the warning below about the pager before doing this. Conversely, if your message does not warrant any action on Sysgroup's part (i.e. announcements), put the keyword `[I]' on the subject line.

You can also report problems via the telephone, however this is the least desired method for reporting problems, since it can be difficult to communicate the details of the problem (i.e. complex error messages). However, due to the large number of evening and off-campus classes, sometimes this may be your only choice.

The following numbers should be tried in the order given:

725-4101
Systems Office (Student workers)
725-4235
Systems Manager
725-5886
Systems Programmer
299-9490
Systems Pager

WARNING: the last number should only be used in dire emergencies. If you do use it, make sure that you leave a phone number where you can be reached. If you don't, odds of anything being done are very low.

Accessing the systems

Introduction

This chapter explains how and where you can access your UNIX account. You need to have some sort of terminal that connects you to your UNIX machine. Most personal computers like Mac's and PC's can run a program that will emulate such a terminal. How to run and use these programs is described in the section Logging on from the Computer labs on campus. The section Basics of logging in and out describes how to log in and out of your account once you have connected to the machine.

Basics of logging in and out

Once you have connected to the UNIX machine, you will see a prompt similar to:

`login:'

You should now type your login name. After you've typed that, you will be prompted for your password. Note that your password will not appear on the screen while you type it (this is for security purposes). If you have typed everything correctly, you have now successfully logged into the machine. Most machines will next display a message. If you are logging in from a non-X terminal, it will then ask you for the type of terminal you are using, like this:

`TERM = (something) '

You should now enter the type of terminal you are using or emulating. If you are using a Mac or IBM it will most likely be VT100. If you are using an X-terminal, the terminal type will be set automatically to xterm. Often times the computer will already know what term type you are using and display it in the parentheses above instead of the word "something". If this is the case, then you need only to press return. Once you have done this you should see a system prompt with the name of the machine you are using, such as this:

`sirius%'

When you see this prompt, you are ready to begin using your account.

After you have finished using your UNIX account, you need to log out. If you are at an X-terminal, move the mouse cursor over the Logout button window in the lower right corner of the screen and click the left mouse button. You can also exit you session by choosing the EXIT, option from the utility menu. To open you utility menu, just press the left mouse button on the root window (root window is the background window).

If you are at another type of terminal, you type

logout

at the system prompt. You can also type Ctrl-D to logout. If you see the line

`There are stopped jobs.'

you will need to type logout again, which will kill all the stopped jobs. Jobs are typically stopped by typing Ctrl-Z. To find out more about Jobs, See section Controlling Jobs.

Logging on from the Computer labs on campus

The Computer Science Lab is located in Room 120 of the Mill Street Building, which is located at 528 S.W. Mill Street. It provides access for students to their UNIX accounts on the computer science machines. Tutors are available to answer questions and help with problems. To find out the hours that the lab is open, call the tutors at 725-4023.

Computer Science Lab

The Computer Science lab has more than 20 X-terminals. You can log on to your UNIX account using any of these. There is also an IBM PC for uploading and downloading files to diskettes.

Dialing In from Home

There are many public domain packages which will allow you to utilize your Macintosh or PC as a remote terminal via modem and phone line from your home.

To connect via modem, you need to make sure you have the following settings made:

baud rate:
9600, 2400, 1200 or 300 (as fast as your modem can go)
parity:
none
data bits:
8
stop bits:
1

Also, make a note of the type of terminal emulation your program is set for so when asked what term type you are using, you will know what to enter.

The phone number that you can call to connect to the PSU Cisco Terminal Server, hostname malach, is 725-3144. These numbers automatically switch between the other full time modems available.

Once connected, you may need to press "return" a few times to get the `malach>' prompt. Once you see this prompt you can type machinename to connect to your machine. For example, the following would connect you to the machine sirius:

`malach> sirius.cs.pdx.edu'

If you have some problems while dialing in, try the following steps:

If you have problems with dialing in you should mail a trouble report to:

`psu.dialups'

or call 725-4023 and report the problem to the Computer Science Department tutors. The next section, Reporting Problems, will explain what information to give when reporting the trouble.

Reporting Problems

To report any trouble you may be experiencing, your report needs to have some specific information to aid in locating the offending hardware or software. Each communication system has several possible points of failure. Possible failure points are: phone line, answering modem, serial cables from modem to communications system, malach, or the host to which you are connected. If you are able to get as far as the malach prompt, type who at that prompt to find out which malach port you are connecting to and include that information when you report your problems. Also report which phone number you dialed. Give a description of what happened. Mail reports of problems to psu.dialups, or post an message to the newgroup psu.dialups.

All modems in the CS department are on Malach, the network terminal-server. When you first dial in, hit return twice, then follow instructions given in the message header. Type "help" for information on additional commands.

In order to trace problems, users experiencing problems need to supply as much complete and accurate information as possible. The following is a list of information to supply when reporting problems. Examples showing how to get most of this information follows the list.

Examples
==========
Phone number dialed?                          ______________ (725-3144)
 
Did you get the Malach prompt after the
"CONNECT" response from your modem?           ______________ (yes/no)
Was there an error in connecting to the host? ______________ (yes/no)
What was the error message?                   ______________
Could you connect to other hosts?             ______________ (yes/no)
What software are you using to connect        -------------- 

Work arounds

  1. If all you get is the message "CONNECT", you can take advantage of the modem timeout period of 30 seconds. You would dial the number, wait for the modem at the other end to attempt to establish a connection, hang up, and dial it again. This will allow you to bypass the offending modem, as it is busy trying to connect to your first call. Please report these problems as "dead connects".

  2. If you are having trouble connecting to a specific host, the host may be down.

    From malach, the response would be `HOST NOT RESPONDING.'

  3. If you suspect that you are having a problem with the terminal server, you can check to see which malach port you are on by typing who at the malach prompt.

  4. By trying another modem number you could determine if it is your modem that is having the problems.

The best way to report a problem is with the description of what you think the problem is, followed by a log of what happened. If you are unable to get the backlog of the session and problem, then the appropriate information will be needed, i.e. phone number, port, etc.

Basic UNIX Commands

This chapter is a quick introduction to some of commands available under the UNIX operating system. For more information on any of these UNIX commands refer to the man pages, described in Section See section Man Command.

UNIX Control-Key Commands

UNIX understands several control-key commands, commands you enter by holding down the control key (ctrl) while striking a second key. Listed below are some of the UNIX control-key commands:

ctrl-s
freezes the screen and stops any display on the screen from continuing
(equivalent to a no-scroll key) (sometimes takes a moment to work)
ctrl-q
un-freezes the screen and lets screen display continue
ctrl-c
interrupts a running program
ctrl-\
same as ctrl-c but stronger (used when terminal doesn't respond)
ctrl-z
suspends a running program (use the fg command to continue the program, see section Controlling Jobs)
ctrl-h
deletes last character typed
ctrl-w
deletes last word typed
ctrl-u
deletes last line typed
ctrl-r
redraws last line typed
ctrl-d
ends text input for many UNIX programs, including mail and write.

UNIX Command Syntax

UNIX commands must be entered in the following form:

 command -options arguments

The command is always the first word. The options modify the function the command performs. The arguments identify the data (usually a file or files) upon which the command performs its function.

This syntax is almost universal within UNIX, but not quite. A few commands take options without the preceding dash, and some commands accept dashes but don't require them. Some commands require a dash for each option, instead of permitting you to group several options after one dash. If you have questions about a command's syntax, refer to the man pages (explained in Section See section Man Command) as the final authority.

Three additional areas you should know about using UNIX commands are: abbreviations, upper- and lower-case, and wild-card characters. The first two are simply explained:

The third is only a little more complicated. UNIX shells have two wild-card characters: ? and *. The ? character is used to match one character. For example, if you tell the system to find file ???, it will return all the file names that are three characters long. The * character is used to match file names containing a varied number of characters. For example, if you tell the system to find m*, it will return all the file names that start with `m' (for example, `me', `mother', and `mary' would all be returned). The * character can also be used before partial file names (for example, *.lis) and on both sides of partial file names (for example, *.*). A useful expression is .??* which matches all files beginning with a `.' and are at least 3 characters long. Files beginning with `.' are typically not displayed.

Commands for Specific Purposes

Some common UNIX commands are listed below according to how they're used. Complete information on each of these commands is available via the man command (see section Man Command, for more info).

File Manipulation Commands

More information on dealing with files can be found in section Unix Files & NFS.

mkdir
creates new directory
mv
renames file; also moves files to directory and deletes originals
rm
deletes file
rmdir
deletes empty directory
cp
copies file
cd
changes current directory
vi
edit a file with vi
emacs
full scale emacs editor

Examining And Printing Files

cat
prints file's contents on screen
more
prints file's contents on screen one screen-full at a time
less
same as more, but also allows scrolling backwards in file
head
prints file's first 10 lines on screen
tail
prints file's last 10 lines on screen
ls
prints directory's contents on screen
pwd
prints name of current directory on screen
lpr
prints file on line printer (see section Printing)
lpq
returns status of printing jobs that are in print queue
lprm
deletes a print job from the print queue

To check or compare files

diff
compares two files and prints lines that are different
file
tries to determine type of file
grep
looks for pattern and prints file lines containing pattern
sort
sorts lines of file and puts them in alphabetical order
spell
checks file for spelling errors and prints misspelled words
ispell
an interactive spell-checker
du
displays the disk usage for the current working directory

Compilers And Interpreters

cc
compiles C programs
gcc
compiles C programs
CC
compiles C++ programs
g++
compiles C++ programs
f77
compiles Fortran 77 programs
pc
compiles Pascal programs
sicstus
Starts the SICSTUS prolog interpreter
scheme
Starts the Scheme interpreter
lint
a C program checker/verifier
yacc
parsing program generator
bison
parsing program generator
lex
generates programs for lexical analysis of text
flex
generates programs for lexical analysis of text
nice
changes the priority of a process
make
used to coordinate compiles of many seperate files

Job Control

bg
runs job in background
fg
runs job in foreground
jobs
returns names and process ids of suspended jobs
ps -a
returns names and process ids of currently running processes
kill
cancels jobs (processes)

Miscellaneous Commands

wc
counts the number of lines, words, and characters in a file
who
tells who is currently logged into system
who am i
returns your log-in status
chmod
changes a file's access restrictions
look
find words in the system dictionary or lines in a sorted list

Unix Files & NFS

All modern computers have some means of on-line storage of user data. This data is available immediately to users upon demand, via names, which are supplied by the user. In order to deal with this data, the operating system provides a consistent set of tools allowing users to create, store, retrieve, modify, and otherwise delete files. Files are usually stored physically on some system's hard disk, which is divided into many blocks, much the same way a parking lot is divided into slots, allowing many cars (disk blocks) to park (be stored) in an orderly fashion.

This discussion will give you a general understanding of unix files. After reading and understanding this chapter, you should be familiar enough with unix files to:

  1. move around within unix file tree
  2. list a file's status and understand what it means
  3. move, rename, and copy files
  4. change a file's protection, ownership, and set-uid bits
  5. understand groups and file systems, including, briefly NFS

Unix File Types

Ordinary file

An ordinary file holds data. This data can either be ASCII text (consisting of characters from your keyboard), or binary (generally a machine generated file). An example of an ASCII text file would be some program source code listing; an example of a binary file would be the command ls. The unix operating system supports both random and sequential access on any ordinary file. The majority of all your file experience will be with ordinary files. Ordinary files are usually created using text editors, compilers, and other unix commands.

Files can use almost any character. Normally files that begin with a `.' do not get displayed by commands that list files like ls. These dot files are very important. Most programs use files like `.cshrc', `.newsrc', `.login' and `.emacs' to alter the initial configuration of the program. You will see more later about dot files as you read about each program.

Directory

A directory is a unique file that again holds data. Only here, the data is restricted to being a list of files (the contents of the directory). This list of files (directory) can be any type of file --- ordinary, directory, special, or a link. All directory files are maintained by the operating system, via some file related command or system call. Directories are usually created with mkdir and removed with rmdir.

A very special directory is called your home directory. This is the directory where you are put when you first log in. This directory is the location where all of the programs will search for thier initialization files.

Special file

Special files are files that usually deal with some sort of I/O device. Some examples include: printer, tty, disk, and tape devices. Special files are usually owned by root, and should usually never need manipulation by a standard user. Special files are usually created with mknod.

Links

Unix supports two kinds of link files--a hard link and a symbolic link. A hard link is actually a file with the address space of some ordinary file's data blocks. Once a hard link is established to some file, it becomes indistinguishable from the original. It is like having two identical copies of the same file. If you modify one, the other is modified, etc. On the other hand, a symbolic link is just a reference to another file. It contains the pathname to some other file. If you remove the file it points to, then the symbolic link points to a non-existent file. Hard links are created with the command ln. To create a symbolic line, use ln -s. For example, to create a symbolic link of your USENET directory into you mail directory for use with MH, you would say

ln -s News Mail/news

File Trees and Pathnames

The unix file system is hierarchical. The top of the tree is referred to as `root'. The complete list of directories that must be traversed to access a given file is referred to as it's `pathname'. Your home directory (default directory where all your files will be stored) will usually be somewhere in the middle of the unix file tree. An example of a unix file tree is shown.

                                / (root)
                                |\
                               /|\ \
                              / | \  \
                             /  |  \   \
                            /   |   \    \
                          etc  bin  tmp  users
                                |          |
                                |         / \
                                |        /   \
                                ls     joe   sam
                                        /
                                       /
                                     foo

All files have an absolute pathname (or full pathname) and infinitely many relative pathnames. If `joe' is a user of this system, the pathname to his home account would be `/users/joe'. If he had a file called `foo' in his home directory, it's full pathname would be `/users/joe/foo'. If you were in /users, it's relative pathname would be `joe/foo'. The following concept is what allows infinitely many relative pathnames.

In every directory there are two (2) files that are created by the system when the directory is created. They are `.' and `..'. These files allow relative access to a file. The `.' means the current directory and the `..' means the previous directory. For example, if I am in joe's home directory (/users/joe), and I wish access his file `foo', I can reference it by `./foo', `../joe/ foo', `../joe/./foo', etc.

Handling Files

Unix provides many commands to handle files. I will outline, briefly, the basic ones - ls, cd, cp, mv, and rm.

To use cd (change directory), you must give it an argument of which directory you wish to cd to. For example, if you're in your home directory and issue cd /usr/bin, you will be in the directory of /usr/bin. If you wish to check this, issue the command pwd (present working directory), which would give the output: `/usr/bin'

As an experiment, do a pwd of your home directory. What is this telling you?

The command ls will, among other things, list the contents of the current working directory. An ls of `/usr/man', will usually give the following output:

cat1    cat3    cat5    cat7    man1    man3    man5    man7    
manl    whatis  cat2    cat4    cat6    cat8    man2    man4    
man6    man8    mann

ls will probably be your most useful command. ls supports many options (also called switches). A few will be used in the following discussion. The commands cp, mv, and rm directly manipulate your files. cp copies files, mv moves (or renames) them, and rm removes them. If you wish to copy a file foo to a new file boo, enter:

cp foo boo

If you wish to move `boo' to `coo', enter:

mv boo coo

And finally, if you wish to remove `coo', enter:

rm coo

After reading the rest of the chapter on Unix Files, you will discover many different and interesting ways to manipulate files. You may also be wondering how to create files in general. Files are usually created by editors, compilers, or direct unix commands. After a while, files will seem to `pop' up all over!

File Status

The command ls (with various switches) will display different items of a file's status. There are many pieces of information located in a file's status. For instance, to view a file's last modification date, do an ls -l on the file. Here is what ls -l returns on our example file `foo':

-rw-r--r--  1 tot        2437 Sep  8 15:59 foo

This file has been modified on September 8, of the current year (if it is a previous year, the time will be replaced with the year), at 15:59 hours (3:59pm).

To view a file's `last access' date, do a ls -lu on file foo:

-rw-r--r--  1 tot        2437 Sep  8 16:11 foo

Here, you can see the last access date is September 8, at 16:11 hours. With the ls -l command, you can also obtain the file's permissions. These permissions determine who can read, write and/or execute a given unix file. To understand a file's permissions, you must first understand the concept of owner, group, and other. The owner of a file is usually the person who created it (although it may be changed). The group ownership of a file is a collection of users who group own your file. Finally, other is any other user on the system.

The reason unix has all three is because you may wish to give only the owner (generally yourself) the ability to read and write your file, while allowing the group to only read it, and the rest of the computer's user community, no access to the file at all. So, with a few commands you can protect your files reading, writing, and execution policies between three different domains (owner, group, and other).

When you view the output from a ls -l, you will notice on the far left, there will be dashes and letters. This is the 9-bit access control field of a file's status. The first three bits (starting from the left) represent the owner, the next three (middle) represent the group, and the last three (on the right) represent all others. Moreover, the `r' stands for read, `w' for write, and `x' for execute. So as you can see from doing a ls -lg on foo, produces:

-rw-r--r--  1 tot    staff        2437 Sep  8 15:59 foo

Here, tot (the owner), has read and write privileges, staff (the group) has read privileges, and all others also have read privileges. Consider the following output:

-rwxr-x--x  1 tot    staff        2437 Sep  8 15:59 foo

In this case, tot (the owner), has read, write, and execute privileges. The group staff, has read and execute privileges, and all others can only execute it.

A few more words on file status. The `1', just to the left of tot in the above output, shows how many links the file foo has. These links refer to hard links, since a symbolic link really has no explicit association to a file. If you do a ls -l on a symbolic link called say, `boo', pointing to file `foo', it would look like:

lrwxrwxrwx  1 tot    staff           3 Sep  8 17:10 boo -> foo

Notice, the `l' (ell) on the far left of the 9-bit permissions field. This signifies, that the file `boo' is a symbolic link. Lastly, where you see the 2437 in the following output from ls -lg:

-rw-r--r--  1 tot    staff        2437 Sep  8 15:59 foo

this is how many bytes the file is using.

There are a few more file status items that I will not discuss here; however if you wish more information on this, you may want to do a man on ls. (man ls)

Protecting Files and Directories

There are two ways to change a file's permissions. The first way is to set the permissions with a text string. Say we wish to make a file owner=read, group=read, and other=read. To do this we would do

chmod ugo=r foo

where u=owner, g=group, and o=other, and foo is the filename. Now doing an ls -l, will produce the following output:

-r--r--r--  1 tot       2437 Sep  8 15:59 foo

Alternatively, (from `foo''s current state), we could do:

chmod u+wx foo

where the `+' means add to the current permissions, produces:

-rwxr--r--  1 tot        2437 Sep  8 15:59 foo

This method should be obvious by now. The second method uses three sets of binary numbers, converted to decimal. So, if you wish to give owner read, write, group permission and all others read permission, enter:

chmod 644 foo

where the first digit is for the owner, second is for the group, and third is for all other, would produce:

-rw-r--r--  1 tot        2437 Sep  8 15:59 foo

Notice the 644 is easily extracted from `-rw-r--r--'.

                        6        4       4
                        |        |       |
                      4 + 2      |       |
                       \  |      |       |
                        \ |      |       |
                         421     421     421
                         rw-     r--     r--

All you have to do is look and see which bits are turned on, add them up and, poof, you have your number to call chmod with. Say you wish read, write, and execute (rwx) on owner, read and execute on group and all others (r-x), enter:

chmod 755 foo

-rwxr-xr-x  1 tot        2437 Sep  8 15:59 foo

Figure shows how you can obtain 755 from `-rwxr-xr-x'.

                          7       5       5
                          |       |       |
                      4 + 2 + 1  4+1     4+1
                       \  |  /   | |     | |
                        \ |/     | |     | |
                         421     421     421
                         rwx     r-x     r-x

You may take your pick of whichever method you prefer. Directory permissions work the same way, except what it means to execute a directory is basically permissions to list the contents of it. Hence, a directory of:

drwxr-xr-x  2 tot         512 Sep  8 17:46 foo

(notice the `d' on the far left, that means it's a directory)

this means the owner tot, may read, write & execute it (cd into it and list it's contents). It is uncommon to only give a user read privilege to a directory and not execute, although you may. This would allow one to read from your directory but not list it's contents.

One more thing, if you wish all files to be created with some certain permissions, use umask. For example, if you issue umask 022 you will mask all your upcoming created files with 022, thus producing a newly created file with permissions (644):

-rw-r--r--  1 tot        2437 Sep  8 18:12 foo

If you do a man on umask (man umask) it will explain in more detail about file masking.

Groups

The concept of a group is a collection of users. If you belong to a certain group, and a set of files give you special group permissions, you inherit those permissions. For example, if you're a member of group staff, and the following file has permissions:

-rw-r-----  1 tot    staff        2437 Sep  8 18:12 foo

You may read the file `foo'. On most systems you can issue the command groups and it will list all groups to which you belong.

Changing File and Group Ownership

The group access to a file can be used to safely share files between members of a group and not anyone else. To change the group of a file, use chgrp. For instance if you wish to change file foo to group bin, execute:

chgrp bin foo

Then the file would look like (after doing a ls -lg):

-rw-r--r--  1 tot    bin           0 Sep  8 17:51 foo

However, in this case, you usually must be a member of the group you are changing to, or the system will not allow such a command. To have a group created, if one does not exist with the people you want to share access to a file, you will need to contact sysgroup (see section Sysgroup, for more info.) If you wish to change the ownership of a file, use chown. For instance if you wish to change the ownership of file foo to joe, execute:

chown joe foo

Then the file would look like (after doing a ls -l):

-rwxr-xr-x  1 joe         2437 Sep  8 15:59 foo

However, you usually can not change the ownership of a file, unless you have super-user privileges.

Setuid & Setgid

The concept of setuid files means that if you have the setuid bit turned on on a file, anybody executing that command (file) will inherit the permissions of the owner of the file. So if you have the following setuid file:

-rwsr-xr-x  1 tot        2437 Sep  8 18:12 foo

This means, that when any user executes this file `foo', he will inherit tot's uid (which means he inherits all their file access permissions whether you're tot or not). Note: this can be quite dangerous. If you have a setuid shell owned by yourself, and I execute it, I essentially inherit your file permissions, hence have the ability to remove all your files.

In the above output, the reason for the small s means there's an x (execute) under it that's hidden. If it were a large S as in:

-rwSrw-rw-  1 tot        2437 Sep  8 18:12 foo

This means there's no x under the S. In order to make a file setuid, you prepend the three digits given chown with a 4, or use the s option. For example to get the first output:

-rwsr-xr-x  1 tot        2437 Sep  8 18:12 foo

I did a chmod 4755. The same is true for group, except use a 2 instead. If you want both, add them, to get 6. Hence a file with chmod 6755 would look like:

-rwsr-sr-x  1 tot        2437 Sep  8 18:12 foo

Again, notice the small s. What does that mean?

File Systems and NFS (Network File System)

The term file system actually has two (2) meanings. First it refers to a software mechanism that is generally responsible for the management of all on-line files. Secondly, the way we will use the term filesystem, refers to a given subset of a physical disk drive, divided into some defined number of disk blocks.

All files are usually stored on some type of file system. Most file systems on any given machine will usually be either local (meaning the disk is physically located on that machine), or NFS (having the disk physically located elsewhere).

NFS is a network file system originally developed at Sun. With NFS, you may have a physical file on one system facilitating access to it on another. Under NFS there exists a concept of an NFS server and an NFS client. The server is the system that has the physical space and the client is the system that mounts that space (meaning that space is available). A system may act as both an NFS server and an NFS client. Moreover, any file system on a server is also available locally within that system.

From the user perspective, NFS should be transparent. Really, from the user's view, the only way to identify whether a certain file system is mounted NFS, would be to do a df. A typical df would look as follows:

Filesystem            kbytes    used   avail capacity Mounted on
/dev/sd0a              14095   11292    1393    89%   /
/dev/sd0e              95942   83083    3264    96%   /usr
/dev/sd0d               2335     319    1782    15%   /tmp
lynx:/src             623486  540682   20455    96%   /nfs/lynx/src
lynx:/usenet          582110  290034  233865    55%   /nfs/lynx/usenet
shale:/fog/local      189369  148562   21870    87%   /nfs/shale/local
shale:/u1             322658  253664   36728    87%   /nfs/shale/users
frisby:/spare         454838  377286   32068    92%   /nfs/frisby/spare
frisby:/u1            453799  375705   32714    92%   /nfs/frisby/users

Here you can see this system has three (3) local file systems, and six (6) NFS mounted file systems. Consider the following line, from the above output:

lynx:/src             623486  540682   20455    96%   /home/rigel/src

Here, the `lynx:/src' means the NFS server is lynx and the file system we are mounting is `/src'. The next four (4) fields show statistics about disk space over that file system. The last field, `/nfs/lynx/src', shows where on your local system the lynx:/src file system appears. So for example, if you did a cd to `src' on rigel and do an ls, you would get the same listing from ls if you did a cd to `/home/rigel/src' on this system and did an ls. This /home/rigel/src is a convention established here at PSU. On our machines all NFS file systems are mounted under /home/machine-name/file-system, so in the previous example, machine_name was rigel, and file_system was bacon.

NFS provides a means of allowing file systems form one system to appear on another. Again, this should appear transparent to the user.

Related File System Commands

The following is a table describing some simple unix file commands and their usage. For further information regarding these commands, or any unix command in general, do a man command.

cd
change directory cd newdirectory
ls
list file's status ls filename
cp
copy files cp oldfile newfile
mv
move files mv oldfile newfile
rm
remove files rm filename
ln
create links ln [-s] filename linkname
pwd
print working directory pwd
mkdir
create directories mkdir dirname
rmdir
remove directories rmdir dirname
umask
set file masking umask 022
chmod
change file permissions chmod 644 filename
chown
change file ownership chown newowner filename
chgrp
change group ownership chgrp newgroup filename
cmp
compare 2 files, char for char cmp file1 file2
diff
compare 2 files, line by line diff file1 file2
cat
show contents of file cat filename
more
show contents of file, by page more filename
df
show free disk blocks df

This list of file system commands is in no way exhaustive. There are many more commands available to manipulate unix files. For more information, see section Basic UNIX Commands.

Email

Introduction

Email allows you to send letters to another user's "mailbox" that he or she can read at any time. This chapter describes UNIX email and three different mail programs: Berkeley Mail, MH and Elm. Berkeley mail is a general purpose mail program. MH is an advanced set of tools that offers increased flexibility in using mail. Elm is a user friendly menu type program. There are other mail programs, but these are the ones that are used most often at PSU.

Mail addresses and protocol

To send mail, you need to know the login of the person who is going to receive your mail. In order to find this, you can use finger in the following way:

finger name

Replace name with the name of the person you want to send mail to. A name may be a first or last name, or an account name.

For example, suppose you want to send mail to Moe Howard. To find his login, you'd type the following:

finger howard

(You could also type "moe" instead of howard.) Finger would return something like the following:

`Login name: moeh In real life: Moe Howard'

In this case, Moe's login, and mail address, would be:

`moeh'

If this person didn't have an account on the machine you're using, finger would return:

`Login name: moeh In real life: ???'

Even though this person may not have a login on the machine you're using, they might still be available by email if they have a login on some other machine. You could find their login by typing:

finger name@hostname

For example, if you know that Moe Howard has a login on rigel, you can type:

finger howard@rigel

Say, this returned:

[rigel.cs.pdx.edu]
Login name: moeh         In real life: Moe Howard
Directory: /home/rigel/mayo/moeh      Shell: /bin/csh
On since Sep 10 08:08:35 on ttypf from callisto.cs.pdx.
No unread mail
Project: 
No Plan.

Then Moe's complete mail address would be moeh@rigel.cs.pdx.edu.

Finger will only work on those directly connected Internet sites that have it configured. It will not work though mail gateways or through corporate firewalls. If you find that finger does not work, the best alternative is to use the phone and call the person you are trying to reach to get an email address. Some places like MIT and University of Illinios are setting up campus wide directory systems based on finger. But most place are not yet providing this type of directory service, in fact some have finger disabled.

Note: you may also attach domains to the machine name. Please read the following section (Berkeley Mail) for an explanation of domains.

Berkeley Mail

Once, you've established the person's login to which you wish to send, simple enter:

mail login

So, if you wish to send mail to moeh, you would enter:

mail moeh

If this user was on the machine rigel, you would enter:

mail moeh@rigel

After this point, the program mail will prompt you for the subject and body of the mail message. To end a mail message you typically enter Ctrl-D or a single dot (.) on a blank line.

When sending mail to moeh@rigel it should be noted that moeh is a user on the machine rigel. This machine is located under some domain.

A domain is a string of words separated by periods. Lower-level domains are arranged left to right, in ascending order, ending with a top-level domain. Any number of lower-level domains may be used.

A domain may represent a subdivision of an organization (at any level), or an individual host computer. The following is a list of some of the domains that are found on the PSU campus, and thier associated departments:

cs.pdx.edu
Computer Science
ee.pdx.edu
Electrical and Computer Engineering
cc.pdx.edu
Computer Center
mth.pdx.edu
Math Department
pp.pdx.edu
Physical Plant
lib.pdx.edu
Library

So, if you wish to send mail to a user in another domain, you would enter:

mail login@machine.domain

As you can see, the key to sending someone mail is locating their login, machine, and domain. So, as a review, if the user you wish to send mail to is on the same machine as you, enter:

mail login

If they are in the same domain as you, enter:

mail login@machine

and if they're outside your domain, enter:

mail login@machine.fully.qualified.domainname

How to receive mail

To receive mail, type the following command:

mail

The mail facility responds by printing a list of letters that are in your mailbox. This list looks something like the following:

Mail version SMI 4.0 Wed Oct 23 10:38:28 PDT 1991  Type ? for help.
"/usr/spool/mail/moeh": 1 message 1 new
>N  1 moeh@rigel.cs.pdx.edu Wed Sep  1 12:31   20/643  Help 
& 

In this list, "moeh" is the login of the user who sent you mail, and the quoted section on the right is the subject of the message.

Once inside the mail facility, you can do a variety of things, including the following: scan through the subject headings of your letters, read your mail, reply to it, delete it, forward it, or save it into files. The following is a list of commands that you can give a the ampersand (&) prompt:

t
displays the current letter
n
displays the next letter
d
delete current letter
u
undeletes last (or all) letters
h
lists your letter headers
R
replies to the sender(s) only
r
replies to sender(s) and recipient(s)
q
quits out of mail and saves changes (including deleted messages)
x
quits out of mail without saving changes (doesn't delete messages)

For a more complete list of mail commands, type a question mark (?) in response to the mail facility's ampersand (&) prompt.

The mail program can be configured by editing the file .mailrc. This file will let you define aliases and customize how mail works. Below is a example .mailrc file. Please read the man page on mail to find the details of the initialization parameters.

# .mailrc -- initialization for mail(1)
#
set append 
# ask for the subject
ask 
#start using the pager if the message is bigger than 22 lines.
crt=22 
dot 
folder=Mail 
hold
set nosave 
quiet 
#Don't display some header lines
ignore received message-id status
# set up an alias
alias rms rms@gnu.ai.mit.edu 

More on mail addresses

This section describes some other forms of addresses when sending mail to users who are not on the same system as yourself. There are many different mail systems and many different ways to connect between them.

Site and network

To specify the user's site and network, issue the mail command as follows:

mail login@site.network

Replace site with the name of the site where the person login identifies is, and replace network with the name of the network that person is on.

For example, the following command sends mail to someone who's login is "echo," who is at "hp-pcd," and who uses the "uucp" network.

mail echo@hp-pcd.uucp

There are other networks as well as uucp. Another example is the bitnet net. A possible mail command might be:

mail lstsru@orstate.bitnet

Earlier in this chapter there was a discussion of domain addresses. It is important that a domain is specified when sending mail. The only exceptions are when you are mailing within the sub-domain cs.pdx.edu. That is, all machines in the Computer Science Department do not require that a network is specified, if you are mailing from a CS machine. For review, if your machine is in the Computer Science Department, then your return address is:

`login-name@machine-name.cs.pdx.edu'

Secondary parsing

If you need to send to an address in which there is no direct access to the network, you need to make use of secondary parsing. In other words, you can have "someone else" figure out how to get the mail to go where it should go. The format is:

mail login%site@relay-machine-name

Replace site with the name of the site where login is. site can include the network name. For example, if you want to send mail to someone who is on the BITNET, you can use secondary parsing. In general addresses of the form user@site.BITNET will work, this is just an example of secondary addressing. In the above format the @relay-machine-name indicates the "someone else". So the command:

mail wyatt%cfa2.BITNET@CUNYVM.CUNY.EDU

would be handled as follows. The machine that you mailed the message from would send it to orstcs, our nameserver. Orstcs would see the @CUNYVM.CUNY.EDU and know to send it there. The @CUNYVM.CUNY.EDU would subsequently be stripped off of the initial address. CUNYVM.CUNY.EDU is one of our gateways to the BITNET, so when the machine there saw wyatt%cfa2.BITNET it would know to send it on its way through the BITNET. BITNET addresses are of the form user@host, so CUNYVM.CUNY.EDU would strip off the .BITNET and change the % to an @.

You should remember that in secondary parsing the address is parsed from right to left.

The following is a table outlining how to send to different networks from the Internet:

Applelink
user@applelink.apple.com
AT&T
user%attmail@att.com
Compuserve
7xxxx.yyy@compuserv.com
Fidonet
john.smith@f3.n2.z1.fidonet.org
Mci
2345678@mcimail.com
Span
user@host.span.NASA.gov

What to do when sending mail

After you type the command to send mail, the system may prompt you for a subject. Your subject may be up to one line long.

After typing the subject (if your system prompts you for one) , you can type your letter. Note that mail doesn't have a prompt when you're sending mail; it just sits there waiting for you to type. You can enter as many lines of text as you want.

To get help while in the mail facility, type the following:

? on a line by itself followed by a carriage return

This will bring up a collection of commands that can be used from inside a mail message. The most useful of these is v, which causes your mail message to be put into an editor (default vi) so that you can edit the mail message. (This looks at the value of the VISUAL environment variable. Change this variable if you want to use a different editor)

If you decide in the middle of typing your letter that you don't want to send the letter or that you want to save it and finish it later, type ctrl-c twice. This saves the contents of your letter in a file called "dead.letter." You can then delete the dead.letter file or edit it and send it at a later time. To send a letter that you saved in the dead.letter file, type the following:

mail -s "subject" login < dead.letter

Note: If the letter is not saved into dead.letter, and you want this option, your .mailrc file will have to be modified. Invoke an editor and bring up your .mailrc file. Remove only the word "nosave" from the file. Save the file. From then on, each time you use mail, the cancelled mail will be saved in the file dead.letter. When you're done with your letter, type ctrl-d to get out of the mail facility and back to the UNIX prompt. When you type ctrl-d, mail sends your letter to the user who's login you named when you invoked mail.

MH -- Mail Handler

(Note: Taken from the MH man page.)

MH is the name of a powerful message handling system; it is an alternative interface to the UNIX mail system. Rather then being a single comprehensive program, like most mailers, MH consists of a collection of fairly simple single-purpose programs to send, receive, save, and retrieve messages. The user should refer to the MH User's Manual and the man pages for the MH program for more details about how to use the program.

Unlike mail, the standard UNIX mail user interface program, MH is not a closed system which must be explicitly run, then exited when you wish to return to the shell. You may freely intersperse MH commands with other shell commands, allowing you to read and answer your mail while you have (for example) a compilation running, or search for a file or run programs as needed to find the answer to someone's question before answering their mail.

The structure of MH makes it possible to easily customize the mailer to be more effective and efficient for your use. MH is a more powerful and flexible mailer than the regular UNIX mail program. MH makes it easy to organize and coordinate large amounts of mail. It can be slower for reading individual mail messages, but often can be more powerful when handling large numbers of mail messages.

To get started using MH, put the directory /usr/local/bin/mh in your $PATH. This is best done in one of the files: .profile, .login, or .cshrc in your home directory. (Check the manual entry for the shell you use, in case you don't know how to do this.) Run the inc command. If you've never used MH before, it will create the necessary default files and directories after asking you if you wish it to do so.

The MH system uses the ".mh_profile" file to configure the MH system. You will need to read the man pages for more information about this file. You may also want to look at other peoples files to see examples of MH configurations.

MH basic commands

There are some basic commands that allow you to use MH to read mail:

inc
incorporate
scan
scan messages
show
show current message
prev
previous message
next
next message
rmm
remove message
repl
reply to message
comp
compose message

These are the basic commands that are most often used.

inc
moves mail from your system maildrop into your MH `+inbox' folder, breaking it up into separate files and converting it to MH format as it goes. It prints one line for each message it processes, containing the "From" field, the subject field, and as much of the first line of the message as will fit. It leaves the first message it processes as your current message. You'll need to run inc each time you wish to incorporate new mail into your MH file.

scan
prints a list of the messages in your current folder. It will place a + in front of the current message in the folder. Scan may be passed a list of messages or a range.

show, next, prev
are used to read specific messages from the current folder. show displays the current message, or a specific message, which may be specified by its number, which you pass as an argument to show. next and prev display, respectively, the message numerically after or before the current message. In all cases, the message displayed becomes the current message. If there is no current message, show may be called with an argument, or next may be used to advance to the first message.

rmm
deletes the current message. It may be called with message numbers passed as arguments, to delete specific messages.

repl
is used to respond to the current message (by default). It places you in the editor with a prototype response form. While you're in the editor, you may peruse the item you're responding to by reading the file . After completing your response, you will be prompted by the what now? prompt. By pressing return you will see all of the options available to you, l will "list" your message, s will "send" your message, or p will "push" your message in to the background. Push is the same as send but much faster.

comp
allows you to compose a message by putting you in the editor on a prototype message form, and then lets you send it.

All the MH commands may be run with the single argument: `-help', which causes them to print a list of the arguments they may be invoked with.

Commands which take a message number as an argument (scan, show, repl, ...) also take one of the words: first, prev, cur, next, or last to indicate (respectively) the first, previous, current, next, or last message in the current folder (assuming they are defined).

Commands which take a range of message numbers (rmm, scan, show, ...) also take any of the abbreviations:

num1 - num2
Indicates all messages in the range num1 to num2, inclusive. (the range must be nonempty)
num:+N
Up to N messages beginning with message num.
num:-N
Up to N messages ending with message num.
(num
may be any of the pre-defined symbols: first, prev, cur, next or last)
first:N
The first N messages, if they exist.
prev:N
The previous N messages, if they exist.
next:N
The next N messages, if they exist.
last:N
The last N messages, if they exist.

One of the most useful examples is: scan cur-last

There are many other possibilities such as creating multiple folders for different topics, and automatically refiling messages according to subject, source, destination, or content. For more information please consult the MH manual pages. (man folder, man mh, man refile)

Elm

Elm is a menu based way of sending mail. When elm is invoked, a menu of commands is displayed and if you have mail, it will display the subjects of the mail.

There are 3 main ways to use elm:

  1. Explicitly send a single message.
  2. Conveniently send files or the output of commands via command line redirection.
  3. Use elm as an interactive mail interface program (Just type elm).

To invoke elm just type: elm

Once you are in elm, you will see at the bottom of the screen a menu of commands, and if you have mail waiting you will see at the top of the screen, from who the mail is coming from and the subject of the mail. In front of each piece of mail there is a status message and also a number. The status field is composed of three separate character fields, the first of which indicates temporary status:

D
Indicates a deleted message.
E
Identifies an expired message. This flag is set according to the header field Expires.
N
Identifies a new message.

At the menu you can execute this commands that will enable you to read, send mail, reply to mail, forward mail and other functions.

Return
Read current message.
f
Forward this message to another person.
m
Send mail to a specified user.
n
Go to next message.
q
Quit and save all changes.
r
Reply to the author of the current message.
c
Change mailbox file.
s
Save message(s) to file.
x
Exit and throw away all changes.

When sending a message, elm uses vi as the default editor, unless you have altered the editor specified in your .elm/elmrc file or have an editor listed as $EDITOR in your environment. If builtin is specified as your editor, a large set of commands is available while composing your message.

If the file $HOME/.elm/elmheaders exists, elm reads in the contents of the file and adds it to the headers of all outbound mail (useful for adding an Organization: field, Phone: field, etc).

Elm supports automatic configuration by means of an rc file. The file must be named $HOME/.elm/elmrc and can contain any combination of the string, numeric, and boolean variables described below. If the directory $HOME/.elm does not exist, elm asks whether you want to create it or not. If you respond with "yes", elm will create $HOME/.elm.

The following files have special meaning if they exist in your .elm directory:

signature
This file will be appended to all outbound mail before the editor is invoked.
weedout
This can contain a list of headers that you wish to not see. Default is >From" "In-Reply-To:" "References:" "Newsgroups:" "Received:" "Apparently-To:" "Message-Id:" "Content-Type:" "From" and "Mailer:")

Ways to Communicate with Other Users

This chapter talks about six ways to communicate on line with other UNIX system users: mail, messages, news, talk, write, and conferencing programs.

Mail

Mail is a way of sending a person a letter and the next time that person logs on again he will be able to read the message. Mail is discussed further in Chapter See section Email.

Messages

A way to communicate on line with other users is to use the "messages" facility. Messages are a form of mail where the messages you send go to everyone on the system. The support staff will post urgent messages to msgs. Ongoing discussions and non urgent information should be done in news. Msgs and other news groups are discussed further in section News.

How to send messages

To send a message to everyone on the system, type the following:

mail msgs

Mail will prompt you for everything else you need to enter.

How to receive messages

To receive all the messages available, type the following:

msgs

If you are using a machines which does not support messages, then you can read them by reading the articles in the newsgroup msgs. For example,

nn psu.msgs

Many people have the command for receiving messages in their log-in files so that when they log in, they see all existing messages. If you don't see the messages when you log in, but you want to, you can include the command for receiving messages in your login file.

News

Usenet news is like a very large electronic bulletin board service. It allows users to post electronic "news" articles around the network and to read news items from other users at other sites. More information on news and how to read and post articles is covered in section News.

Talk

Talk is a visual communication program which copies lines from your terminal to that of another user. To use talk, type the following:

talk login@fully.qualified.domain.name

Replace login with the user's login, and fully.qualified.domain.name with the user's site.

If you're on a BSD system and you want to find out who is currently logged in and what their logins are, type the following:

moeh     Moe Hawthorne         s4   24 Fri 15:22  :0.0
griff    Griff McClellan       se   1d Wed 11:23  sirius.cs.pdx.ed
alf      Anthony Fiarito       co      Fri 15:20
tytran   The Hitman            p0      Sat 03:15  malach.cs.pdx.ed
riceman  Rich Rice             p6  12: Fri 15:05  137.161.6.79
johnj    Tail Cat             *pa      Sat 03:17  pcat144.cs.pdx.e
antoy    Sergio Antoy          q9   2d Thu 09:10  antares.cs.pdx.e

From this list, you can see that Moe is logged in. You can send him a message using talk by typing the following:

talk moeh

If your login is "larr", moeh will get a message at his terminal that looks something like the following:

Message from Talk_Daemon@rigel at 10:07 ...       
talk: connection requested by larr@cs.pdx.edu.edu
talk: respond with:  talk larr@cs.pdx.edu       

From here, moeh can answer you using talk. When he does, talk splits your screen in two and shows your typing in one half and moeh's in the other half. Both you and moeh will see both sides of the conversation.

When you finish each of your messages, type <0>, for "over", to tell moeh that your message is over. When you're ready to quit, type <0 + 0 >, for "over and out", to tell Moe you're quitting. To exit talk, type ctrl-c.

Note: If the person you are trying to talk with is logged onto a computer more than once, you may experience problems connecting. The computer can not tell which tty port you want it to use. To help the computer out, give the tty after the users name:

talk moeh ttyp3

To find out the tty of another user, use the finger command.

Write

Write allows you to communicate with other users when you are at a hard-copy terminal and the same system. To use write, type the following:

write login Replace login with the login of the user you want to communicate with.

If your login is "larr" and you're working on the rigel system, the person you send the message to receives a message that starts like this:

Message from larr@rigel on ttypf at 10:16 ...e talking to each

That person can reply using write, and you'll be talking to each other. Everything typed at your terminal will be sent to the other user's terminal, and vice versa. End each message in < 0 >, as with talk, and, also like talk, end your write session with < 0 + 0 >. To terminate the conversation, type ctrl-d.

Note: If the person you are trying to talk with is logged onto a computer more than once, you may experience problems connecting. The computer can not tell which tty port you want it to use. To help the computer out, give the tty after the users name:

write moeh ttyp3

One drawback of write as compared to talk is that it's hard to tell when the other person has completed a message and is waiting for your response. A good rule of thumb is to enter two carriage returns after the last line of your message.

Mesg

If you don't want to be disturbed by other users sending you interactive messages, you can prevent them from sending you messages by using mesg. To use mesg, type the following:

mesg n You can permit messages again by typing the following:

mesg y

Conferencing Programs

There are a couple of different programs that allow you to talk interactively with more than one person at different sites. These programs are unsuported and not installed on all machines.

The basic idea for the programsis to have a large amount of people using the program from different places at the same time, sort of like a party line on the phone. You can join different "channels" or groups with different topics and talk to all the people on the channel, or you can send private messages to a certain user.

IRC

IRC stands for Internet Relay Chat. To start irc type irc2 at the prompt:

irc

This will put you in the irc window with the line on the bottom used for giving commands and the rest of the window for watching what else is happening. These sections are divided by a highlighted line that says your nickname, the program name (IRCII) and /HELP for help. When you type /HELP you get a list of topics that you can get help for. You can type /HELP BASICS to get the following introduction to irc.

Irc is a multi-user, multi-channel chatting network. It allows people all over the Internet to talk to one another in real-time. Each irc user has a nickname they use. All communication with another user is either by nickname or by the channel that they or you are on. All IRCII commands begin with a / character. Anything that does not begin with a / is assumed to be a message that is sent to everyone on your channel. Here is a list of basic commands to help you get started:

/NAMES
Shows the nicknames of all users on each channel.
/JOIN channel
Join the named channel. All non-commands you type will now go to everyone on that channel.
/MSG nick msg
Sends a private message to nick. Only nick will see this message.
/NICK nick
Change your nickname to nick.
/QUIT
Exits irc.
/HELP topic
Gets help on all IRCII commands.
/WHO channel
Shows who is on a given channel, including nickname, user name, host, and real name.
/WHOIS nick
Shows the "true" identity of someone.

These commands should get you started on irc. Use the /HELP command to find out more about things on irc, or ask question of people... most would be happy to help you out. You can also type man irc to read the man page. Another good source of information about irc is to read the newsgroup alt.irc.

Remember, when you first start irc, it puts you into channel 0 (or *). Since this really isn't a channel, you need to join another channel in order to talk to other people on that channel. Once you have joined a channel, anything you type and then hit return afterwards, everyone on that channel will see. IRC uses your login name as a default nickname. To change your nickname you would type /NICK your new nickname.

Editors

Introduction

Two editors are used on the Computer Science Department's UNIX systems: vi and emacs.

The next two sections explain vi and emacs. Each section contains the following: a general description, how to learn it, how to get into it, and some of its commands.

Vi

Vi is a visually oriented text editor that's based on ex, a line editor that's available on most UNIX systems.

How to learn vi

You can learn vi by doing the following:

How to use vi

To use vi, type the following command:

vi file

If the file you designate exists, it will be opened, and the contents will be displayed. If the file does not exit already, vi will open a file with the specified name. Vi has two modes: command and insert. When you start vi, you're in command mode. In command mode, vi accepts commands like the ones listed later in this section (commands to move, delete, save, etc.). In insert mode, vi accepts everything you type as text.

If you're in command mode, you can enter insert mode by typing a command like i, which inserts text starting at the cursor (there are others -- see the list of commands). If you're in insert mode, you can enter command mode by pressing the escape key.

Entering and Leaving Vi

vi -l
set up for lisp editing
vi -R
read only
vi +n
edit file starting at line n
:q!
quit vi; discard changes
ZZ or :wq
write and quit
:w
write; don't quit

Inserting and Changing (end with esc key)

A
add at end of line
i
insert before cursor
I
insert before first character in line
o
open line below; add text
O
open line above; add text
rx
replace single character with x
R
replace characters until ESC is pressed
s
substitute characters
S
substitute lines
.
repeat last change

Correcting during insert

esc
end insertion
ctrl-w
erase last word

Deleting

dw
delete word
dpattern
delete up to pattern
D
delete rest of line
x
delete character
X
delete characters to beginning of line

Moving and Copying lines

ny
copy n lines to buffer
p
put all lines in buffer after current line
P
put all lines in buffer before current line

Undoing and Restoring

U
restore current line

Positioning within the file

ctrl-b
backward one screen
ctrl-d
scroll down half screen
ctrl-u
scroll up half screen
n G
go to line n (default: end of file)
1G
go to beginning of file
G
go to end of file

Line Positioning

k
previous line, same column
H
top window line
L
last window line
M
middle window line
+
next line, first character in line
-
previous line, first character in line
J
join lines

Character Positioning

0
beginning of line
$
last character in line
l
forward one character
h
backward one character

Words, Sentences, Paragraphs

b
backward one word

Searching for pattern

pattern
matches pattern to next line matching pattern
?pattern
to previous line matching pattern
n
repeat last search

File manipulation

:e file
edit file
:e!
reedit, discarding changes
:r file
read from file; put after current line
:w
write back changes
:w file
write to file
:w! file
overwrite file
:!cmd
execute cmd in shell, then return to editor

Emacs

Emacs is an advanced, self-documenting, customizable, extensible real-time display editor. Emacs was written by Richard Stallman of the Free Software Foundation. Emacs is mostly written in Lisp, with some C for efficiency.

Emacs is WYSIWYG (what you see is what you get), updated frequently, has features like text filling, auto-indent, viewing 2+ files, deals with characters, words, lines, paragraphs, sentences, pages. The user can change the definitions, rearrange the command set, and create new commands (programs in Lisp) online (don't need to create a new version).

Getting Started

Welcome to Emacs. Learning Emacs may seem a daunting task, but spending a few minutes learning Emacs, can save you many more in the future. Emacs is an extremely powerful editor and many of tasks you now do from the command line and using different applications can be done from inside of Emacs.

The section contains a brief tutorial on some of the basic operations of Emacs, so you can get started quickly and learn the more powerful features later.

Starting Emacs

To start Emacs type `emacs' and an optional file you wish to edit then press return. That's it!

Opening a file

If you didn't specify a file when you started Emacs you can open one after you enter Emacs by typing C-x C-f. This means hold down the control key and then press the x and f keys and release the control key. You will be prompted for a file name at the bottom of your Emacs screen. Enter the file name you wish to edit and press return.

Moving around in your file

There are three different ways to move around in your file: Control keys, the mouse and, if they are enabled, the arrows keys on your keyboard. Below are the control keys, with which you can move around in your file. Any other keys you press will be inserted as text in your file.

C-f forward-char
C-b backward-char
C-n next-line
C-p previous-line
C-a beginning-of-line
C-k kill-line
C-e end-of-line
C-d delete-char
C-g keyboard-quit
C-h help-command
C-l recenter
C-o open-line
C-r isearch-backward
C-s isearch-forward
C-t transpose-chars
C-v scroll-up
C-@ set-mark-command
C-w kill-region
C-y yank
C-z iconify-frame
C-_ undo

Saving and exiting

To save your file press C-x C-s

To exit Emacs press C-x C-c

Hints

If you get stuck by hitting the wrong key combinations you can press C-g to abort. This will terminated almost any command. You should read the section on getting help before you get started.

Command completion is a usefull time saving feature of Emacs and can save you many keystokes and works in most contexts. One usefull example is: when opening a file you don't have to enter the whole name, just type the first letter or first unique letters and then press the tab key. Emacs will fill in the rest for you. If there is more than one file with the same first characters, pressing the tab key again will open a buffer window with a list of the file names which have those first characters.

If you are using Emacs19, read the section on Emacs19 first. Many of the commands you do by entering keystrokes can be done using menus.

When you see M- in the documentaion it means press the ESC key first. On some systems the ALT key has the same effect.

To execute a command in Emacs use M-x and then the command name.

Buffers

When you edit a file in Emacs, it is stored and edited in a buffer and when you save your file you are actually saving a buffer. Buffers can not only contain files they can also be used for a wide variety of purposes. Among these is storing and displaying the information generated by help commands and utility lisp programs such as mail handlers or gnus, the Emacs news reader.

These are the most used buffer commands.

To list all the buffers use C-x C-b this is bound to the list-buffers command.

To kill a buffer use C-x k this is bound to the kill-buffer command.

Windows

Buffers in Emacs are displayed in windows. When you first start Emacs you see only one window, you can display more than one window by dividing the display either vertically or horizontally.

Use C-x 2 to split a window vertically or use C-x 5 to split a window horizontally.

Delete a window with C-x 0 and move to another window with C-x o.

Emacs Help

An Emacs reference card is available in the tutors room. Complete documentation is available in the info system under Emacs. Printed version of the same documentation is also avialable.

One of the big advantages of Emacs over other editors is the extensive availability of on-line help. To acess on-line help use ESC-? or C-h depending on which is enabled in your system. Here is a list of the help functions and a brief explanation of them.

Emacs19

Emacs19 is the X-based version of Emacs and is mouse-sensitive. Many new feature have been added. Read Emacs News in the help menu for a list of these.

Menus have been added and can be accessed by the menu bar or by holding the control key and clicking a mouse button. These menus can also be customized.

A scroll bar is on the side of the frame and by clicking on it with the mouse you can move around your buffer.

Multiple frames can be added with new frame.

The mouse can be dragged to mark a region and with the edit menu you can cut and paste like many commercial wordprocessors. You can also cut and paste between Emacs and the rest of your X terminal screen.

Emacs19 is still unsupported software at PSU and is located in the /usr/local/uns/bin path. Some parts of the .emacs initialization file don't port to emacs19.

The Emacs Initialization File

The initialization file is ".emacs" and is in your home directory. This file can be used to customize your emacs environment. Here are some good things to have in your ".emacs" file:

(display-time)

(setq-default version-control t)

(setq-default auto-save-interval 50)

* display-time displays the time, system load factor and a flag to indicate unread mail on the mode line (in addition to the other stuff).

* version-control set to true allows for versioning: if you edit the file prog1.c, then you will end up with a previous version, prog1.c. and the current file.

* auto-save-interval saves your file after specified number of keystrokes. (Causes short delays, but I value my work.....)

X Environment

After typing in your login and password, XDM checks your home directory for a .xsession file. If you have a .xsession file, it is executed. If you do not have a .xsession file, then the file /usr/local/X11R5/lib/X11/xdm/.xsession is executed. In order to change the Window Manager that is started, or to modify the other programs that are started when you log in, you must have a .xsession file in your home directory.

The CS department supports one Window Manager: twm.

If you want to customize your X environment, you may copy the default startup files and modify them accordingly. Make sure you know what you are doing before modifying the default setup, because it is very easy to make a mistake that will prevent you from logging in. When in doubt, ask the tutor for assistance.

The Xresources file

The Xresources file is read by your .xsession file when you log in. There are several command line options that can be given when an X client is run (see the man page for xterm for example.) Each of these command line options can be specified in the Xresources file. If the command line option is not specified, then the specification in the Xresources file is used as a default.

The .xsession files support two Xresources files. The system keeps a Xresources file in /usr/local/X11R5/lib/X11/Xresources. You may have your own customized Xresources file in your home directory.

Warning: If you modify your .xsession file, make sure that you do not remove the line that loads the system Xresources; things will stop working if you do not load the system Xresources.

Using a .twmrc

Twm (Toms Window Manager) is a window manager for the X-Windows system. It provides titlebars, shaped windows, several forms of icon management, user-defined macro functions, click-to-type and pointer-driven keyboard focus, and user-specified key and pointer button bindings.

The system default .twmrc file may be found in /usr/local/X11R5/lib/X11/twm. To customize the action and feel of TWM, you must first copy the .twmrc file to your home directory. To do this, type the following: cp /usr/local/X11R5/lib/X11/twm/system.twmrc $HOME/.twmrc

Features

The features included in the standard .twmrc are described here.

Pop-up menus

To see the pop-up menus, press one of the mouse buttons while the mouse cursor is located in the root (grey background) window.

The first menu is reached by pressing the left mouse button, while the mouse cursor is in the root window. It is labeled Window Options. This menu contains things you can do, such as Refresh the screen, Focus on a window, Move or Destroy a Window, Show or Hide the Icon Manager Window(usually located in the upper right corner of your screen), Reread the .twmrc file (useful if you've made some changes and you want to see the results without logging out and back in), and Exit TWM, the Tom's Window Manager program.

The second pop-up menu, reached by pressing the center mouse button while the cursor is located in the root window, is the Hosts menu. With this menu you can open a window on a particular computer host, such as Sirius, Jove, Csqr, Odin, or the PSU library, if you have an account on that machine. You will be given a login prompt for typing in your account name and password.

The third menu, reached with the right mouse button, is the Applications menu, giving you the option of opening certain applications, such as a calculator, a man page reader, a mail reader (elm), etc. Not all of these work on every machine. Xman is one that you may want to take notice of. It opens a window in which you can look at man pages.

Control Menus

The set of menus described in the previous section pop-up when the mouse cursor is on the root window. There is another set of menus that pop-up when the mouse cursor is on a window and the control key is pressed while a mouse button is being pressed.

Pressing the left mouse button while the cursor is within a window and you are also pressing the control key gives you a menu of Main Options, such as redrawing a window, or sending a kill signal to destroy the window.

Using the middle mouse button with the control key gives you some options for controlling the window you are currently in, such as changing to reverse video, or enabling the visual bell (the window will flash instead of beep when you make an error).

If you press the right mouse button while pressing the control key, you will be given the option of changing the size of the font in the window you are currently in, making it smaller or larger.

Cut and Paste

If you have several windows open and want to copy some text from one window to the other you can use the cut and paste feature of X.

First select the text in one window using the first mouse button (left). Then go to the window you want to paste that text to and press the second mouse button (center). The text will appear in the window just as if you had typed it yourself.

Key Bindings

Below is a chart of what happens when the mouse keys are pressed. Different things happen depending on where the mouse is and what keys are pressed at the time.

Button1
root & menu Window Options
Button2
root & menu Hosts
Button3
root & menu Applications

Button1
shift & window & raise
Button2
shift & window & move
Button3
shift & window & lower

Button1
control & window & menu Main Options
Button2
control & window & menu VT Options
Button3
control & window & menu Fonts

Button1
titlebar & menu move
Button2
titlebar & menu raise
Button3
titlebar & menu lower

Button1
icon & iconify
Button2
icon & move

Tips

When the size of a window changes let the computer know what the new window size is by typing: eval `resize` or resize

Logout

To end a session (logout) move the mouse pointer down to the "LOGOUT" box and click in the box. This closes all windows, resets the screen, and brings the XDM login window back. In general it is a good idea to stop any commands you have running before logging out.

Error messages

The error messages are re-directed to the .xsession-errors file in your home directory. To view the errors, type: cat $HOME/.xsession-errors. Usually you can ignore this file unless you are having problems running an application.

Text Processors

Text processors are similar to compilers, but instead of preparing a program for execution, they prepare a text file for printing. For example, this manual was created using a text processor. The authors created a text file and put in it both the manual's text and commands to tell the text processor how to format the text. Because of the commands they included, the headings are in bold-face type, the examples are indented, and so on.

There are two major text processors available: troff and TeX. LaTeX is a macro package for TeX and gets used more than Plain TeX at PSU (and many other places), so this section will go over LaTeX and TeX format text to be printed on a laser printer, although there are programs to give a "tty" approximation of the output. There are X-window based preview packages available for troff and TeX. Using them will save you time and paper.

LaTeX

LaTeX (pronounced lah-tech) processes files so they look typeset and can be printed on a laser printer. LaTeX is widely used on college campuses for writing technical reports, theses, and sometimes class assignments, but can be used for much more.

Where to Find Help for LaTeX

There are several facilities available to you for helping with LaTeX. The first place that you should probably look is in a book called LaTeX, A Document Preparation System (which will be referred to as the LaTeX Manual for the rest of this section) written by Leslie Lamport. The author of the book is the actual programmer of the macros that are used by LaTeX to do it's processing. The book can be ordered through most bookstores.

The second place you can find help with is a newsgroup that has been set up to field questions concerning LaTeX. If you are stuck with a problem that the LaTeX Manual cannot answer, you can post a message on `psu.TeX'.

For general discussion of LaTeX you can read the newsgroup comp.text.tex.

How to learn LaTeX

To learn LaTeX, you can read this chapter and/or read the LaTeX Manual. This section provides fundamental information to get you started using LaTeX and acquaint you with LaTeX's capabilities. The LaTeX Manual does an excellent job at giving more detailed help and more thorough examples. The LaTeX Manual is the comprehensive document describing LaTeX; it provides everything from basic information to specifics on setting up your own document formats.

The LaTeX Manual often refers to the TeX book. This is the book that describes TeX. This comprehensive book, written by Donald Knuth (as was TeX itself), is available Library.

How to prepare files for LaTeX

To prepare a file to run through LaTeX, you must include commands that tell LaTeX what to do with the text in the file. This section explains the basic LaTeX commands and some of the effects you can produce using LaTeX.

Basic LaTeX commands

LaTeX understands three basic document styles: report, article, and letter. Many add commands to LaTeX, but some are whole document-changing styles. The major difference between the report and article styles is that reports can have chapters and sections but articles can only have sections. The letter style, of course, formats letters.

The following is an example of the most basic LaTeX commands:

\documentstyle{report}
\begin{document}

Mares eat oats and does eat oats and little lambs eat ivy.

\end{document}

These commands tell LaTeX what kind of document the file is, where the document starts, and where the document ends. Every text file that is to go through LaTeX must contain these commands.

The only variable parts of this example are the actual document style and the text inside the document.

The text inside the document can be formatted in many ways. To produce a simple document, you might want to know about the commands to produce the following elements:

To produce a chapter title (which starts a new page) in the report style, include the following command after the \begin{document} command:

\chapter{name}

To produce a section heading in either the report or article styles, include the following command:

\section{name}

In both situations, when LaTeX finds the command, it formats name according to what the document style dictates, affecting the type style and size of name and the spacing around it.

Another thing LaTeX does when it finds the command is put the word "Chapter" or "Section" and a number in front of the chapter title or section heading. To prevent LaTeX from numbering the chapters and sections, include an asterisk (*) between the command and the curly brackets ({}) that enclose the name, as in the following example:

\section*{A Lovely Day}

The chapter titles and section names in this manual are examples of what the report style produces without an asterisk. The LaTeX Manual explains how to have additional levels of section headings in the report and article styles.

LaTeX has the ability to handle footnotes in a wide variety of ways. To produce a footnote, you need to place the following command after the text you wish to footnote:

\footnote{ text }

where text is the text that will be the footnote. There are several different ways to format you footnote. You can number the footnotes or just use symbols. See the LaTeX Manual for more information.

LaTeX has several styles and sizes of type available. The LaTeX Manual provides a complete list. To produce italicized text, type the following:

{\it text}

Replace text with the text you want to be italicized. For example, the command {\it \LaTeX\ Manual} produces the italicized manual title that appears throughout this section.

To produce bold-faced text, type the following:

{\bf  text}

Replace text with the text you want to be bold faced. For example, the {\bf This is bold face.} command produces the following text:

This is bold face.

The following list shows the characters latex has special meanings for (in the left column) and the command you must put in your file to get latex to produce each character (in the right column):

Character
What to type
#
\\#
$
\\$
%
\\%
&
\&
{
\{
}
\}
_
\_ or \$\underline{~}\$
|
$|$ or $\mid$
<
$<$
>
$>$
^
\^{}
~{}
\~{}
\
$\backslash$

Some LaTeX-produced effects

In addition to the effects described above, there are several other effects you can produce using LaTeX commands. These include, among others, lists, pictures, tables, equations, tables of contents, and indices. This manual was created using LaTeX, so you can use LaTeX to produce anything you see in this manual. Refer to the LaTeX Manual to learn how.

How to run LaTeX

The name of a file to be run through LaTeX must end with .tex. To run a file through LaTeX, type the following command:

latex  file

Replace file with the name of the file to be run through LaTeX. For example, to run the file examples.tex through LaTeX, I could type the following command:

latex examples.tex

LaTeX responds by working its way through the file and reporting its progress as it goes. This "report" goes to both the terminal screen and a file called file.log, where file is the name of the file you ran through LaTeX (without the .tex suffix).

If LaTeX finds errors, it reports them as it finds them. If LaTeX generates error messages you don't understand, refer to the LaTeX Manual for explanations.

If LaTeX finds no errors, it generates a file called file.dvi, where file is the name of the file you ran through LaTeX (without the .tex suffix). The .dvi suffix is short for device independent. A dvi file can translated into the many different languages that printers know about. To print your LaTeX documents, see Section See section Printing.

Previewers

Once you have gotten a dvi file, there are a couple of different ways that you can preview the document before printing it out on a laser printer. If you are using an X-Window system there is a program called `xdvi' that will preview your dvi file to your display. There are several options to `xdvi' that allow different magnifications and movement within the document. Read the man page for more information on using `xdvi'.

LaTeX Examples

This section gives a couple of examples on how to prepare files to run through LaTeX, how to run them through LaTeX, and how LaTeX responds.

The following are the contents of a file called `example.tex', which contains the commands that are necessary to run it through LaTeX. Don't let some of the formatting scare you off. Once you get the hang of LaTeX you will be able to produce great looking documents.

\documentstyle{report}
\parskip= 10pt plus2pt minus2pt
\setlength{\parindent}{0in}
\begin{document}
\chapter{Example chapter}
\LaTeX\ is a very powerful system for typesetting all of
your documents. It does such things as tables, pictures,
indices, tables of contents, bibliographies,
footnotes\footnote{See how easy footnotes are.}, and much
much more.

Here is what a table can look like:

\begin{center}
\begin{tabular}{|c|c|} \hline
{\it heading} & {\it heading} \\ \hline \hline
item & item \\  \hline
item & item \\  \hline
\end{tabular}
\end{center}

The math abilities of \LaTeX\ are also {\em very} powerful.
For example:

\begin{displaymath}
\sum_{i=1}^{n} x_{i} = \int_{0}^{1} f
\end{displaymath}

The following shows the command that runs example.tex through LaTeX:

latex example.tex

The following shows how LaTeX responds to this command:

This is TeX, C Version 3.14t3
(example.tex
LaTeX Version 2.09 <14 January 1991>
(/usr/local/lib/tex/inputs/report.sty
Document Style `report' <13 Nov 89>.
(/usr/local/lib/tex/inputs/rep10.sty)
(/usr/local/lib/tex/inputs/titlepage.sty)) (example.aux)
Chapter 1.
[1] (example.aux)
Output written on example.dvi (1 page, 1696 bytes).
Transcript written on example.log.

The next page shows what the file example.dvi looks like when it's printed on a laser printer (note the new page caused by the \chapter command).

Troff

Troff formats text for sending to a phototypesetter or printing on a laser printer.

This section is focused towards the -ms macros. A more complete reference, which is being written, is available in it's current state in See section `Top' in The GNU Troff Manual.

How to learn troff

To learn troff, you should first read this section. It provides a lot of information to help you understand Troff because the manual that describes troff is pretty dense and not very learner-oriented. After reading this section, you can refer to the Unix User's Supplementary Documents (USD) chapters 20 through 25 for additional information.

There are many different types of troff: nroff, troff, ditroff, psroff, groff, and others. They all use the same commands but print to different types of printers or have added features. Nroff is used when you want to print to a low resolution device like a lineprinter. Groff is the GNU implementation of troff, which is used at PSU, and is, thus, used in examples.

How to prepare files for troff

To prepare a file to run through troff, you must include commands that tell troff what to do with the text in the file. This section explains the basic troff commands and some of the effects you can produce using troff.

The most important thing to remember about all troff commands is that they must begin at the left margin. If troff finds a command some place other than the left margin, it thinks the command is normal text and doesn't execute it as a command.

Troff commands allow you to do the following tasks:

The following sections explain how to do these tasks. The last of these sections summarizes these troff commands.

Troff also allows you to define constants and macros and use conditionals and diversions. To learn how to do these tasks, refer to the Unix User's Supplementary Documents (USD) chapters 20 through 25.

Setting margins at top and bottom of pages

To set a margin for the top of a page, include the following in your file:

.nr HM topmargin

Replace topmargin with the size you want the margin to be. For example, to set the top margin to 1.5 inches, include the following command in your file:

.nr HM 1.5i

To set a margin for the bottom of a page, use the same command, but replace `HM' (header margin) with `FM' (footer margin).

Setting type styles

Troff provides three basic type styles: roman, italic, and bold. Troff allows for different type fonts, but they must be mounted on the printer. For further information, contact the system administrator or refer to the Unix User's Supplementary Documents (USD) chapters 20 through 25 and the appropriate printer manuals.

To set a type style, include the following command in your file just before the text you want in that style:

.ft style

Replace style with the type style you want: R for roman, I for italic, or B for bold. For example, if you wanted to italicize a book title in the middle of some roman text, your file would look something like the following:

The book
.ft I
Handbook for Technical Writers
.ft R
is a good reference book for anyone
writing about a technical subject.

This file italicizes the book title Handbook for Technical Writers and then returns to roman type for the rest of the text.

Setting type sizes

Troff also allows for different type sizes: 6, 7, 8, 9, 10, 11, 12, 14, 18, 20, 22, 24, 28, and 36 point. Text is usually around 10 or 11 points. Headings are often around 14 or 18 points. Newspaper headlines often measure about 36 points.

To set a type size, include the following command in your file:

.ps size

Replace size with the type size you want. For example, if you wanted to write a paper and give it a heading that was larger than the text type, you might create a file that looks like this:

.ps 18
.ft B
Going Skiing
.ft R
.ps 11
Going skiing is really fun.  Whenever I have a
chance, I go skiing.  I am planning to go during
spring break.

The commands in this file create a heading that is set in 18-point-high bold type, and then they switch to 11-point-high roman type for the text. These styles and sizes are about equivalent to the chapter titles and text in this manual.

Setting amount of space between lines

Troff allows you to set the spacing between lines in inches or in terms of single- and double-spacing on a typewriter. To set the amount of space between lines, include the following in your file:

`.sp spacing'

Replace spacing with the amount of spacing you want. For example, to set the space between lines to 1.5 inches, include the following:

`.sp 1.5i'

To set the space between lines to be like a typewriter's double spacing, include the following:

`.sp 2'

As with other troff commands, once you set the line spacing it stays the way you set it until you change it to something else.

Setting line lengths

The default line length in troff is 6.5 inches. Troff allows you to change the line length by including the following in your file:

.ll length

Replace length with the line length you want. For example, to set the line length to 5 inches, you'd include the following command in your file:

.ll 5i

Setting tabs

Troff allows you to set tabs by using the .ta command as follows:

.ta tab1 tab2

The desired tabs replace tab1 and tab2. For example, to set tabs at one-half inch, one inch, and four inches, you'd include the following command in your file:

`.ta 0.5i 1i 4i'

Indenting text

Troff provides two ways to indent text. The first is for indenting the first line of paragraphs, and the second is for indenting examples, lists, and similar information.

To indent the first line of paragraphs, include the following command in your file immediately before each paragraph that is to be indented:

`.PP'

A file whose paragraph's first lines were to be indented might look like this:

.PP
Once upon a time, a long time ago, there was a
little girl named Goldilocks.  She lived near
a big forest that was full of wonderful trails.
.PP
One day, Goldilocks went for a very long walk on
one of the trails.  Pretty soon, she came upon
a lovely house in a clearing.

The first line of each paragraph, starting with "Once" and "One" will be indented.

To indent examples, lists, etc., include the following command in your file directly before the text that is to be indented:

.in indentation

Replace indentation with the amount you want the left margin to be indented. For example, if you had an example you wanted to indent, like the Goldilocks example, your file would look something like this:

.in 0.5i
.PP
Once upon a time, a long time ago, there was a
little girl named Goldilocks.  She lived near
a big forest that was full of wonderful trails.
.PP
One day, Goldilocks went for a very long walk on
one of the trails.  Pretty soon, she came upon
a lovely house in a clearing.

The left margin in this example would stay indented one-half inch until you included a second indent command to set it back to zero.

Making labelled lists

Troff allows you to make paragraphs that have a label in the left margin by including only one command, .IP. To use .IP, include it in your file as follows:

.IP label

Replace label with the label that is to go in the margin. For example, if you wanted to create a paragraph and give it a label called "Weather," your file would look like this:

.IP Weather
This is a nice day.  We could have been outside
having a fun time.  But probably by the time
we get outside it will be raining.

This file produces the following output:

Weather
This is a nice day. We could have been outside having a fun time. But probably by the time we get outside it will be raining.

Troff command summary

The following list shows the troff commands discussed in this chapter (in the left column) and what each command does (in the right column).

.nr HM topmargin
set top margin to topmargin
.nr FM bottommargin
set bottom margin to bottommargin
.ft style
make type font style; style can be R, I, or B
.ps size
set type size equal to size
.sp spacing
set line spacing to spacing
.ll length
set line lengths to length
.ta tab1 tab2
set tabs at tab1 and tab2
.PP
indent first line of next paragraph
.in indentation
indent all subsequent text by the amount in indentation
.IP label
indent the left margin of the next paragraph and
put label to the left of the paragraph

How to run troff

To run a file through troff and send its output to a file, type the following command:

groff -ms inputfile > troffoutputfile

Replace inputfile with the name of the file to be run through troff. Replace troffoutputfile with the name of the new file you want to receive troff's output.

For example, to run a file called ch9 through troff and send its output to a file called ch9.out, you would type the following command:

groff -ms ch9 > ch9.out

Example

The following are the contents of a file called graduate, which contains the commands that cause troff to format the output:

.nr HM 2i
.ps 24
.ft B
How Happy I Am To Be Graduating
(example)
.ft R
.ps 11
.sp 0.5i
This report describes how happy I am to be graduating this term.
.sp 0.25i
.ft B
Sing
.sp 0.25i
.ft R
I'm so happy, I could
.ft I
sing!
.sp 0.25i
.ft B
Dance
.sp 0.25i
.ft R
I'm so happy, I could
.ft I
dance!
.sp 0.25i
.ft B
Smile
.sp 0.25i
.ft R
I'm so happy, I could
.ft I
SMILE ALL THE TIME !
.nr FM 2.5i

Texinfo

Texinfo is the GNU document formatting system. This document was produced using Texinfo. For further information See section `Top' in The Texinfo Manual.

Printing

This chapter explains how to print files, and how to get your printouts. It will explain how to print text files, DVI files (produced by TeX, LaTeX, or groff), PostScript files, and images (gif, rle, pbm). Do not send binary files to the printers! The printers cannot print binary files, and get very confused when sent on

Lpr, lpq, lprm

On the CS systems we use the Berkeley printer spooling package. There is an alternate package used on SysV machines, it is not in use, and, thus, will not be discussed.

By default, they all operate on the default printer (`lp'), a different printer can be used by using the `-Pprinter-name' argument. Alternately, the environment variable PRINTER may be set to your preferred printer.

lpr

The command for printing a file to a printer is lpr. To print a file called `foo' to the default printer (lp1 on most machines):

lpr foo

If you want to print the file to a different printer, say `lw3', use

lpr -Plw3 foo

The general syntax is lpr -Pprinter file where printer is one of the valid printers on our machines. A list of printers is shown in See section Printers in the CS Department.

If you normally print to a different printer than the default, you can take advantage of the environment variable PRINTER. For instance, if you normally print to the lw3 printer, you can type the following line:

setenv PRINTER lw3

and from now until you log out, your default printer will be lw3. Therefore, when you use lpr without the -P option, it will send the file to the `lw3' printer. Of course, you can still use -Pprinter to make it go to a different printer.

If you put the above line in your .cshrc, it will set your default printer every time you log in, so you won't have to type it each time. lpr, lpq, and lprm all use the PRINTER variable.

lpq

The command for examining the printer queue (or spool) is lpq. To display the queue of the default printer type lpq and you will see something like this:

lp is ready and printing
Rank   Owner      Job  Files                                 Total Size
active trent      971  standard input                        89471 bytes
1st    alsam      771  standard input                        16851 bytes
2nd    trent      973  standard input                        35393 bytes
3rd    hsin       466  standard input                        1233 bytes
4th    trent      975  standard input                        38179 bytes
5th    trent      978  standard input                        11381 bytes
6th    lynnette   461  Newsout                               2426 bytes

For a different printer, the -P option, as in lpr, can be used. For instance, to see what jobs are waiting for the `lw3' printer, use lpq -Plw3.

lprm

The command for removing a job from the printer spool is lprm. If your job is currently printing and you wish to stop it, you can use the lprm with no arguments.

NOTE: removing the currently printing job can mess up some printers, notify the Tutors or Sysgroup if you need to do this.

To remove a specific job, you will need to use lpq to get the job number, and then use the job number as an argument to lprm. Assuming the queue shown in section lpq, the following command would remove `lynnette''s print job.

lprm 461

The argument `-' will remove all jobs that you own.

As with lpr and lpq you can specify a printer with the `-P' option.

Printing text files

line printers

All line printers have names starting with `lp'. In most situations, to print an ASCII file, the following command is used:

lpr -Pprinter filename

Files with backspace sequences (i.e. typescripts) should not be sent directly to a line printer. To eliminate these sequences, filter your file through col:

cat file | col -b | lpr

If tabs do not appear right on the printer use expand to turn them into spaces.

cat file | expand | lpr

PostScript printers for text files

To print text files to a PostScript printer, the file must first be converted to PostScript. Most of our spoolers will automatically convert text sent to them to PostScript, but it is not a good idea to count on this feature. We have two different programs to convert text to PostScript, each with their advantages and disadvantages, and different options. When run without options, all of them will produce acceptable output, but you may wish to use the options to get output which is more suitable to you.

enscript
This is part of Adobe's Transcript package, which can print 1 or 2 pages per sheet, and can do fancy headers.
mpage
Prints muliple pages per sheet (1, 2, 4, or 8).

Examples of use:

enscript -2rG -Plw2 foo
mpage -8 -Plw3 baz

Printing DVI files

DVI files are generated by the TeX, LaTeX, and groff programs. DVI stands for device independent, which means one must convert a DVI file to whatever format the output device will use.

line printers for DVI files

There is no program which can produce acceptable ASCII output from a DVI file. The program dvitty attempts to do this, but falls quite short. We do not support this program.

PostScript printers for DVI files

The dvips program is the DVI to PostScript program we are supporting on all our machines. dvips supports a multitude of options, and is highly configurable. For a complete overview, see the dvips manual.

In these examples, we will assume the file `foo.dvi' is to be printed.

Normally, you use dvips to convert the DVI file into PostScript and then lpr the result:

dvips -o foo.ps foo.dvi
lpr -Plw3 foo.ps

Printing PostScript files

line printers

To send a PostScript file to a line printer, you can use lpr. The text of the PostScript code will be printed out. This is usually not what you want, as PostScript source code tends to be quite long (possibly hundreds of pages).

PostScript printers

To send a PostScript file to a PostScript printer, you can use lpr in the standard fashion. This printer should be a PostScript printer, and the file should begin with the characters `%!'. To print file.ps, use:

lpr file.ps

Printing Images

To print image files, you must convert them into PostScript and then send them to the printer. The only packages which are capable of this are unsupported.

Printer Quotas

This section applies primarily to printers which have quotas installed (See section Printers in the CS Department, for more info). On any printer with quotas, copies must be either paid for or pre-authorized.

The policy is as follows:

The procedure for getting/buying copies on a quota'ed printer is as follows:

There are two programs for manipulating printer quotas: lwquot, and lwaddquot. These programs are rudimentary, and will be replaced with a more elaborate system.

The lwquot command will display a user's current allowance on a printer. Notice that it prints the totals; subtract the two numbers to find out how many more copies the user has. If no username is given, `$USER' is used.

% lwquot glatz
75 pages allowed
15 pages used

Printer Specific Features

The CS Department's new HPIIIsi, and EE's existing HPIIId, laser printer have two features which can be accessed from the various printing programs.

The first feature is duplex (or double-sided) printing. A component of this is a feature called tumbling, which involves rotating the second side 180 degrees. This is used when for output which is rotated (landscape mode). `lw2' is set to print duplex by default.

The second feature is the ability to select paper trays. By default, the printer will use the upper paper tray, the lower tray may contain special paper (i.e. letterhead). We do not (yet) have an envelope feeder tray.

All of the options may be selected by post-processing your postscript code with the program psmod. Read the man page for full information.

What follows are examples of how to use psmod with most applications. Only the necessary options are shown.

enscript -p- file | psmod | lpr -Pprinter
mpage -P file | psmod | lpr -Pprinter
groff file | psmod | lpr -Pprinter
psroff -t file | psmod | lpr -Pprinter
dvips -f file.dvi | psmod | lpr -Pprinter
psmod file.ps | lpr -Pprinter

If you want to manually add these options to a PostScript file, You can use psmod to tell you what to add to the file. The following command will print out the necessary PostScript code.

echo %! | psmod

With groff and TeX, these printer options may be selected within your document. This may be useful if you want to change options on the fly.

In groff the local macro package `-mhp' supplies macros for changing these printer options. To select duplex mode use the `.duplex-mode' macro. An argument of `tumble' can be given to to that macro turn on tumbling. From the command line, the argument of `-dduplex=1' will enable duplex printing, and `-dtumble=1' will enable tumbling. To select a certain paper tray use the `.papertray' macro, with an argument of `lower', `upper' or `envelope'. From the command line, the argument of `-dtray=tray-name' will select the corresponding paper tray.

For TeX, there is a local set of macros in `/usr/local/lib/tex/inputs/local/hp.sty' which can activate the printers special features.

Printers in the CS Department

The most up-to-date listing of printers is available in `/etc/printcap', this listing is correct as of Sept-93

lpcs (lp on CS machines)
Fujitsu M3041R (band printer), Located in CS Terminal Room (MSB 120)

lpee
Printronix P300 (dot matrix), located in the EE CAD Lab.

lpmsb
Printronix P300 (dot matrix), located in Mill Street Building.

lw1:
HP LaserJet IIId with a PostScript Cartridge, located in the EE office (PCAT 102)

lw2
HP LaserJet IIIsi w/ PostScript Cartridge, located in the CS office (PCAT 120). For Faculty use only.

lw3
HP LaserJet III w/ PostScript Cartridge, located in the CS Terminal room (MSB 120) This printer has quotas, See section Printer Quotas, for more info.

lw4
HP LaserJet III w/ PostScript Cartridge, located in EE CAD Lab. This printer has quotas, See section Printer Quotas, for more info.

lw5
HP LaserJet III w/ PostScript Cartridge, located in Mill Street Building This printer has quotas, See section Printer Quotas, for more info.

lw6
HP LaserJet III w/ PostScript Cartridge, located in SEAS Annex Building This printer has quotas, See section Printer Quotas, for more info.

csappletalk
Apple LaserWriter+, located in the CS office (PCAT 120). This printer is connected to the AppleTalk network, the software to spool jobs to it is unreliable, and, thus, unsupported.

eeappletalk
Apple LaserWriter+, located in the EE office (PCAT 102). This printer is connected to the AppleTalk network, the software to spool jobs to it is unreliable, and, thus, unsupported.

Using UNIX Systems Efficiently

Commonly people think of computer resources as unlimited, especially in the case of powerful multi-user systems. But in fact, all computer resources are limited. UNIX does a good job of sharing resources among multiple users under a changing work load, but you can help get the most out of the physical UNIX machines by using these resources wisely.

This chapter explains several ways that you can use UNIX resources efficiently.

The publications listed in section Books, provide further information on the techniques described in this chapter. They also provide additional techniques for using UNIX efficiently.

UNIX Shells and Varieties

Many shells are available on the Computer Science Department's UNIX systems, most of them derive from either the Bourne shell (sh) or the C shell (csh). Each of these shells has spawned other shells that have improved features. The Bourne Shell has spawned the Korn Shell (ksh). The C shell has spawned tcsh. The Born Again Shell (bash) is an alternative replacement for sh which implements features of ksh and csh plus others.

The books listed in section Books and the man pages explained in section Man Command explain these shells in detail. Documentation for bash is available in See section `Top' in Bash Manual.

When using UNIX systems around PSU, you are typically using one of the following UNIX varieties:

Each of these versions of UNIX evolved from the original UNIX developed by AT&T in the mid-seventies.

After creating the original UNIX, AT&T developed two notable experimental varieties in the late seventies: Version 6 in 1975, and Version 7 in 1978. From these experimental varieties, two major stems developed in the early eighties: Berkeley and System III.

The publications listed in Section See section Books provide more information on UNIX varieties and their history.

You need to know is which UNIX variety is on the computer you're using. With this knowledge, you can tell which UNIX utilities are available to you and which are not.

Customizing Your Environment

Each time you log in, your log-in files are executed. These files establish your particular computing environment for that session, and may be modified to suit your personal needs. The login files will, for example, assign certain functions to specific keys -- like the erase function is assigned to the BS (backspace) key -- or determine where commands will be found on the system. They determine what abbreviations you can use and what characteristics your terminal has. These files are called `.login' and `.cshrc' if your login shell is csh, and `.profile' if your login shell is sh. Each of the different shells might have specific initialization files. You should check the man pages on the specific shell to get the specific information.

You can find your login shell by saying: finger login_name

You can set your own abbreviations and terminal characteristics by using the alias and stty commands. You put these commands in your log-in files using an editor. Once you've modified your log-in files, your settings will be set in place every time you log in. Be careful--mistakes can make it possible that you can't login again.

The default shell that the system comes with here at PSU is C-shell. To change your default shell you need to run the program chsh. To learn how to use the chsh program refer to the man page of chsh. To get help using the man command, section Man Command.

Setting abbreviations

You can set abbreviations for use in csh using the alias command. To use the alias command, include the following in your `.cshrc' file:

alias abbrev fullcommand

For example, suppose you find yourself frequently typing ls -Fas.

You can set up an alias dir for this command by including the following in your `.cshrc' file:

alias dir "ls -Fas"

Adding this command to your `.cshrc' file causes the dir command to exist for you every time you log in. Thereafter, whenever you type dir, UNIX will act exactly as though you had typed ls -Fas.

Setting terminal characteristics

You can set terminal characteristics using the stty command. The stty command is complicated, with many options, but once you get it to set the terminal characteristics you like, you can put it in your `.login' file and you'll never see it again. You can see all of your settings by saying: stty everything or on System V machines stty -a.

For example, many UNIX systems use the backspace key to erase characters. If you're used to Digital Equipment Corporation (DEC) systems, you're probably accustomed to using the delete key for this purpose. The stty command has an option called dec, shown below, that causes the delete key to erase characters.

stty dec

Including this command in your `.login' file makes your terminal act like it's on a DEC system every time you log in. To learn about other stty command options, refer to the man pages described in section Man Command, or the publications listed in section Books.

If you are using an X window system and you change the size of the window, the window will need to be resized. You can do this by saying: set noglob; eval `resize`

Changing Your Password

The Computer Science Department recommends that you change your password often, at least once a quarter. You should become familiar with the procedure described in this section. The following guidelines should be followed when selecting a password. The new password must be at least six characters long and should contain a random number. Avoid joes (i.e. any variation of your own name) and any other easy to guess words. WARNING: if you do not use a secure password (i.e. we in the CS Department are able to crack it) you may lose your machine privileges. Security of our systems depends on your password, and we are very security conscious. To change your password, issue the following command:

passwd

The system responds by prompting you for your current password to verify that you are authorized to make such a change. Then it asks you for the new password. On most systems, your password will be checked to make sure it is not easy to guess, if it is, it will ask you for a better password. After you enter the new password, it prompts you for it again. If the two inputs are identical, your password is changed. If they differ (if you made a typing mistake, for example) your password is not changed. This prevents you from mis-typing a password that you then could not use.

Re-executing Commands and Completing Commands

This section explains two ways to decrease the amount of time you spend at a terminal. The first one, re-executing commands, allows you to find out which commands you've entered since you logged in and to re-execute any one of them. The second one, completing filenames, allows you to type a portion of a file name and have UNIX return all the file names that contain that portion.

Re-executing commands

The UNIX C shell provides a mechanism that allows you to recall previous commands and re-execute them. To see what commands UNIX has saved during your login, use the history command.

UNIX responds with a display similar to the following:

1  mail
2  finger
3  cd assign1
4  ls -F
5  more try1.c
6  grep bitsearch try1.c
7  cd
8  ls *.h
9  cp myheader.h assign1
10 pwd
11 cd assign1
12 vi try1.c
13 cc -o try1 try1.c
14 lint try1.c

Knowing which commands you've entered, you can re-execute any of them using one of several methods. You can re-execute the most recent command, you can re-execute a command by specifying its number or a fragment of its name, or you can add to a command and then re-execute it.

There are also more sophisticated methods for re-executing pieces of previous commands. They are described in section The C shell and in the csh man page. In general, program development time can be decreased simply by re-executing compile and edit commands.

To re-execute the last command you entered, type !!. The following example shows this command and how UNIX responds:

rigel% !!
lint try1.c
output from lint

To re-execute a command by specifying its number, type !number where number is the command number. For example (look at the history example above)

rigel% !8
ls *.h

To re-execute a command by specifying its name or a fragment of its name, type !name where name is the name or name fragment. For instance:

rigel% !more
more try1.c

To add to a command and then re-execute it, use one of the preceding methods but don't type a carriage return, and then, on the same command line, type what you want to add to the command. The following example shows the lint command being re-executed with "| less" added to it:

rigel% !lint | less
lint try1.c | less

For even faster program development, combine history with job control. See section Controlling Jobs, for more info.

Completing commands

UNIX provides another way to minimize key strokes called command completion. It allows you to type the first letter or letters of a file name followed by the esc key and have UNIX return the only file name that matches the letter or letters you typed. This feature is supported by some csh's, bash, tcsh, and ksh. If more than one file name matches, the shell will wait for more letters. Command completion also allows you to type the first letter or letters of a file name and then type ctrl-d (for csh's), causing UNIX to return all the file names that match the letters.

To use it on BSD systems, your `.cshrc' login file must include the command that makes the esc key and ctrl-d work. To include this command if it's not already in your `.cshrc' file, do the following. Invoke an editor and bring up your `.cshrc' file. Move to the end of the file, and insert the following line:

set filec

Then save the file and leave the editor. File completion is not available under DYNIX unless you use the bash shell.

The man pages described in section Man Command have a page called csh that contains additional information on completing filenames. To find this information, call up that man page and then search for the pattern `complete'.

Controlling Jobs

When you're running a program at your terminal, sometimes it takes longer to complete than you had expected. BSD UNIX, DYNIX, and SunOS provide tools to deal with this problem. These tools are collectively known as job control.

One job-control tool lets you suspend a program that is taking a long time to execute. When you suspend a program, it stops running and frees your terminal for other work. Another job control tool allows you to continue running the program in the background, causing the program to continue running detached from your terminal. Using a third job control tool, you can return the job to the foreground at any time.

Suspending jobs

To suspend a job, type ctrl-z. When you do this, the job stops running and waits for you to start it again as described below or to kill it using the kill command. (Be sure to cancel any suspended jobs you don't want using the kill command described in section Job Control before you log out.)

Running jobs in the background

To run a job in the background, type an ampersand (&) at the end of the command line that starts that job, or type the following after you've started and then suspended the job: bg.

After putting a job in the background, you can check its progress by typing the command jobs.

UNIX responds to this command by listing all the jobs that have been suspended during the current terminal session. This display looks similar to the following:

[1] + Running
cc -o myprogram myprogram.c
[2] + Stopped (tty input) otherprogram

UNIX will subsequently notify you when a job that's running in the background stops running.

Running jobs in the foreground

To run a job in the foreground, type the following: fg

Running several jobs at once

Using job control, you can have several jobs running at once. Only one job can be in the foreground at one time, but any number can be in the background. Background jobs can remain stopped or idle until you return them to the foreground, or they can be made to continue running concurrently in the background.

Background jobs that require terminal input will automatically stop running and wait until you move them to the foreground. You should keep a highly interactive program in the foreground and put slower, compute-bound programs in the background. You can also use job control to switch among several active jobs as they move from computation to interactive dialog.

A common use of job control, especially during program development, is to switch between the editor and the compiler. Suspending and continuing an editor is faster than running it every time. The speed increase is best if you edit large files or you switch back and forth between files frequently. As an added convenience, this puts you back into your file where you last were editing. You may find that you like this feature so much that you edit several files at once, using ctrl-z to suspend one editing session and the fg command to continue another one.

You will need to know how to specify which job to continue. If you don't specify a particular job, fg or bg continues the last job you suspended. This won't always be the job you want. To find out what jobs you have running or suspended, use the jobs command. The number listed next to each job is the number you specify with fg or bg to continue that job in the foreground or background. Consider the following example:

[1]  Stopped  vi myprogram.c
[2]  Stopped  vi myotherprogram.c
[3]  Stopped  vi yetanother.c
[4]  Stopped  cc canonical.c

In this example, the user wants to continue compiling the C program `canonical.c' in the background and resume editing `myotherprogram.c' in the foreground. To find out which jobs he has suspended, he types the jobs command. It lists each suspended job with an identifying number. He puts the compile job (#4) in the background using the bg command, and then he uses the jobs command to verify that it's running. He then brings the edit job (#2) to the foreground using the fg command.

A useful hint: you can use the following procedure to switch back and forth between a compile job and an edit job. Use your editor to write out your changes to a source file, and then type ctrl-z to suspend the editor. Then run the compiler and direct its error messages to a listing file. Then switch between editing your source file and reading the listing file, trying to fix as many errors in your source file as you can after each compile.

Remember, the compiler compiles the disk file, not the copy the editor has in its memory, so be sure to write out your file before you suspend the editor. Similarly, when you go back to editing your file, be sure to continue your suspended editing session. Don't start another editing session every time you want to return to your file! If you're not sure if you suspended or exited the editor, use the jobs command to show your suspended jobs.

Example of controlling jobs

The following example shows how to suspend a job, run it in the background, check its status, and do something else while waiting for UNIX to say the job running in the background is finished.

rigel% cc -o myprogram myprogram.c
ctrl-Z
Stopped
rigel% bg
[1] cc -o myprogram myprogram.c
rigel% jobs
[1] + Running  cc -o myprogram myprogram.c
rigel% lpq
no entries
[1] + Done quad cc -o myprogram myprogram.c
rigel% ls -F
myprogam*  myprogram.c  test-data

In this example, a user uses the cc command to compile a C program that's in a file named `myprogram.c'. The user decides that the compile job is taking too long and that she wants to have the terminal back while the job completes, so she types ctrl-Z to suspend the job. Because she wants the job to continue in the background, she types the bg command. She then types the jobs command to make sure the job is running. Then she does other work while the job continues running in the background, and UNIX notifies her when her job has finished running.

If compiling this program always takes a long time, it would make sense for the user to run it as a background job in the first place. The following example shows how to do this and then check to see that the job is running.

rigel% cc -o myprogram myprogram.c &
[1] 1962
rigel% jobs
[1] + Running  cc -o myprogram myprogram.c

Maximizing Response Time

UNIX is a multi-user, multi-tasking environment. You share computer resources with other users. You can help keep the environment responsive to yourself and other users by using its resources wisely. Wasted resources serve nobody, and contention during periods of peak usage can degrade response time to the point where nobody gets any useful work done.

Running jobs at low priority

A specific UNIX command that lets you run your background jobs (See section Running jobs in the background) at low priority is the nice command. It helps prevent compute-bound applications from slowing down interactive use of the computer. This includes your own interactive use in the foreground. nice accepts priority numbers from 1 to 20, where higher numbers mean lower priority. For example, to execute a program called number-cruncher at low priority in the background, you could type nice +20 number-cruncher &

Enter the nice command this way when you're in the C shell. When you're in the Bourne shell, enter it the same way except replace the plus (+) before the 20 with a minus (-). Note that there are 4 different forms of nice.

Running jobs during low-use times

Another strategy for using processor resources wisely is spreading the load -- performing work outside of periods of peak usage. The w and uptime commands list load averages.

These commands return three numbers which describe cpu usage averaged over the last 1, 5, and 15 minutes. If you see high load averages, consider logging out and doing other work for awhile. You will enjoy better response when the load averages come down, and you will help the current users get their work done faster.

Some systems have the batch command. It allows you to submit jobs into a queue which then gets run serially. This is a useful way to limit CPU bound programs. Sometimes the at command can be used to postpone work until later.

You will find that periods of peak usage are cyclic, peaking every day in the afternoons and evenings, and during the academic year just before due dates for computer assignments. If you wait until the system is heavily loaded, you won't have much choice of when to do your work. Do your work early.

You might want to put the uptime command in your `.login' file.

Using Disk Space Efficiently

Although current disk drives afford each user ample storage for ordinary needs, disk space is finite. Your files count against the total disk space available for anyone's use. UNIX provides tools that let you limit your permanent storage to what you really need.

These tools include the du command, which tells you how much space you're using, the piping utility, which reduces the need for temporary files, and a hierarchical file system, which makes it easy to organize your files.

Another way to use disk space efficiently is to delete all files you don't need.

Using the du command

To use the du command, type the following: (this sorts usage in reverse numerical order)

du | sort -rn | more

UNIX responds by giving you a number that is the amount of disk space you're using, in kilobytes. Some systems give this number in 512 blocks, instead of K.

Using the UNIX file system

UNIX's hierarchical file system is one of its strengths. You should utilize this system placing no more than 30 or 40 files in any one directory. This will actually decrease disk storage, because you won't be afraid to delete a file when you know what's in it. In addition, it will increase the speed at which the computer can find a specified file.

Deleting files

Another way to conserve disk space is to not save files because you "might need them someday." If you want to keep them indefinitely, download them to a micro and keep them on your own floppy disk, or write them to tape or floppy disc That way, you'll have your own copy even when your account expires, and you can always upload them when you want them on line again. If you think it takes too long or costs too much to do this, reconsider how much keeping the file around indefinitely is worth to you.

You can also use any of the following methods to help you delete files:

Compressing files

compress uses Lempel-Ziv-Welsh coding for compressing files. Most files can be compressed to half of their original size thus saving on disk space. You should compress any files that you do not use frequently as this will help keep from going over your disk space limits. compress is executed as follows, with filename being replaced with the name of the file (or files) to be compressed.

compress filename

The compressed file is stored under the name `filename.Z'. The `.Z' extension on the filename lets you know that this is a compressed file. Remember that any compressed file must be treated as a binary file for purposes of file transfer.

In order to uncompress a file, use the uncompress command. The resulting uncompressed file will be without the `.Z' extension.

uncompress filename.Z

You can use the command zcat to look at a compressed file without uncompressing it. A typical way to look at a compressed text file is as follows:

zcat filename | more

How not to print

UNIX provides tools such as screen editors, I/O redirection, piping, and the on-line documentation systems that reduce the need for printing files. One of the biggest savers is the various previewers (for groff, TeX and PostScript) available.

You can help reduce turnaround time for printouts by printing only when hard-copy output is necessary and by not printing duplicate copies of files. Printing each version of a program and duplicates of files is counterproductive; you'll spend as much time tracking which piece of paper matches which file as you gain any other way. With good use of editors, window systems, and other tools you may never need a print out. Many homework assignments are both distributed and turned in electronically by mail or news now.

Input / Output Redirecting and Piping

Most commands get their input from standard input, which is usually the terminal, and send their output to standard output, which is also usually the terminal. Errors go to standard error. I/O redirection and piping allow you to specify otherwise.

I/O redirection lets you tell a command to read its input from a file, write its output to a file, or both. Piping allows you to tell a command to read its input from another command's output or even to read its input from the output of a string of several commands.

For example, let's assume you want to compute the wages earned by all professors in the College of Business during the past five years. The program you are using will read in data one line at a time. You could process the information line by line, typing in each piece of data each time the program asked for it, or you could do it much more quickly by using input output redirection. Your command line would look something like this:

program  < datafile > resultsfile

With input output redirection, you would simply need to create a `datafile', and then look at the `resultsfile'.

If your data needs to be processed by several programs, you can use piping to save quite a bit of time.

cat datafile | program1 | program2 | program3  > resultsfile

In this case, data is taken from `datafile', processed by program1 which passes it on to program2 which process it farther and passes it on to program3 which processes it and placed it into resultsfile.

Redirecting Input / Output

Redirecting input

To get input for a UNIX command from a file instead of the terminal, enter the command as follows:

command options arguments < inputfile

Replace command, options and arguments with the full command as you would normally enter it. Replace inputfile with the file from which the command is to get its input.

For example, to execute the program myprog and have it draw its input from the file myinput, you'd type the following:

myprog < myinput

Redirecting output

To send the output generated by a UNIX command to a file rather than to the terminal, enter the command as follows:

command options argument > outputfile

Replace command, options, and argument with the full command as you would normally enter it. Replace outputfile with the file to which the command is to send its output.

For example, consider the grep command, which is used to search a file for a string and write all the lines that contain that string to the standard output device. In the following example, the grep command searches the file `myprog.c' for the string `counter' and prints all the lines that contain counter at the terminal:

grep counter myprog.c

The grep command could also be used to place all the lines that contain `counter' in a file called `counter-matches' instead. The following example shows how grep would do that if you redirected its output to `counter-matches':

grep counter myprog.c > counter-matches

You could then manipulate counter-matches as you would any other file.

Piping

Piping is used in one of the following ways: to tell a command to read its input from another command's output, or to tell each command in a string of commands to get its input from the output of the last command.

Getting input from another command

To tell a command to get its input from another command, type the following:

anothercommand | command

Replace anothercommand with the command that is to generate the output, and replace command with the command that is to get the output. (Note that the `|' symbol is usually found on the far right side of the keyboard.)

A common way to use piping is with the more command, which causes its input to print at the terminal one screenful at a time. For example, the following command causes the output of the grep command to go to the more command, which prints grep's output at the terminal one screenful at a time:

grep counter myprog.c | more

While the grep command is executing, grep's standard output feeds into more's standard input, and more's output goes to its standard output, which in this case is the terminal.

Getting input from a string of commands

To tell each command in a string of commands to get its input from the command before it, type the following:

firstcommand | secondcommand | lastcommand

Replace lastcommand with the command that is to get its input from secondcommand, and replace secondcommand with the command that is to get its input from firstcommand.

The following example runs the program myprog and sends its output to the grep command. It then causes the grep command to look for all occurrences of the string `counter' in myprog's output and sends the grep command's output (all the lines of myprog that contain the counter string) to the more command. The more command then sends the grep command's output to the terminal screen (which is the more command's standard output).

myprog | grep counter | more

Combining Input / Output redirection and piping

By now, you should begin to see the power of piping and I/O redirection. They provide a highly general way to put together simple commands to perform complex operations.

Programming languages that run under UNIX are usually integrated into this system. Thus if you write an ordinary user program that reads and writes to your terminal, you can tell it to read from a file and write to a file instead. This can save you a lot of time writing and debugging your programs.

For example, suppose you have inserted debugging statements into your code which write out the values of variables at various points in the program. You now find that your program writes so much output that it scrolls off the screen too quickly. You can pipe your program's output through more by typing the following:

myprog | more

Or suppose your program (myprog) prompts you for input at your terminal and you discover a bug that occurs well into the program. When trying to debug the program, you might find that it takes a long time to get to the point where the error occurs. You can tell your program to read its input from a prepared file called input-file instead of your terminal by typing the following:

myprog < input-file

You could combine these steps by using both piping and I/O redirection as follows:

myprog < input-file | more

If you still find you're wading through too much output that's unrelated to the bug, you could search through your program's output for a specific error message that includes the string `uninitialized' as follows:

myprog < input-file | grep uninitialized | more

Exceptions

Unfortunately, not all UNIX commands can have their input or output redirected. As noted before, UNIX commands read from standard input, which is usually the terminal, and write to standard output, which is also usually the terminal. When you specify I/O redirection or piping, the UNIX shell redefines standard input and output for each command to be files or other commands as you specify. The problem is that not all commands use standard input and output.

Some UNIX commands write error output to standard error. Output that goes to standard error can be redirected just like output that goes to standard output. (Note) csh and sh handle standard error redirection slightly differently, csh is explained here)

A notable example is the output of the C compiler that is executed by typing the cc command. If you type the following command, more won't get any input, because the cc command's output will go to standard error:

cc myprog.c | more

To overcome this problem, add an ampersand (`&') after the vertical bar (`|'), as in the following example:

cc myprog.c |& more

Similarly, if you want to send the cc command's output to a file called `error-file', place an ampersand after the right arrow (`>') as in the following example:

cc myprog.c >& error-file

Some commands like vi must talk to the terminal and simply fail under I/O redirection.

The C shell

  1. Use file completion when possible. When you have a filename partially typed in, esc will cause the machine to finish the filename for you if it unique, and beep if it is not.

    On most machines (except DYNIX), file completion can be turned on by typing: set filec.

    On some systems, file completion can be turned on by typing: set complete

    On machines which do not have file completion in the C shell, you will need to use an alternative shell like bash.

  2. Use file listing. When you have a command/filename partially typed in, typing: ctrl-d

    Will cause the machine to list all the commands/files which could complete the string you have typed in.

  3. Additional features Here is a list of additional C shell features; this list is not exhaustive. For a more in-depth treatment, see the man page on the C shell.

Special Characters

;
separates commands on a single line
&
execute command in the background
&&
execute following command only if previous command returned a zero value (i.e. it was successful)
||
execute following command only if previous command returned a non-zero value (i.e. it failed)
'....'
single quotes; treat enclosed characters literally
"...."
double quotes treat enclosed characters literally but perform variable and history substitutions
`....`
back quotes; execute enclosed characters as a command and substitute output
.
refers to current directory
..
refers to parent of this directory

Input/Output

<
redirect output to a file
>
redirect output to a file
>&
redirect output and error messages to a file
>!
redirect output to a file; overwrite the file if it already exists
>>
same as >, but add to the end of file if it exists
>>!
same as >>, but create the file if it doesn't exist
<<word
read following lines as standard input until a line containing only word is read
|
pipe output to next command
|&
pipe output and error messages to next command

Character Matching

?
match with any single character
*
match with any string of characters (including none). Does not match a period, however.

Special Variables

completion
filec
allows automatic filename completion (on some systems)
cwd
full pathname of current working directory
list
allows listing of matching files with ctrl-d (on some systems)
path
PATH
search-path for commands
prompt
prompt string printed when shell is waiting for input

Job Control

bg job
put the current or specified job in the background
fg job
put the current or specified job in the foreground
job
put the specified job in the foreground
jobs
list active jobs
kill job
kill the current or specified job
ctrl-z
suspend the foreground job

Aliases

alias
list all aliases
alias name
lists the alias for name
alias abbrev full
assigns abbrev as an alias for full
unalias pattern
discards all aliases matching pattern

Restoring Deleted Files

UNIX files are backed up to tape daily and can be restored from tape to disk if necessary. This is a time consuming process which may take up to 24 hours. You can request that it be restored by sending mail to `sysgroup'. The backup system is not designed to be a guarantee of protection, but to give a good chance of recovering from a disaster. A best effort attempt will be made to restore the file.

Make sure that you don't have another file saved with the same name as the file being restored. If you do, the restored file will overwrite it.

If the file that you deleted was on-line for at least 24 contiguous hours sometime during the previous week, your chances for restoration are pretty good. If the file was on-line for less than 24 contiguous hours, or was deleted more than one week before you request restoration, the chances that it can be restored drops considerably. We only keep daily tapes for a week and weekly tapes for a month. This means that a file that existed for a day between two old weekly tapes will not be saved on tape.

If you have data on a different tape that originated from a different place, you can have the files on the tape restored to your home directory on any machine in the CS Department. You should send mail to `sysgroup' and drop off your tape in PCAT 144. The tape must be a magnetic tape (800, 1600, or 6250), Sun cartridge, HP cartridge, or Exabyte tape. The files must be in one of the following formats: tar, ansi-labelled, dd, cpio, or dump. Describe in your mail message to backup what the format of the tape is and where you want the data stored.

Backing Up Files On Tape

There are a number of ways to back up your files onto some sort of secondary media. If you have a PC or Mac, you can transfer your data to floppies. Otherwise you can use the following method. Other methods are available via special arrangement with Sysgroup.

For this method, you will need 1/4" data cartridges. They come in several sizes, there are two common sizes available 450 ft (which will contain aproximately 45 Megabytes) and 600 ft (which will contain aproximately 60 Megabytes).

Each of the Tektronix 4319 workstations in both the CS terminal room and the EE grad cad lab have a scsi tape drive. You can login to the 4319's in the CS terminal room using the same login name and password you use on rigel.

Backing Up/Restoring Files

To backup or restore files using a scsitape you will either need to use tar or cpio. The devices for the scsitape are /dev/rmt8 if you want to have the tape rewind after you have tar'ed or cpio'ed a file, or `/dev/rmt12' which will not rewind when the tar or cpio command is done.

Tar Method:

To backup files:
tar -cvf /dev/rmt12 filenames

To restore files:
tar -xvf /dev/rmt12 filenames

For table of contents:
tar -tf /dev/rmt12

Cpio Method

To backup files:
echo filenames | cpio -V/dev/rmt12 -ovc

To restore files:
cpio -ivcd -V/dev/rmt12

For  table  of  contents:
cpio  -ivct -V/dev/rmt12

For more information Read the tar(1), cpio(1), and mt(1) manual pages.

Example

Using tar:

% cd
% ls file1 file2 file3 file4 
% tar -cvf /dev/rmt12 file1 file2 file1 file2 
% tar -tf /dev/rmt12 file1 file2

(Using cpio)

% cd
% ls file1 file2 file3 file4 
% echo file1 file2 | cpio -V/dev/rmt12 -ovc file1 file2 
% cpio -ivct -V/dev/rmt12 file1 file2

News

This section provides both a general description of USENET news and an explanation of how to use various programs to access it.

General description

USENET is an informal network of tens of thousands of computers worldwide. Many sites are running UNIX, since the original goal of USENET was to tie together the UNIX community for advice and mutual support.

USENET is like an electronic bulletin board service. It allows users at participating sites to post electronic news articles around the network, and to read news items from other users at other sites. Each site gets copies of all news items.

News items are posted to a specific newsgroup. This restricts discussion of a given topic to people who are interested in it. There are newsgroups to discuss bicycles, books, the C programming language, database management, ham radio, and thousands of other topics. You can post news items for distribution to sites around the world, or just to your local community.

Since there may be over 1 million articles active at any given time, they are arranged based on the topic to which they relate. Usenet topics are arranged in a hierarchical manner (general topics are broken into more specific interests), such that, for example, articles relating to the 386bsd operating system will be under the `386bsd' group, under the `os' subhierarchy, under the `comp' hierarchy. This group is represented by the dotted notation `comp.os.386bsd' (pronounced: "comp oh-es three-atee-six bee-es-dee". Many may also include "dot" between the divisions). Articles under this group all pertain to that topic. This allows the user to interact with only subjects in his/her particular interests.

There are several different user interfaces for USENET news: rn (or rrn), nn, gnus (within emacs), tin. Three obsolete newsreaders, which you may hear references to are readnews, vnews, and notes.

Most of these use the NNTP protocol to read news from a remote server which stores all articles. Other machines can then run the client program and it will retrieve the articles from the news server.

News Etiquette

This section describes the USENET culture and customs that have developed over time. All new users should read this section to find out how USENET works.

USENET is a large collection of computers that share data with each other. It is the people on these computers that make USENET worth the effort to read and maintain, and for USENET to function properly those people must be able to interact in productive ways.

The following is a guide to using it politely, effectively and efficiently. Communication by computer is new to almost everybody, and there are certain aspects that can make it a frustrating experience until you get used to them. This document should help you avoid the worst traps.

The easiest way to learn how to use USENET is to watch how others use it. Start reading the news and try to figure out what people are doing and why. After a couple of weeks you will start understanding why certain things are done and what things shouldn't be done.

How to read news

There are quite a few nesreaders available, but we support only two: rn, nn. There are other newsreaders installed, on various machines You are free to use whatever program you like best, but keep in mind that the various packages have different levels of support.

All newsreading programs have one file in common: `.newsrc'. This file (located in your home directory) contains a listing of all of the currently active newsgroups.

It also indicates which groups you are subscribed to, i.e. the newsgroups that a newsreader will show you. Each newsgroup name is followed by a `:' or `!'. A colon indicates that you are currently subscribed to that group. An exclamation point indicates that you are currently unsubscribed to that group.

The `.newsrc' file keeps track of which articles you have read. Following the colon or exclamation point are the article numbers that you have read in that particular newsgroup.

There are several ways in which your `.newsrc' file can be setup. You could allow your newsreader to create it for you, but it will subscribe you to every single group, which is obviously not desired. The newsetup program will have the same behavior.

A better option is to use the new-newsrc program, which will create your `.newsrc' file, and then, automatically, invoke eep, which allows the user to determine which groups to subscribe to. eep will also allow you to change the order of your `.newsrc' which can make reading news much easier.

An alternate way to set up your `.newsrc' file is to use let newsetup create it for you. Then using an editor (i.e. vi or emacs, move the newsgroups you want to read to the top. When you are done with that, replace the remaining colons in the file with bangs (`!').

rn

rn is the program that is used to read news about a variety of subjects that are posted to USENET. In order to run rn, all you need to do is to type rn(2)

You can also specify the newsgroup you want to read, like rn rec.arts.startrek.current.

If no newsgroup name is specified then the rn program goes through your `.newsrc' file, which has a list of all the newsgroups. If a `.newsrc' file does not exist in your home directory, then rn creates one in your directory (using the newsetup program).

If you type the name of the newsgroup like `rec.humor' in the example above, then rn directly takes you to that newsgroup and you can start reading articles in that newsgroup.

rn operates on three levels:

paging
This is the bottom level and at this level rn operates very much like the utility more which is basically for a screen-oriented display.

selection
In this level you can specify which articles you want and in what order.

newsgroup selection
This is the top level in which you can select which newsgroups to view. The newsgroups are given to you in the order specified in your .newsrc.

On any level, and at any prompt you can type h for a list of available commands. This command will be very useful as you try to do more and more operations in rn. Typing space when rn prompts you for input will make it do the normal thing. Every prompt will have a set of options which can be typed and so at this point you can either type space (for first option) or something else as specified.

Upon startup, rn does the following:

  1. looks in your directory for a `.newsrc' which gives a list of the newsgroups you have subscribed to. If a `.newsrc' does not exist then it creates one for you.

  2. performs consistency checks on your `.newsrc' to see if it is consistent. If it is not it will patch it for you.

  3. checks to see if any new newsgroups have been created and it asks you whether you want to add these new newsgroups to your `.newsrc'. This checking can be disabled with the (locally added) option `-n'.

Then it goes into the top level, the newsgroup selection level.

Newsgroup selection level

In this section, some of the commands that you can use are described. SP stands for the space--bar.

When you are at this level your prompt will look something like:

      ************33 unread articles in rec.humor-- read now? [ynq]

At this prompt you can use any of these commands:

y, SP
read this newsgroup now.
=
read this newsgroup now, but display the list of articles before doing so.
n
go to the next newsgroup with unread news.
N
GO to the next newsgroup.
-
go to the previously displayed newsgroup.
^
go to the first newsgroup with unread news.
$
go to the end of the newsgroups list.
g newsgroup
go to newsgroup. If you are not subscribed rn will ask if you want to subscribe.
/pattern
scan forward in the newsgroups list for the specified pattern.
?pattern
scan backward in the newsgroups list for the specified pattern.
u
unsubscribe from the current newsgroup.
c
catch up, mark all articles in this newsgroup as read.
a pattern
add newsgroups to your `.newsrc' which match the pattern.
! command
run command in a subshell.
q
quit.

Article selection level

In this level rn selects articles from the newsgroup that you are reading in the order in which they have arrived at your site. In this level you are not asked whether you want to read an article and then display it, instead, it displays the first page of the article and at the end of the article it displays the following prompt:

-- End of article 256 ( of 900 ) -- what next? [npq]

At this point you can type any one of the following options:

n
SP
scan forward to the next unread article.
N
go to the next article.
^N
scan forward to the next article with the same subject. (now the search mode will be based on subject rather than article number)
p
scan backward for previous unread article.
-
go to previously displayed article (whether read or unread).
^P
scan backward for the previous article with the same subject.
^X
restart the current article and decrypt as a rot13 (a way of encoding) message.
X
refresh the screen and decrypt as a rot13 message.
q
quit this newsgroup and go back to the newsgroup selection level.
j
junk the current article and mark it as read. (j goes to the end of the article while n goes to the next unread article) number go to the numbered article.
m
mark the current article as still unread. (if you want to read the articles which are interesting at a later time)
k
mark as read all articles with the same subject as the current article.
r
reply through mail. This replies to just the person who posted.
F
submit a follow-up article. (including the lines in the article to which you are replying.
s filename
save the current article to the given filename.
=
List the subjects of unread articles.

Pager level

At the pager level (within an article) the prompt looks like :

--------More--(17%)--

At this prompt you can type any of the following commands:

SP
display next page.
X
refresh the screen and display as a decrypted rot13 message.
q
go to the end of the current article. This leaves you at the "What next ?" prompt.
j
junk the current article. Mark it as read and go to the end of the article.
gpattern
search forward for pattern.

Options while invoking rn

rn has a set of options which you can use to tailor the way in which rn works to your liking. Some of the options that you can use are:

`-d directory_name'
sets the default save directory to directory_name. (the default is `~/News')
`-e'
causes each page of the article to be started at the top of the screen.
`-M'
forces mailbox format in creating new save files. (this can be used to mail files to other people)
`-S'
causes rn to enter the subject search mode automatically. (this speeds up reading and searching for articles in a newsgroup)

This section on rn is just an annotated description of the features that will enable you to use rn comfortably. there are a lot of other options which you will want to use and for a detailed description of these do a man rn at the command line.

Pnews

Pnews allows you to post to a newsgroup. In order to run just type, Pnews newsgroup or just Pnews

Pnews is a friendly interface for posting news articles. It will ask several questions, then allow you to enter your article, and then post it.

nn

nn stands for No News and is a program for reading netnews. You may be wondering why it is called No News. That is part of its larger title: No News is Good News. The philosophy behind the design of nn is to minimize the amount of time spent in reading news. Thus, no news is good news because you don't have to spend any time reading news. (3)

nn modes

nn has two modes: selection mode and reading mode. When you first enter a newsgroup you are in selection mode. From this screen you select which articles you would like to read. Once this is done, you enter reading mode to read the articles.

The following commands will work in both modes:

?
Display a help page.
^L
Redraw the screen.
!
Shell escape.
Q
Quit nn.

command & command is an nn command. Some sample nn commands are:

:bug
report a bug in the nn program.
:help
provide online help.
:man
read the on-line manual pages.
:post
post an article.
:q!
quit nn without updating anything.

Selection Mode

The following figure shows a sample selection mode screen. This is what you will see whenever you enter a newsgroup. Note the following information:

Newsgroup: rec.arts.startrek.current               Articles: 786 of 14/1

a.Kymberlee Ricke  16  >>Spoilers for DS9: "Playing God"
b.Blanche Cohen    13  >>>
c.Sidra Vitale     42  >The Future of Star Trek
d.Jeff Hitchin     16  >Can trills transport?
e.Andre Bratu      25  >>
f.D t Omniscient   18  >
g.Sean Butler      35  >>
h.108swelnis       13  >>>
i.Mike Who         28  >>>>
j.holthausc@urvax  12  Top Ten Guys
k.holthausc@urvax  21  >Marina Sirtis' Opinions on Star Trek
l.acm0200@mtroyal  19  >>>Star Trek V
m.acm0200@mtroyal  36  >>>>>
n.Chem C3 Lab      25  >>>>>
o.KAUFMAN          44  >>>>
p.Dennis Bailey     4  >>>>
q.KAUFMAN          38  >>>>
r.Taki Kogoma      31  >>>>
s.Taki Kogoma      53  >>>>

-- 11:41 -- SELECT -- help:? -----Top 16%-----

In selection mode you select which articles you wish to read by pressing the appropriate article id key. There are several ways to do this:

Here are some examples:

a*
will select articles `a' through `d'
e-m
will select articles `e' through `m'
o
will select article `o'
q*
will select articles `q' and `r'.
o
pressing o again will cause `o' to be un-selected

You can tell if an article is selected because it will be highlighted.

Attributes

Each article has an article attribute associated with it. This attribute indicates the status of the article (have you seen it? have you read it? etc.). The attribute is shown either by highlighting the article line, or placing a single character following the article id.

In most cases, the initial display of articles has the unread attribute associated with each article. This is indicated by a blank space after the article id. In our example you can see that all of the articles are marked as unread.

When you select an article it will be highlighted (if your terminal cannot do highlighting then it will be marked with `*'). This is the selected attribute. Articles will remain selected if you mark them selected and then leave the newsgroup without reading them.

An article is marked read after you have read it. These articles will be marked permanently read when you leave the newsgroup and will not be displayed the next time you enter the newsgroup. The read attribute is indicated by `.'

One final attribute is the seen attribute. This indicates that an article has been presented but not read. These will be marked read when you leave the newsgroup.

There are several other article attributes, but they are beyond the scope of this document.

This brief introduction to attributes was necessary to understand some of the following selection mode commands:

Z
Enter reading mode immediately (normally reading mode is entered after all articles have been selected). When all selected articles have been read, return to the current group. Selected articles will be marked read. Unread articles are not changed.

X
Similar to Z, except that all unmarked articles are marked seen. When all selected articles have been read, advance to the next newsgroup. This is useful to skip all of the articles in a large newsgroup without having to go through all of the selection mode menu pages.

SPC
Continue to the next menu page. If you are on the last menu page then SPC will put you in reading mode. If no articles were selected then advance to the next newsgroup. All unread articles will be marked seen.

RET
Similar to SPC, except that unread articles will remain marked unread.

>
Goto next menu page.

<
Goto previous menu page.

$
Goto last menu page.

^
Goto first menu page.

=pattern
Select all articles having pattern in their subject.

Reading Mode

In reading mode the selected articles are displayed one at a time. Each article is marked read after you have read it. You will enter the next newsgroup after reading the last selected article (or the current newsgroup if you used the Z command).

The following are some of the commands that are available in reading mode:

SPC
Scroll one page forward. If you are on the final page of an article, then scroll to the next article.

BS
C-h
Scroll one page backward.

d
Scroll one half page forward.

u
Scroll one half page backward.

^
Move to the first page of the article.

$
Move to the last page of the article.

/regexp
Search forward for text matching the pattern regexp. For example, use /foo to search the for the string `foo' in the current article.

D
Turn rot13 decryption on or off for the current article.

n
Move to the next selected article. Current article is marked as read.

l
Leave a selected article and go to the next article. This is useful if you want to respond to an article, but you would first like to see if any of the existing responses say what you are planning to say.

=
Return to selection mode. Articles read will be marked read.

k
Kill current subject. Skips rest of article and all articles with the same subject heading. Skipped articles are marked read.

K
Similar to k, but kills the subject permanently (more on this later).

*
Selects all articles with same subject as current article. Can be used to select a base note, read it, and then select the responses only if you find the base note interesting.

N
Skip the rest of the selected and unread articles and go to the next newsgroup.

X
Mark all articles in current group as read and go to the next newsgroup.

There are three commands for saving articles. These can be invoked from either reading mode or selection mode:

S
Save article including full article header.
O
Save article with a short header.
W
Save article without a header.

When using one of these three commands, nn will give you a default file name. You can kill this and enter your own. You can also associate a file name with a particular newsgroup via your `.nn/init' file (this file will be discussed later).

Posting Articles

Posting and responding to articles can be done from either reading mode or selection mode. Two important notes concerning posting:

  1. Be aware of general network etiquette. Take a look at the articles in the newsgroup `news.announce.newusers' for information about netiquette. See section News Etiquette, for more info.
  2. Use a test newsgroup when learning how to post articles. Use a local one if available (we have a `psu.test' newsgroup for psu testing and an or.test for oregon distribution). Otherwise, use alt.test or misc.test.

The following commands are available for posting and responding. The first three give you the option of including the current article.

R
Reply through electronic mail to the author of the article. This is the preferred way to respond unless you think your article will be of general interest.

F
Follow-up with an article in the same newsgroup.

M
Mail a letter to someone.

:post
Post a new article to any newsgroup. News offers two features: cross-posting and distribution control. Cross-posting means that you can post the same article to more than one group. Do this by entering a comma separated list of newsgroups when nn asks for the newsgroup.

Distribution refers to who will see it. Sometimes the issue may be of interest only to the local community. In these cases you should choose as small a distribution as possible. This helps reduce network congestion. At PSU CS, we have the following possible distributions:

psu
Computer Science
psu
Portland State University
pdx
Portland area
or
Oregon
usa
United States
na
North America
world
Everywhere

When you are done editing your response you will be prompted with several options. The two that are used the most often are send to send the letter or post the article and abort to throw the letter/article away.

Three Very Important Files

In this section we will discuss three important files: your kill file, the `.newsrc' file, and the .nn/init file.

As was mentioned earlier, you can use the K command to kill a subject permanently. Articles of this subject heading will no longer be displayed. nn also has an auto-select feature where you can specify that certain articles automatically be marked as selected.

nn will ask you several questions after you press K. The first one is whether you would like to `k'ill or `s'elect. The next question asks if you wish to perform the action based upon `s'ubject or `n'ame. If you choose name then you must enter the name.

You will then be asked if you wish for this to apply to the current `g'roup only or `a'll groups. The final question is how long should this entry remain in your kill file. Each question has a default answer which will be used if RET is pressed. In addition, pressing RET in reply to the first question will perform a default action of killing all articles with the same subject for 30 days.

nn will use the same `.newsrc' that rn uses (see section How to read news, for more info), but nn does not use the `.newsrc' file to determine what order to display the groups. You can switch from rn to nn and retain the same newsgroup subscriptions you used to have.

The .nn/init file allows you to customize nn. You can set certain variables, define macros, customize your article header presentation, remap keys, and indicate the desired presentation sequence of articles. Unfortunately, a detailed discussion of the nn/init file is beyond the scope of this course. Interested users should consult the manual page for nn.

The default init file is located in `/usr/local/lib/news/nn/init'. If you copy this to your `.nn' directory with the command

cp /usr/local/lib/news/nn/init ~/.nn/init

You can then edit it. This is a very good way to put the critical news groups as the first groups you read.

What Next?

Finally we're ready to experiment with nn! There are three common ways to invoke nn:

nn
nn -g
nn -anumber

For starters, simply type nn. This normally sequences you through all of the groups that you are subscribed to. Initially you are subscribed to all groups.

This is the only time you'll have to do this. Now type nn. You will see that it displays one of the newsgroups that you selected. From here you should be able to use this handout to experiment with nn.

The `-g' option is used when you wish to go to a specific group. You can also use G from within nn to do the same thing. nn will prompt you for the group name. nn will ask `number of articles?' after you enter the newsgroup name. At this point enter the number of articles which you would like to read or a to see all articles. If you use G then you should answer jump instead of all.

The `-aN' is used to limit the display to a maximum of N articles. For example, the following will display the last 10 articles in each newsgroup:

nn -a10

This is handy for getting up to date if you have not read netnews for a while.

One other command that you will find handy is the U command. This is given from within nn and it will unsubscribe you to the current group.

In order to subscribe to a group, use either the `-g' option when invoking nn, or use the G command from within nn to go to the group. This will jump to the group. From within this group use the U command and nn will resubscribe you to that group.

I'd like to leave you with an advanced command that shows the power of nn. nn provides a way to search all newsgroups for a particular subject or a particular author! You cannot do this in other newsreaders (such as rn).

The format of the command is:

nn -mxX -sSubject all
 or
nn -mxX -nName all

For example, to search for all article posted about pizza, type:

nn -mxX -spizza all

The `-n' and `-s' options cannot be used together. The meaning of the various option flags is left as an exercise for you.

That's it! Experiment with nn and practice posting to a test newsgroup. If you're feeling particularly adventuresome, you may want to try to tackle the manual page for nn (its about 80 pages!).

Networking

Internet vs. BITNET

Portland State University is a part of the Internet network, but also provides connections to BITNET, UUCPnet and others. The following text was taken from a newsgroup and discusses the differences between the Internet and BITNET.

National Computing Networks

Several different networks have evolved from different origins, but efforts to develop a coherent strategy for the future are under way. The national network that is probably of most importance in the long term for delivering electronic information to the academic community is the Internet, which supports high speeds and powerful services. BITNET is a less powerful, and less expensive network; it reaches many smaller institutions that have not been able to justify the higher budgetary commitment (for equipment and staff support) to connect to the Internet if the campus network is not immediately compatible. The number of institutions connected to these networks has been growing rapidly, and mechanisms are in place to maintain and upgrade services, speed, and reliability. These networks are now part of the academic infrastructure, general--purpose highways for transporting data.

The Internet is not a single network; it incorporates the ARPANET, NSFNET, and many regional networks, which operate using the same family of communications protocols. Although it comprises networks administered by a variety of organizations, to the user it appears as an integrated whole. Just as anyone with a telephone can dial a friend anywhere in the country regardless of which local or long--distance telephone companies own the lines along which the signals travel, a computer connected to the Internet can communicate with any other computer on the Internet. The number of universities with access to this network has been growing fast since the National Science Foundation introduced NSFNET to provide researchers with high--speed access to supercomputer centers. In early 1989 it reaches around 300 academic institutions, and at many of these any computer or terminal attached to the campus network has access to the network. The Internet supports a wide variety of network services: the most commonly used are electronic mail, transfer of files between computers, and the ability to link to a remote computer as if one were at a terminal connected directly. However, the network is designed to support much more sophisticated functions that will be necessary for achieving the vision of transparent access to remote resources. A single logical database may be distributed over several machines, and software running on a user's workstation can refer to files stored on a computer across the country just as if they were stored on the workstation. These advanced network applications are only just emerging from the experimental stage; currently most network use is conscious. A researcher sends a message to a colleague using her network address, or logs on to a remote computer.

Several institutions have made their online information systems or databases accessible to remote users who log in over the Internet. For instance, the CARL system in Colorado, the Dante database at Dartmouth, and RPI's information system can all be reached over the Internet. To protect copyright, the tradition of free, open access to all information held by libraries sometimes has to be compromised to comply with restrictions incorporated into licenses by the owners of databases. For instance, the MELVYL online catalog is accessible over the Internet but access to MEDLINE is restricted to users on the University of California campuses. Other institutions require passwords or have restricted remote access over the Internet entirely, even when it is technically simple. This conflict will have to be resolved before the vision of a global information environment can be achieved, but such resolution will not come without considerable experience of pragmatic approaches.

In some disciplines, mainly technical fields such as computer science or engineering, access to the Internet is vital to keeping up with developments. Electronic mail is much more heavily used for communicating with colleagues around the world than paper, and the mail system supports an enormous number of mailing lists which function as bulletin boards on various topics. A wide variety of information, including working papers, reports, software, and documentation is accessible over the Internet through an informal distribution scheme based on a file transfer facility known as "anonymous FTP". FTP (File Transfer Protocol) allows a user to transfer files from one computer to another. Normally the user needs to sign on to an authorized computer account on both computers. However, anyone who has files or documents that they wish to make publicly accessible can store them so that they can be accessed by others who sign on as "anonymous". Once signed on, the remote user can look at a list of available files and request that some be transferred to his own computer. This facility provides a primitive form of networked information server.

The potential of networks for accumulating and distributing information in specialized areas is demonstrated by an example at the University of Delaware. With support from the Delaware Institute for Medical Education and Research, Dr Borgaonkar of the Medical Center of Delaware maintains two databases that support both research and practice in cytogenetics, the study of heredity through genetic means and the analysis of cells. The first, "Chromosomal Variation in Man -- A Catalog of Chromosomal Variants and Anomalies", is a bibliographic database which contains citations to relevant material scattered in the literature. The second, "International Registry of Abnormal Karyotypes -- Repository of Human Chromosomal Variants and Anomalies", holds unpublished data on about 350,000 chromosomal analyses, including 65,000 abnormalities. The information is submitted in personal communications, often over BITNET, by over 300 practitioners and researchers around the world. The databases are published in printed form, but there is a four--year interval between editions of the catalog and two years between editions of the registry. The field is developing rapidly, and online access is essential for locating recent data. Currently, most remote users send requests by electronic mail. The search is performed locally by Dr. Borgoankar or his staff, and the results returned by electronic mail. The university's support group for academic computing expects more demand for direct online access in the future, and the computer on which the database is stored is already accessible from the Internet, BITNET, and commercial packet--switched networks. (Copyright, Digital Press, 1989)

Campus Strategies for Libraries and Electronic Information (1989) and Campus Networking Strategies (1988) are both published by Digital Press. Call 1-800-343-8321, the Educational Services Order Fulfillment Division. CSLEI is $34.95 (Part # EY-C185E-DP-SS). CNS was $30 (Part # EY-6736E-DP).

Both books are also available at reduced prices through EDUCOM (609) 520-3340. I believe CNS is $20, and CSLEI is $25. You can place an order over BITNET by sending mail to PUBS@EDUCOM.

File Transferring and Downloading

FTP

File transfer protocol (FTP) is a standard used for transferring files to and from machines connected to the Internet. Ftp can be used from all machines in the Computer Science Department. The easiest way to use the ftp program is to use ftp command followed by the name of the machine with which to connect:

ftp hostname

After executing this command, you will be prompted for a name and a password. Your response will depend on whether or not this is an anonymous ftp. An anonymous ftp allows anyone to login with a name of anonymous and access publically accessible files. When using anonymous ftp, the password prompt should be answered with the full E-Mail address of the user. An example of an anonymous ftp login would be:

rigel ftp wuarchive.wustl.edu 
Name (wuarchive.wustl.edu:moeh):anonymous 
Passwd (wuarchive.wustl.edu:anonymous):moeh@rigel.cs.pdx.edu 
331 Guest login ok, sent ident as password. 
331 Guest login ok, access restrictions apply. 
ftp>

If you are not using an anonymous ftp, then you would normally be logging into your own account on another machine. In this case, the name prompt would be answered with your login name, and the password prompt would be answered with your password on the remote machine. An example of a normal ftp login would be:

(rigel) moeh {519}> ftp cs.pdx.edu
Connected to cs.pdx.edu.
220 cs.pdx.edu FTP server (Version 5.89 Wed Jul 31 13:15:11 PDT 1991) ready.
Name (cs.pdx.edu:moeh): moeh
331 Password required for moeh.
Password: <moeh's password>
230 User moeh logged in.
ftp> 

Both anonymous and normal ftp should now display the ftp> prompt. You can always get help from the ftp> prompt by typing a ? or help. This will display a list of possible commands. The two most used commands are get which will retrieve a file, and put which will send a file. If the file is not a text file, then binary mode must be used. An example of retrieving a binary file with a file name of file1.c would be:

ftp> bin
200 Type set to I.
ftp> get file1.c 
200 PORT command successful.
150 Opening BINARY mode data connection for meetinfo03.Z (864 bytes).
226 Transfer complete.
local: file1.c remote: file1.c 
864 bytes received in 0.0018 seconds (4.8e+02 Kbytes/s)
ftp> 

The following is a list of some useful ftp commands and a brief description.

binary
set file type to binary
cd
change directory on remote machine
get
retrieve a file from the remote machine
hash
put a hash mark (#) after each buffer transferred
put
send a file to the remote machine
quit
quit ftp
ascii
set file type to ascii (text)

FTP Etiquette

The Internet is financed in a cooperative effort. All sites share the charges incurred by users. Somebody is paying the long distance phone bills for your connection in exchange for us paying for any costs of connecting through Portland State University. As a courtesy to the Internet, please do not explore ftp sites outside of Portland State University during normal business hours. By accessing these ftp sites during non-business hours, 5:00 pm to 8:00 am, you will be saving PSU money and as a bonus your connections and transfers will be swift.

RCP

Rcp stands for remote copy. It is like cp, but between two separate machines. In order to use rcp, you must have an account on both machines, and have a .rhosts file on the machines involved ( Note: .rhost files are a security risk and should only be used if absolutely necessary). The rcp command has the following format:

rcp host1: file1 host2: file2

This will transfer file1 on machine host1 to file2 on machine host2. If the host is left out, then it defaults to the current machine. An example of transferring a file from rigel to the current machine would be:

rcp rigel.cs.pdx.edu:myprogram.c localprogram.c

XMODEM, YMODEM, and ZMODEM

This section deals with uploading and downloading files from you home computer over a modem. Two programs will be illustrated: sx sb sz , and kermit.

Sx rx, sb rb, and sz rz implement the xmodem, ymodem, and zmodem file transfer protocols respectively.

XMODEM

Xmodemis one of the most widely used file transfer protocols. The original Xmodem protocol uses 128-byte packets and a simple "checksum" method of error detection. A later enhancement, Xmodem-CRC, uses a more secure Cyclic Redundancy Check (CRC) method for error detection. Xmodem protocol always attempts to use CRC first. If the sender does not acknowledge the requests for CRC, the receiver shifts to the checksum mode and continues its request for transmission.

Xmodem-1K

Xmodem 1K is essentially Xmodem CRC with 1K (1024 byte) packets. On some systems and bulletin boards it may also be referred to as Ymodem. Some communication software programs, most notably Procomm Plus 1.x, also list Xmodem-1K as Ymodem. Procomm Plus 2.0 no longer refers to Xmodem-1K as Ymodem.

YMODEM

Ymodem is essentially Xmodem 1K that allows multiple batch file transfer. On some systems it is listed as Ymodem Batch.

Ymodem-g

Ymodem-g is a variant of Ymodem. It is designed to be used with modems that support error control. This protocol does not provide software error correction or recovery, but expects the modem to provide the service. It is a streaming protocol that sends and receives 1K packets in a continuous stream until instructed to stop. It does not wait for positive acknowledgement after each block is sent, but rather sends blocks in rapid succession. If any block is unsuccessfully transferred, the entire transfer is canceled.

ZMODEM

Zmodem is generally the best protocol to use if the electronic service you are calling supports it. Zmodem has two significant features: it is extremely efficient and it provides crash recovery.

Like Ymodem-g, Zmodem does not wait for positive acknowledgement after each block is sent, but rather sends blocks in rapid succession. If a Zmodem transfer is canceled or interrupted for any reason, the transfer can be resurrected later and the previously transferred information need not be resent.

The fallowing are small examples on how this programs can be used. These commands are executed on the UNIX machine first, and then the appropriate option is selected on your PC to start the transfer. The following are examples of these commands using the xmodem protocol. The other protocols can be used the same way.

sx file1
send text file file1, using the xmodem protocol
sx -b file2
send binary file file2, using xmodem
rx
receive a text file using xmodem
rx -b file3
receive a binary file, file3, using xmodem

Kermit

Kermit was developed at Columbia University. It was designed to facilitate the exchange of data among very different types of computers (mainly minicomputers and mainframes). You probably will not need to use Kermit unless you are calling a minicomputer or mainframe at an educational institution.

Version 4C of this file transfer program is available on most computers. Kermit can be used in comand-line mode or interactively. In both cases, kermit is intended to be run on each of the two computers that are in communication; one prepared to send and the other prepared to receive.

To use kermit in command-line mode, type the following:

kermit options filenames

replace options with the options you want to use. The -l option, indicating location, and the -b option, indicating baud rate, are both required. The -r option indicates you want to receive the files indicated in files, and the -s option indicates you want to send these files. Replace filenames with the names of the files you want to transfer. To get help, use the -h option.

To use kermit in interactive mode, type the following:

kermit

You should then see the fallowing:

(rigel) moeh {1246}> kermit
C-Kermit 5A(189), 30 June 93, SunOS 4.1 (BSD)
Type ? or HELP for help

In interactive mode, use the ? command to get help.

Archiving

Compress and Uncompress

Compress is a program that saves disk space by reducing the size of your files. It is described in Section See section Compress and Uncompress

Tar

Tar is used to archive files and/or directories to a single file, or to a magnetic tape. The two most useful tar modes are create and extract, denoted by a "c" and an "x" option respectively. The "f" option is used to specify the filename or tape device where the tar file will be saved. For example, if you have a directory, Mail, and you would like to archive this directory using the filename, mail1.tar, you would use the following command.

tar cf mail1.tar Mail

If you ever want to unarchive the tar file, mail1.tar, you could use the following command. Remember, untaring this file will recreate the Mail directory, destroying any existing directory named Mail.

tar xf mail1.tar

For more information take a look at Section See section Backing Up Files On Tape

Systems Summary

The following is a synopsis of the Departmental computing facilities which are managed (or co-managed) by the CS Systems Staff.

This information can change very quickly, and, thus, may be slightly out of date (particularily in a printed copy). It was last updated on 19-Apr-94.

rigel.cs.pdx.edu
Sparc 2, 64megs, 3*1.2G+2*1G+.4G disk space
Primary CS file server

sirius.cs.pdx.edu
Sparc 10/50, 64megs, .4G+1G disk space
(main login machine) PCAT X terminal server
zetar.cs.pdx.edu
Spar 10/50, 128megs, 1.05G disk space
(facutly workstation)

xavier.cs.pdx.edu
Sparc 2, 64megs, .4G+1.2G
(runs the CS lab) CS lab X terminal server

antares.cs.pdx.edu
Sparc IPC, 24 megs, 1.2G disk space (faculty workstation)

polaris.cs.pdx.edu
Sparc IPC, 24 megs, .77G disk space (faculty workstation)

draco.cs.pdx.edu
Sparc 2, 64 megs, 1.2G disk space (faculty workstation)

plieades.cs.pdx.edu
Sparc 2, 64 megs, 1G disk space (faculty workstation)

orion.cs.pdx.edu
Sparc 1+, 24 megs, .3G disk space (faculty workstation)

palm.cs.pdx.edu
Sparc 1, 24 megs, .4G disk space (faculty workstation)

pdxgate.cs.pdx.edu
Sun 3/50, 24 megs, .7G disk space. Mail/uucp gateway.

aurora
Intel 301 running an IPSC/2 with 24 nodes. (gift from OACIS)
malach
Cisco ASM/2, 64 port terminal server. 12 2400 baud dialups (also 11 EE dialups), 3 V.32bis dialups (also 3 EE dialups).

accounts (a.k.a. ganymede)
The account database machine.

X terminals
50+ Tek X terminals of various models. 4 Sun 3/50 (running as Xterms) and 3 Tek 4319 workstations (running as Xterms)

janus
AT&T 6386, 300 megs, DOS transfer machine

other DOS machines
About 9 PC's scattered about the department, 4 or 5 networked via NCSA Telnet. Two XT's are available in the Lab.

Sysgroup Training Machines

These machines change very quickly, the ones at the top are more stable

acacia
Intel 302 (386-25), 24 megs, 770 megs disk space, running 386BSD (patchkit distribution)
sloth
Intel 302 (386-25) 24 megs, 350 megs disk space, running Linux (SlackWare)
babylon
gommorah
ren
stimpy
Sun 3/50, 300 megs disk space, Systems development and testing boxes.
tom-servo
486DX-50, 300 megs, running Linux

Appletalk Network

Both MSB and PCAT have an AppleTalk network, linked to the UNIX networks via 2 Shiva Fastpath gateways. There are a total of about 14 Macs scattered throughout both buildings. None for student access, though.

Printers

Other machines (run by the Computer Center):

csqr
Sequent S27, 10 procs, 128 megs, 5*.5G disk space
jade
Sequent S81, 20 procs, 256 megs, 19*.5G disk space

odin
Sequent S81, 20 procs

Newsgroups

This appendix lists some of the more useful newsgroups, both local and worldwide. See section News, for more information.

Local Newsgroups

The following is a list of the local PSU newsgroups and what they are intended for.

If you feel there should be another local newsgroup send a proposal to 'usenet@ee.pdx.edu'.

`psu.msgs'
`psu.msgs' is primarily meant to carry system announcements (downtime, updates, etc) and other official information distribution (seminars, class information, etc). Everything posted here should be of general interest to the users in the EE and CS departments and the Campus Computer Center. Discussions of anything posted here should be posted to `psu.general' or `psu.flame' (see below). Inappropriate postings here may result in punitive measures. (Note: The msgs command accesses the identical messages as the newsgroup `psu.msgs')

`psu.general'
`psu.forsale'
`psu.flame'
These newsgroups are for general use by anybody at PSU. `psu.general' is for discussions, etc. of issues about PSU, `psu.forsale' is for for sale and want ads. The latter is actually a newsgroup from Penn. State which somehow got here; nevertheless, feel free to use it for all your flaming needs.

`psu.systems'
`psu.systems.group'
These newsgroups are for CS Systems Related issues. The former group is for questions and discussions about how Sysgroup is doing their work. The latter is for discussions among Sysgroup.

`psu.usenet'
`psu.dialups'
`psu.TeX'
`psu.maple'
`psu.games'
These newsgroups are for discussions/complaints/comments about these various software/services around CS and EE.

`psu.test'
This newsgroup is for testing article posting in the PSU distribution. Never use the other `psu.*' newsgroups for this.

Recommended Newsgroups

Portland State University Computer Science Department Systems Staff (Sysgroup) strongly recommends that you subscribe to the following newgroups and read them regularly:

`news.announce.important'
`news.newusers.questions'
`psu.msgs'
`psu.systems'
`psu.general'
`pdx.general'
`or.general'

You may also want to subscribe to these:

`comp.unix.questions'
`comp.unix.wizards'
`comp.windows.x.announce'
`gnu.announce'
`misc.jobs.offered'

There are a wide range of groups available. Odds are that you will find more newsgroups about subjects which you are interested in than you will have time to read. In particular, you may want to look at `*.announce' newsgroups, since they are low volume.

Index

!

  • !
  • !!

    *

  • * character

    .

  • .cshrc
  • .dvi files
  • .emacs
  • .login
  • .mailrc
  • .mh_profile
  • .newsrc
  • .nn
  • .nn/init
  • .profile
  • .tex files

    /

  • /dev/rmt12
  • /etc/printcap
  • /folklore
  • /usr/local/lib/news/nn/init

    ?

  • ? character
  • ? command

    a

  • A Practical Guide to the UNIX System
  • abbreviations
  • Abbreviations, setting
  • absolute pathname
  • acceptable use policy
  • account eligibility
  • addme
  • alias
  • aliases
  • archiving files
  • arguments, UNIX
  • article attribute
  • articles, posting
  • assistance, getting
  • at
  • attribute, article

    b

  • backing up files on tape
  • backspace key
  • bang
  • bash
  • Basic UNIX commands
  • batch
  • Berkeley Mail
  • bg
  • BITNET
  • Books
  • books
  • books, how to get
  • born again shell
  • bourne shell

    c

  • C Programming in the UNIX Environment
  • C shell
  • c shell
  • C wizards Programming Reference
  • C: A Reference Manual
  • cat
  • cc
  • cd
  • Changing shell
  • chgrp
  • chmod
  • chown
  • col
  • command completion
  • commands, completing
  • commands, re-executing
  • commands, UNIX
  • communicating with other users
  • comp.unix.questions
  • comp.unix.wizards
  • comp.windows.x.announce
  • completing commands
  • completion
  • compress
  • compressing files
  • Computer Networks
  • control keys
  • controlling jobs
  • cp
  • cpio
  • cpu usage
  • cross-posting
  • csh
  • ctrl-\
  • ctrl-c
  • ctrl-d
  • ctrl-h
  • ctrl-q
  • ctrl-r
  • ctrl-s
  • ctrl-u
  • ctrl-w
  • ctrl-z
  • customizing environment
  • cwd

    d

  • dead.letter
  • default permissions
  • delete key
  • deleting files
  • diff
  • directory
  • disk space, using efficiently
  • disk storage
  • distribution
  • dot files
  • dot files, .emacs
  • du
  • duplex
  • dvi
  • dvips

    e

  • EDITOR
  • editors
  • Editors
  • editors, emacs
  • editors, vi
  • eep
  • efficiency
  • emacs
  • emacs, learning
  • Email
  • enscript
  • environment, customizing
  • exceptions
  • expand

    f

  • f77
  • fg
  • file
  • file system
  • filec
  • files
  • files, .tex
  • files, archiving
  • files, backing up
  • files, deleting
  • files, printing
  • files, restoring
  • filesystem
  • filters
  • finger command
  • full pathname

    g

  • getting help
  • GNU
  • gnu.announce
  • gopher
  • grep
  • groups
  • guest accounts

    h

  • harassment
  • hard copy
  • head
  • help
  • Help! C shell! special variables
  • help, getting
  • help, on-line
  • Help, with commands
  • help, with interactive utilities
  • history
  • history, UNIX
  • home directory

    i

  • I/O
  • I/O redirection
  • images, printing
  • info
  • initialization files
  • instructor
  • internal help
  • Internet
  • Introducing the UNIX System
  • irc

    j

  • job control
  • jobs
  • jobs, controlling
  • Jobs, example of controlling
  • jobs, running at low priority
  • jobs, running during low-use times
  • jobs, running in background
  • jobs, running in foreground
  • jobs, running in the background
  • jobs, running in the foreground
  • jobs, running several at once
  • jobs, suspending

    k

  • kermit
  • kill
  • kill file
  • korn shell
  • ksh

    l

  • laser printer
  • latex
  • LaTeX Manual
  • Latex, basic commands
  • Latex, chapter titles
  • Latex, document styles
  • Latex, effects
  • Latex, examples
  • Latex, footnotes
  • Latex, learning
  • Latex, preparing files for
  • Latex, running
  • Latex, section headings
  • Latex, special characters
  • Latex, type sizes
  • Latex, type styles
  • Learning the UNIX Operating System
  • Learning the Vi Editor
  • less
  • lex
  • links
  • lint
  • lisp
  • list
  • load average
  • Log-in file
  • log-in files
  • Log-in files
  • Login! determining
  • look
  • low-use times
  • lowercase letters
  • lpq
  • lpr
  • lprm
  • ls
  • ls -Fl
  • lwaddquot
  • lwquot

    m

  • mail
  • Mail
  • mail command
  • Mail Help
  • mail msgs command
  • Mail, receiving
  • mailbox
  • make
  • man
  • man -k
  • man command
  • Man Pages
  • Man pages, organization
  • Managing Projects with Make
  • Managing UUCP & Usenet
  • manuals
  • manuals, how to get
  • Mesg
  • mesg command
  • messages
  • Messages, receiving
  • Messages, sending
  • MH
  • MH and XMH
  • MH! basic commands
  • misc.jobs.offered
  • mkdir
  • more
  • mpage
  • msgs command
  • mv

    n

  • new-newsrc
  • news
  • News, reading
  • news.announce.important
  • news.newusers.questions
  • newsetup
  • nfs
  • nice
  • no news
  • Notable Networks

    o

  • on-line communication
  • On-line Communication
  • On-line Communication! mail. See Mail.
  • On-line Communication! messages. See MH.
  • on-line help
  • options, UNIX
  • or.general

    p

  • passwd
  • password
  • password, changing
  • PATH
  • path
  • pathname, absolute
  • pathname, full
  • pc
  • pdx.general
  • permissions
  • permissions, default
  • photo-typesetter
  • piping
  • Piping! getting input from a string of commands
  • Piping! used with I/O redirection
  • Pnews
  • policy, acceptable use
  • posting articles
  • postscript
  • Practical UNIX Security
  • PRINTER
  • printer queue
  • printer quotas
  • printers, laser
  • Printing
  • printing
  • printing files
  • printing images
  • Printouts
  • printouts
  • privacy
  • Programming in Perl
  • Programming with Curses
  • prompt
  • ps -a
  • psmod
  • psu.dialups
  • psu.flame
  • psu.forsale
  • psu.games
  • psu.general
  • psu.maple
  • psu.msgs
  • psu.systems
  • psu.systems.group
  • psu.test
  • psu.TeX
  • psu.usenet
  • pwd

    q

  • queue, printer
  • Quick-reference
  • Quick-reference, UNIX
  • quotas, printer

    r

  • rcp
  • re-executing commands
  • Reading and Writing Termcap Entries
  • rec.arts.startrek.current
  • redirecting I/O
  • Redirecting I/O! input
  • Redirecting I/O! used with piping
  • resources, system
  • resources, using wisely
  • response time, maximizing
  • restoring deleted files
  • rm
  • rmdir
  • rn
  • rot13
  • running jobs at low priority
  • running jobs during low-use times
  • running jobs in the background.
  • running jobs in the foreground
  • running several jobs at once

    s

  • script
  • Secondary parsing
  • Sed and Awk
  • Sending mail
  • set
  • sh
  • sort
  • special characters
  • special file
  • spell
  • spool
  • standard error
  • standard input
  • standard output
  • Star Trek
  • Starting with UNIX
  • stty
  • support staff
  • suspending jobs
  • Sysgroup
  • sysgroup
  • system information
  • system resources, using wisely
  • systems group
  • systems manager
  • systems, using efficiently

    t

  • t c shell
  • ta
  • tail
  • talk
  • tape storage
  • tar
  • tcsh
  • terminal characteristics, setting
  • tex
  • text processors
  • text processors, latex
  • text processors, troff
  • The C Programming Language
  • The Design of the UNIX Operating System
  • The Form
  • The UNIX Operating System
  • The UNIX Programming Environment
  • The UNIX Survival Guide
  • The UNIX System
  • Tricks of the UNIX Masters
  • troff
  • Troff
  • Troff, command summary
  • troff, commands
  • troff, constants
  • troff, effects
  • troff, example
  • troff, indenting text
  • troff, labelled lists
  • troff, learning
  • Troff, line lengths
  • Troff, line spacing
  • troff, macros
  • troff, margins
  • troff, preparing files for
  • Troff, running
  • troff, tabs
  • Troff, type sizes
  • troff, type styles
  • tumble
  • tutorials
  • Tutors
  • tutors
  • Tutors, Before You Go
  • tutors, ways to contact
  • typesetter

    u

  • umask
  • UNIX BSD Quick Reference Guide
  • UNIX commands
  • UNIX commands, control-keys
  • UNIX Commands, descriptions of
  • UNIX commands, descriptions of
  • UNIX commands, I/O
  • UNIX commands, quick-reference to
  • UNIX commands, syntax
  • UNIX Communications
  • UNIX control-key commands
  • UNIX file system
  • UNIX for People
  • UNIX history
  • UNIX Primer Plus
  • UNIX Programmers Manual
  • UNIX Quick Reference
  • UNIX shells
  • UNIX System Administration
  • UNIX System Administration Handbook
  • UNIX System Security
  • UNIX systems, using efficiently
  • UNIX Text Processing
  • Unix User's Supplementary Documents
  • UNIX varieties
  • UNIX varieties, BSD
  • UNIX varieties, DYNIX
  • UNIX varieties, ptx
  • UNIX varieties, SunOS
  • UNIX varieties, Sys VR3
  • UNIX varieties, Sys VR4
  • uppercase letters
  • uptime
  • USD
  • usenet
  • USENET
  • Using UUCP & Usenet

    v

  • vi
  • vi, character positioning
  • vi, correcting during insert
  • vi, deleting text
  • vi, file manipulation
  • vi, getting into
  • vi, inserting or changing text
  • vi, learning
  • vi, line positioning
  • vi, moving or copying lines
  • vi, positioning with a file
  • vi, searching for a pattern
  • vi, undoing or restoring
  • vi, words, sentences, and paragraphs

    w

  • w
  • wc
  • who
  • who am i
  • wild-card characters
  • write

    x

  • X window system
  • xinfo
  • xlisp
  • XMODEM

    y

  • yacc
  • YMODEM

    z

  • ZMODEM

    ~

  • ~/News