BSD 3 development
[unix-history] / usr / man / man0 / intro
CommitLineData
a4ed1c04
BJ
1.af PN i
2.pn 5
3.de IR
4\fI\\$1\^\fR\\$2
5..
6.de RI
7\fR\\$1\fI\\$2\^\fR\\$3
8..
9.TL
10INTRODUCTION TO VOLUME 1
11.LP
12This volume gives descriptions of the publicly available
13features of the
14.UX \s-2/32V\s0
15system,
16as extended to provide a virtual memory environment
17and other enhancements
18at U. C. Berkeley.
19It does not attempt to provide perspective or tutorial
20information upon the
21.UX
22operating system,
23its facilities, or its implementation.
24Various documents on those topics are contained in
25Volume 2.
26In particular,
27for an overview see `The
28.UX
29Time-Sharing System'
30by Ritchie and Thompson; for a tutorial see
31`\s8UNIX\s10 for Beginners' by Kernighan,
32and for an guide to the new features of this virtual version, see
33`Getting started with Berkeley Software for \s8UNIX\s10 on the \s8VAX\s10'
34in volume 2c.
35.LP
36Within the area it surveys, this volume attempts
37to be timely, complete and concise.
38Where the latter two objectives conflict,
39the obvious is often left unsaid in favor of brevity.
40It is intended that each program be described
41as it is, not as it should be.
42Inevitably, this means that
43various sections will soon be out of date.
44.LP
45The volume is divided into
46eight sections:
47.DS
481. Commands
492. System calls
503. Subroutines
514. Special files
525. File formats and conventions
536. Games
547. Macro packages and language conventions
558. Maintenance
56.DE
57Commands are programs intended to be invoked directly by
58the user, in contradistinction to subroutines, which are
59intended to be called by the user's programs.
60Commands generally reside in directory
61.I /bin
62(for
63.IR bin \|ary
64programs).
65Some programs also reside in
66.I
67/\|usr/\|bin,
68.R
69or in
70.I
71/\|usr/\|ucb,
72.R
73to save space in
74.I /bin.
75These directories are searched automatically by the command interpreters.
76.LP
77System calls are entries into the
78.UX
79supervisor.
80The system call interface is identical to a C language
81procedure call; the equivalent C procedures are described in Section 2.
82.LP
83An assortment
84of subroutines is available;
85they are described in section 3.
86The primary libraries in which they are kept are described in
87.IR intro (3).
88The functions are described in terms of C, but most will
89work with Fortran as well.
90.LP
91The special files section 4 discusses the characteristics of
92each system `file' that actually refers to an I/O device.
93The names in this
94section refer to the DEC device names for the
95hardware,
96instead of the names of
97the special files themselves.
98.LP
99The file formats and conventions section 5 documents the structure of particular
100kinds of files; for example, the form of the output of the loader and
101assembler is given. Excluded are files used by only one command,
102for example the assembler's intermediate files.
103.LP
104Games have been relegated to section 6 to keep them from contaminating
105the more staid information of section 1.
106.LP
107Section 7 is a miscellaneous collection of information necessary to
108writing in various specialized languages:
109character codes,
110macro packages for typesetting,
111etc.
112.LP
113The maintenance
114section 8 discusses procedures not intended
115for use by the ordinary user.
116These procedures often involve use of commands
117of section 1, where an attempt has been made to
118single out peculiarly maintenance-flavored commands
119by marking them 1M.
120.LP
121Each section consists of a number of independent
122entries of a page or so each.
123The name of the entry is in the upper corners of its pages,
124together with the section number, and sometimes a
125letter characteristic of a subcategory, e.g. graphics is 1G,
126and the math library is 3M.
127Entries within each section are
128alphabetized.
129The page numbers of each entry start at 1;
130it is infeasible to number consecutively the pages of
131a document like this that is republished in many variant forms.
132.LP
133All entries are based on a common format,
134not all of whose subsections will always appear.
135.RS
136.LP
137The
138.I name
139subsection lists the exact names of the commands and subroutines
140covered under the entry and gives
141a very short description of their purpose.
142.LP
143The
144.IR synopsis ""
145summarizes the use of the
146program being described.
147A few conventions are used, particularly in the
148Commands subsection:
149.LP
150.RS
151.B Boldface
152words are considered literals, and
153are typed just as they appear.
154.LP
155Square brackets [ ] around an argument
156indicate that the argument is optional.
157When an argument is given as `name', it always
158refers to a file name.
159.LP
160Ellipses `.\|.\|.' are used to show that the previous argument-prototype
161may be repeated.
162.LP
163A final convention is used by the commands themselves.
164An argument beginning with a minus sign `\-'
165is often taken to mean some sort of option-specifying argument
166even if it appears in a position where a file name
167could appear. Therefore, it is unwise to have files
168whose names begin with `\-'.
169.LP
170.RE
171The
172.IR description ""
173subsection discusses in detail the subject at hand.
174.LP
175The
176.IR files ""
177subsection gives the names of files which are
178built into the program.
179.LP
180A
181.I
182see also
183.R
184subsection gives pointers to related information.
185.LP
186A
187.I diagnostics
188subsection discusses
189the diagnostic indications which may be produced.
190Messages which are intended to be self-explanatory
191are not listed.
192.LP
193The
194.IR bugs ""
195subsection gives
196known bugs and sometimes deficiencies.
197Occasionally also the suggested fix is
198described.
199.LP
200In section 2 an
201.I assembler
202subsection carries the PDP-11 assembly-language system interface.
203.LP
204.RE
205At the beginning of the volume is a table of contents,
206organized by section and alphabetically within each section.
207There is also a permuted index derived from the table of contents.
208Within each index entry, the title
209of the writeup to which
210it refers is followed by the appropriate section number in parentheses.
211This fact is important because there is considerable
212name duplication among the sections,
213arising principally from commands which
214exist only to exercise a particular system call.
215.SH
216HOW TO GET STARTED
217.LP
218This section sketches the basic information
219you need to get started on
220.UX
221how to log in and log out,
222how to communicate through your terminal,
223and how to run a program.
224See `\c
225.UX
226for Beginners'
227in Volume 2 for a more complete introduction
228to the system.
229.LP
230.I
231Logging in.\ \
232.R
233You must call
234.UX
235from an appropriate terminal.
236.UX
237terminals are typified by the TTY 43,
238the Decwriter II, the DASI 300S and 450, and most
239video terminals such as
240the ADM-3A, HP 2621, or Concept 100.
241You must also have a valid user name,
242which may be obtained, together with the telephone number, from the system administrators.
243The same telephone number
244serves terminals operating at all the standard speeds.
245After a data connection is established,
246the login procedure depends on what kind of terminal
247you are using.
248.I
249.I
250.R
251.R
252.LP
253.I
254300-baud terminals:\ \
255.R
256Such terminals include the GE Terminet 300, and
257most display terminals
258run with popular modems.
259These terminals generally have a speed
260switch which should be set at `300' (or `30' for
26130 characters per second)
262and a half/full duplex switch which should be set at
263full-duplex.
264(This switch will often have to be changed
265since many other systems require half-duplex).
266When a connection is established, the system
267types `login:'; you type your
268user name, followed by the `return' key.
269If you have a password, the system asks for it
270and turns off the printer on the terminal
271so the password will not appear.
272After you have logged in,
273the `return', `new line', or `linefeed' keys
274will give exactly the same results.
275.LP
276.I
2771200- and 150-baud terminals:\ \
278.R
279If there is a half/full duplex switch, set it at full-duplex.
280When you have established a data connection,
281the system types out a few garbage characters
282(the `login:' message at the wrong speed).
283Depress the `break' (or `interrupt')
284key; this is a speed-independent signal
285to
286.UX
287that a different speed terminal
288is in use.
289The system then will type `login:,' this time at another
290speed.
291Continue depressing the break key
292until `login:' appears in clear, then
293respond with your user name.
294From the TTY 37 terminal, and any other which has the `newline'
295function (combined carriage return and linefeed), terminate each line you type with the
296`new line' key,
297otherwise use the `return' key.
298.LP
299.I
300Hard-wired terminals.\ \
301.R
302Hard-wired terminals usually begin at the right
303speed, up to 9600 baud; otherwise the preceding instructions
304apply.
305.LP
306For all these terminals, it is important
307that you type your name in lower-case if possible; if you type
308upper-case letters,
309.UX
310will assume that your terminal cannot generate lower-case
311letters and will translate all subsequent upper-case
312letters to lower case.
313.LP
314The evidence that you have successfully
315logged in is that a shell program
316will type a prompt (`$' or `%') to you.
317(The shells are described below under
318`How to run a program.')
319.LP
320For more information, consult
321.IR tset (1),
322and
323.IR stty (1),
324which tell how to adjust terminal behavior,
325.IR getty (8),
326which discusses the login sequence in more
327detail, and
328.IR tty (4),
329which discusses terminal I/O.
330.LP
331.I
332Logging out.\ \
333.R
334There are three ways to log out:
335.IP
336You can simply hang up the phone.
337.IP
338You can log out by typing an end-of-file indication
339(EOT character, control-d) to the Shell.
340The Shell will terminate and the `login: ' message
341will appear again.
342.IP
343You can also log in directly as another user
344by giving a
345.IR login (1)
346command.
347.LP
348.I
349How to communicate through your terminal.\ \
350.R
351When you type characters, a gnome deep in the system
352gathers your characters and saves them in a secret
353place.
354The
355characters will not be given to a program
356until you type a return (or newline), as described above
357in
358.I
359Logging in.
360.R
361.LP
362.UX
363terminal I/O is full-duplex.
364It has full read-ahead, which means that you can
365type at any time,
366even while a program is
367typing at you.
368Of course, if you type during output, the printed output will
369have the input characters interspersed.
370However, whatever you type will be saved
371up and interpreted in correct sequence.
372There is a limit to the amount of read-ahead,
373but it is generous and not likely to be exceeded unless
374the system is in trouble.
375When the read-ahead limit is exceeded, the system
376throws away all the saved characters.
377.LP
378The character `@' in typed input
379kills all the preceding characters in the line, so
380typing mistakes
381can be repaired on a single line.
382Also, the character `#' erases the last character typed.
383(Most users prefer to use a backspace rather than `#',
384and many prefer control X instead of `@';
385.IR tset (1)
386or
387.IR stty (1)
388can be used to arrange this.)
389Successive uses of `#' erase characters back to, but
390not beyond, the beginning of the line.
391`@' and `#' can be transmitted to a program
392by preceding them with `\\'.
393(So, to erase `\\', you need two `#'s).
394.LP
395The `break' or `interrupt' key causes an
396.I
397interrupt signal,
398.R
399as does the
400\s8ASCII\s10 `delete' (or `rubout') character,
401which is not passed to programs.
402This signal
403generally causes whatever program
404you are running to terminate.
405It is typically used to stop a long printout that
406you don't want.
407However, programs can arrange either to ignore
408this signal altogether,
409or to be notified when it happens (instead
410of being terminated).
411The editor, for example, catches interrupts and
412stops what it is doing,
413instead of terminating, so that an interrupt can
414be used to halt an editor printout without
415losing the file being edited.
416.LP
417The
418.IR quit ""
419signal is generated
420by typing the \s8ASCII\s10 FS character.
421(FS appears many places on different terminals, most commonly
422as control-\e or control-\^|\^.)
423It not only causes a running program to terminate
424but also generates a file with the core image
425of the terminated process.
426Quit is useful
427for debugging.
428.LP
429Besides adapting to the speed of the terminal,
430.UX
431tries to be intelligent about whether
432you have a terminal with the newline function
433or whether it must be simulated with carriage-return
434and line-feed.
435In the latter case, all input carriage returns
436are turned to newline characters (the standard
437line delimiter)
438and both a carriage return and a line feed
439are echoed to the terminal.
440If you get into the wrong mode, the
441.IR reset (1)
442command will rescue you.
443.LP
444Tab characters are used freely in
445.UX
446source programs.
447If your terminal does not have the tab function,
448you can arrange to have them turned into spaces
449during output, and echoed as spaces
450during input.
451The system assumes
452that tabs are set every eight columns.
453Again, the
454.IR tset (1)
455or
456.IR stty (1)
457command will set or reset this mode.
458.IR Tset (1)
459can be used to set the tab stops automatically when necessary.
460.LP
461.I
462How to run a program; the shells.\ \
463.R
464When you have successfully logged in, a program
465called a shell is listening to your terminal.
466The shell reads typed-in lines, splits them up
467into a command name and arguments, and executes the command.
468A command is simply an executable program.
469The Shell looks in several system directories to find the command. You can also
470place commands in your own directory and have the shell find them there.
471There is nothing special about system-provided
472commands except that they are kept in a directory
473where the shell can find them.
474.LP
475The command name is always the first word on an input line;
476it and its arguments are separated from one another by
477spaces.
478.LP
479When a program terminates, the shell will ordinarily regain control and type
480a prompt at you to indicate that it is ready for another command.
481.LP
482The shells have many other capabilities, which are described in detail in
483sections
484.IR sh (1)
485and
486.IR csh (1).
487If the shell prompts you with `$', then it is an instance of
488.IR sh (1)
489the standard Bell-labs provided shell.
490If it prompts with `%' then it is an instance of
491.IR csh (1)
492a shell written at Berkeley.
493The shells are different for all but the most simple terminal usage.
494Most users at Berkeley choose
495.IR csh (1)
496because of the
497.I history
498mechanism and the
499.I alias
500feature, which greatly enhance its power when used interactively.
501.LP
502You can change from one shell to the other by using the
503.I chsh (1)
504command, which takes effect at your next login.
505.LP
506.I
507The current directory.\ \
508.R
509.UX
510has a file system arranged in a hierarchy of directories.
511When the system administrator gave you a user name,
512he also created a directory for you (ordinarily
513with the same name as your user name).
514When you log in, any file
515name you type is by default
516in this directory.
517Since you are the owner of this directory, you have
518full permission to read, write, alter, or destroy
519its contents.
520Permissions to have your will with other directories
521and files will have been granted or denied to you
522by their owners.
523As a matter of observed fact, few
524.UX
525users
526protect their files from destruction,
527let alone perusal, by other users.
528.LP
529To change the
530current directory (but not the set of permissions you
531were endowed with at login) use
532.IR cd (1).
533.LP
534.I
535Path names.\ \
536.R
537To refer to files not in the current directory, you must
538use a path name.
539Full path names begin with `/', the name of the root directory of the
540whole file system.
541After the slash comes the name of each directory containing the next
542sub-directory (followed by a `/') until finally the
543file name is reached.
544For example,
545.I
546/\^usr/\^lem/\^filex
547.R
548refers to the file
549.I
550filex
551.R
552in the directory
553.I
554lem; lem
555.R
556is itself a subdirectory of
557.I
558usr; usr
559.R
560springs directly from the root directory.
561.LP
562If your current directory has subdirectories,
563the path names of files therein begin with
564the name of the subdirectory with no prefixed `/'.
565.LP
566A path name may be used anywhere a file name is
567required.
568.LP
569Important commands which modify the contents of files
570are
571.IR cp (1),
572.IR mv (1),
573and
574.IR rm (1),
575which respectively copy, move (i.e. rename) and remove files.
576To find out the status of files or directories, use
577.IR ls (1).
578See
579.IR mkdir (1)
580for making directories and
581.I
582rmdir
583.R
584(in
585.IR rm (1))
586for destroying them.
587.LP
588For a fuller discussion of the file system, see
589`The
590.UX
591Time-Sharing System,'
592by Ken Thompson and Dennis Ritchie.
593It may also be useful to glance through
594section 2 of this manual, which discusses
595system calls, even if you don't intend
596to deal with the system at that level.
597.LP
598.I
599Writing a program.\ \
600.R
601To enter the text of a source program into a
602.UX
603file, use
604the editor
605.IR ex (1)
606or its display editing alias
607.IR vi (1).
608(The standard editor
609.IR ed (1)
610is also available.)
611The principal languages in
612.UX
613are
614provided by the C compiler
615.IR cc (1),
616the Fortran compiler
617.IR f77 (1),
618the Pascal interpreter
619.IR pi (1), px (1),
620the Lisp system
621.IR lisp (1),
622and the APL system
623.IR apl (1).
624After the program text has been entered through
625the editor
626and written on a file, you can give the file
627to the appropriate language processor as an argument.
628The output of the language processor
629will be left on a file in the current directory named `a.out'.
630(If the output is precious, use
631.I mv
632to move it to a less
633exposed name soon.)\
634.LP
635When you have finally gone through this entire process
636without provoking any diagnostics, the resulting program
637can be run by giving its name to the shell
638in response to the shell (`$' or `%') prompt.
639.LP
640Your programs can receive arguments from the command line
641just as system programs do,
642see
643.IR exec (2).
644.LP
645.I
646Text processing.\ \
647.R
648Almost all text is entered through the editor
649.IR ex (1)
650(often entered via
651.IR vi (1)).
652The commands most often used to write text on a terminal are:
653.I
654cat, pr, more
655.R
656and
657.I nroff,
658all in section 1.
659.LP
660The
661.I cat
662command simply dumps \s8ASCII\s10 text
663on the terminal, with no processing at all.
664The
665.IR pr ""
666command paginates the text, supplies headings,
667and has a facility for multi-column output.
668.I
669Nroff
670.R
671is an elaborate text formatting program.
672Used naked, it requires careful forethought, but for
673ordinary documents it has been tamed;
674see
675.IR me (7)
676and
677.IR ms (7).
678.I
679.LP
680.I Troff
681prepares documents for a
682Graphics Systems phototypesetter or a Versatec Plotter;
683it is very similar to
684.I nroff,
685and often works from exactly the same
686source text.
687It was used to produce this manual.
688.LP
689.IR Script (1)
690lets you keep a record of your session in a file,
691which can then be printed, mailed, etc.
692It provides the advantages of a hard-copy terminal
693even when using a display terminal.
694.LP
695.IR More (1)
696is useful for preventing the output of a command from
697zipping off the top of your screen.
698It is also well suited to perusing files.
699.LP
700.I
701Status inquiries.\ \
702.R
703Various commands exist to provide you with useful
704information.
705.IR w (1)
706prints a list of users presently logged in,
707and what they are doing.
708.IR date (1)
709prints the current time and date.
710.IR ls (1)
711will list the files in your directory or give
712summary information about particular files.
713.LP
714.I
715Surprises.\ \
716.R
717Certain commands provide inter-user communication.
718Even if you do not plan to use them, it would be
719well to learn something about them, because someone else may
720aim them at you.
721.LP
722To communicate with another user currently logged in,
723.IR write (1)
724is used;
725.IR mail (1)
726will leave a message whose presence will be announced
727to another user when he next logs in.
728The write-ups in the manual also suggest how to respond to
729the two commands if you are a target.
730.LP
731When you log in, a message-of-the-day may greet you
732before the first prompt.
733.SH
734CONVERTING FROM THE 6TH EDITION
735.LP
736There follows a catalogue of significant, mostly incompatible,
737changes that will affect old users converting from the sixth edition
738on a PDP-11.
739No attempt is made to list all new facilities, or even all
740minor, but easily spotted changes,
741just the bare essentials without which it will be
742almost impossible to do anything.
743.LP
744.I
745Addressing files.\ \
746.R
747Byte addresses in files are now long (32-bit) integers.
748Accordingly
749.I seek
750has been replaced by
751.IR lseek (2).
752Every program that contains a
753.I seek
754must be modified.
755.I Stat
756and
757.IR fstat (2)
758have been affected similarly, since file lengths are now
75932- rather than 24-bit quantities.
760.LP
761.I
762Assembly language.\ \
763.R
764This language is dead. Necromancy will be severely punnished.
765.LP
766.I Stty
767and
768.I gtty.\ \
769.R
770These system calls have been extensively altered,
771see
772.IR ioctl (2)
773and
774.IR tty (4).
775.LP
776.I
777C language, lint.\ \
778.R
779The syntax for initialization
780requires an equal sign = before an initializer,
781and brackets { } around compound initial values;
782arrays and structures are now initialized honestly.
783Assignment operators such as =+ and =\-
784are now written in the reverse order: +=, \-=. This removes the possibility
785of ambiguity in constructs such as x=\-2, y=*p, and a=/*b.
786You will also certainly want to learn about
787.DS
788long integers
789type definitions
790casts (for type conversion)
791unions (for more honest storage sharing)
792#include <filename> (which searches in standard places)
793.DE
794.LP
795The program
796.IR lint (1)
797checks for obsolete syntax and
798does strong type checking of C programs, singly
799or in groups that are expected to be loaded together.
800It is indispensable for conversion work.
801.LP
802.I Fortran.\ \
803The old
804.I fc
805is replaced by
806.I f77,
807a true compiler for Fortran 77,
808compatible with C.
809There are substantial changes in the language;
810see `A Portable Fortran 77 Compiler' in Volume 2.
811.LP
812.I
813Stream editor.\ \
814.R
815The program
816.IR sed (1)
817is adapted to massive, repetitive
818editing jobs of the sort encountered in converting to
819the new system.
820It is well worth learning.
821.LP
822.I
823Standard I/O.\ \
824.R
825The old
826.I
827fopen, getc, putc
828.R
829complex and the old
830.I \-lp
831package are both dead,
832and even
833.I getchar
834has changed.
835All have been replaced by the clean, highly efficient,
836.IR stdio (3)
837package.
838The first things to know are that
839.IR getchar (3)
840returns the integer EOF (\-1) (which is not a possible byte value)
841on end of file, that 518-byte buffers are out, and that there
842is a defined FILE data type.
843.LP
844.I Make.\ \
845The program
846.IR make (1)
847handles the recompilation and loading of
848software in an orderly way from
849a `makefile' recipe given for each piece of software.
850It remakes only as much as the modification dates of the input files
851show is necessary.
852The makefiles will guide you in building your new system.
853.LP
854.I
855Shell, chdir.\ \
856.R
857F. L. Bauer once said Algol 68 is the Everest that
858must be climbed by every computer scientist because
859it is there.
860So it is with the shell for
861.UX
862users.
863Everything beyond simple command invocation from a terminal is
864different.
865Even
866.I chdir
867is now spelled
868.I cd.
869If you wish to use
870.I sh
871(as opposed to
872.IR csh )
873then you will want to study
874.IR sh (1)
875long and hard.
876.LP
877.I "C shell" .\ \
878.IR Csh (1),
879developed at Berkeley,
880has features comparible to
881.IR sh .
882It includes a history mechanism that saves you from retyping all or part
883of previous commands, as well as an efficient aliasing (macro) mechanism.
884These features make
885.I csh
886pleasent to use interactively.
887.I Csh
888programs have a syntax reminiscent of
889.I C,
890while
891.I sh
892command programs have a syntax reminiscent of \s-2ALGOL\s0-68.
893.LP
894.I Debugging.\ \
895.IR Sdb (1)
896is a far more capable replacement for the debugger
897.I cdb,
898and debugs C and Fortran at the source level.
899For machine language debugging,
900.I adb
901replaces
902.I db.
903The first-time user should be especially careful about
904distinguishing / and ? in
905.I adb
906commands, and watching to make sure that the
907.I x
908whose value he asked for is the real
909.I x,
910and not just some absolute location equal to the stack offset
911of some automatic
912.I x.
913You can always use the `true' name,
914.I _x,
915to pin down a C external variable.
916.LP
917.I Dsw.
918This little-known, but indispensable facility has been
919taken over by
920.I
921rm \-ri.
922.LP
923.I
924Boot procedures.\ \
925.R
926Needless to say, these are all different.
927See section 8 of this volume, and
928`Setting up \s8UNIX\s10' in Volume 2.