.HI
.ce
Unix Introduction
.ce
Edited by R.P.A.Collinson
.ce
Document no: DOC/UNIX.K0/1
.sp 5
.ce
Contents
.in+10
.de SC
.sp
.ti-10
Section \\$1 
..
.SC 1
Introduction.
.SC 2
Unix for Beginners by B.W. Kernighan.
.SC 3
The Unix system at U.K.C.
.SC 4
Tutorial introduction to the Unix Text editor
.br
by B.W. Kernighan.
.SC 5
File handling.
.br
cat, chdir, chmod, cp, list, ln, ls, mkdir, mv, pr, prot, pwd, rm, rmdir, unprot.
.SC 6
Editors.
.br
ed, em.
.SC 7
System programs.
.br
ascii, date, kill, mail, off, passwd, ps, stty, ttyn, who, write.
.SC 8
Shell programming.
.br
echo, exit, goto, if, sh, sleep, shift, wait
.sp 5
.in -10
c University of Kent at Canterbury (1977) except for sections
from the UNIX documentation which are reprinted under license from Western Electric
Company, Inc.
.sp3
.ul
Not_to_be_distributed_outside_the_University_of_Kent.
.bp
.ce
UNIX License
.sp 3
.PG
Under the terms of the license for UNIX issued to the
University of Kent by Western Electric Company Inc., the
University is able to issue documentation and consent to use the UNIX system
to its employees and students with the following provisions:
.PG
i) Any software or documentation available for UNIX should be held in
confidence and should not be disclosed to any person outside the University.
.PG
ii) It is understood that the system may not be used for any externally funded projects
(excluding students on SRC or SSRC studentships).
.PG
iii) The use of UNIX implies agreement by the user to the conditions imposed by the license.
.PG
A copy of the UNIX license agreement may be obtained from Dr. R.P.A. Collinson
for an appropriate copying charge.
.pn 1
.bp
.nr s 1
.rm FO
.de FO
'sp 2
'tl ''\\ns / %''
'bp
..
.wh -7 FO
.sp 3
.ce
SECTION 1
.sp
.ce
Introduction
.sp 
.PG
This manual is indended for all users of UNIX.  It contains
parts of the UNIX documentation and also information on the local 
pecularities of our system.  The document does not contain any
programming information and users who wish to program
in 'C' should consult the UKC document "C Programmers Manual".
.PG
UNIX documentation from Bell Labs comes in two volumes, the first
("Documents for use with the UNIX Timesharing System") contains various
papers relating to programs and facilities available on UNIX.  The second
("The UNIX Programmers Manual") has eight sections relating to different aspects of the system.
The eight sections are:
	I.	Commands.
	II.	System calls.
	III.	Subroutines.
	IV.	Special files.
	V.	File formats and conventions.
	VI.	User maintained programs.
	VII.	User maintained subroutines.
	VIII.	Maintenance.
.PG
Each section is sorted alphabetically and has a standard format.  The pages are
referenced by a title and a roman numeral, e.g. cat(I) is a file handling
command in Section I of the manual.
.PG
This document contains two papers from the first volume of UNIX documentation
(Sections 2 and 4) and also has a number of manual pages from Section I of the UNIX
Programmers Manual.  To make access easier for new users the manual pages are
contained in sections with a different topic, each section is prefaced with a short
introduction.
.PG
All users should be aware of the 'help' command.  The 'help' command types
out information of new facilities, alterations to the system and the current
UNIX news-letter.  If 'help' is typed by itself as a command, a brief
index of the currently available help files will be listed; 'help index'
prints a file containing a fuller index. If any of the help files are required type 'help'
followed by the file names.
.PG
Section 3 of this document contains details of our local system, these pages were
originally in the help system but are now not available in that format.  It should be noted
by new users that certain things are different in our local system from the UNIX documentation
and new users should glance at Section 3 of this document before trying the commands
given in 'UNIX for Beginners'.
.PG
The main differences are:
.br
i)	The delete or rub-out key on a teletype
deletes the last character input.
.br
ii)	Control-G is break.
.br
iii)	The 'man' command is not implemented.
.br
iv)	The editor 'ed' is present, but it is much better to use 'em',
these are exactly the same program but are set up with different
parameters.
.br
v)	When logging off use the command 'off',
this will neatly tidy up after you - see Section 3 of this manual for
a page on the 'off' command.
.pn 1
.bp
.nr s 3
.ce
SECTION 3
.sp
.ce
The UNIX system at UKC.
.sp 2
.PG
This section gives information about the local pecularities
of our system and also summarises the information contained
in "Unix for Beginners".
It mostly consists of the print out from a number of 'help'
files.
.bp
.tl 'HELP - BEGINNERS''9-November-76(PC)'
.ce
PECULARITIES OF OUR SYSTEM.
.PG
Our system is much the same as is described in the documentation
in the two UNIX manuals.  There are two main differences:
.ST
Teletype protocol.
.sp
.br
a)	'Break' is now Control G, the Delete key is used to rubout characters
on the line.
.br
b)	'Delete' will delete the last character which was input.  The
current erase character will still be in force - so you will
have two different
keys meaning delete the last character. 
These keys are normally # and the Delete key itself.  You can just make the
Delete key do the work (freeing the # key) by using stty - see below.
.br
c)	Control Z will temporarily halt output on the teletype, another
character will start output again.
.br
d)	The characters Control A to Control F, Control N to Control Y (inclusive)
are echoed as up-arrow (^) followed by the upper case letter.  This is
useful if you wish to change the characters for rubout and  kill the line.
To change 'kill' to ^U and the erase character to be only the Delete key say
.TI
stty kill ^U erase \\(delete)
.br
where ^U stands for Control U - a single key depression.
.br
All deletes will then be echoed as #.  The escape (back-slash) before the
delete is important.  Say
.TI
stty
.br
to check that you've got it right.
.ST
Disc Structure.
.PG
The file system is split over two discs.
You will find that when you log into the system your
directory is called
.ti +10
/usr/rk1/bloggs
.br
not
.ti +10
/usr/bloggs
.br
as it says in the documentation.  This is because I found
it easier to split the
system is the /usr directory itself.  The pwd (print working directory) command
will reply
.ti +10
bloggs
.br
because the top level of your directory is on the
boundary between the two RK05's.
.bp
.ce
Alteration of the login program
.sp 3
.PG
The login program has been altered to allow an additional feature. 'login'
asks for a login name and a password (if one has been set up).  Assuming
all is well it then looks for a file called '.init' on the user's directory which
should contain shell commands.  If this file is found it is executed before control is passed to the
user.
.PG
The main intention of this facility is to allow users to set up their teletype
using stty(I) before they are fully logged in.  However any other commands may be
placed in the '.init' file;  users should beware of invoking the shell from the file.
.bp
.tl 'HELP - SYMBOLS''9-November-76(PC)'
.sp 2
.ce
LIST OF UNIX SPECIAL SYMBOLS.
.ST "Teletype Control Characters."
.sp
.ce
NOTE THESE ARE SLIGHTLY DIFFERENT FROM THE DOCUMENTATION.
.sp 
.in +10
.TL #,DELETE
Erase last character - can be changed see STTY(I).
.TL @
Erase last line - can be changed see STTY(I).
.TL \\\\
Escape - input before any character to transmit # @ and \\ to
the program.
.TL ^D
Control D - End of Text character - might log you off.
But if you intentionally wish to log off say 'off'.
.TL ^G
Control-G - Break.
.TL "^\\\\"
Control \\ - The ASCII FS symbol is used to cause a quit, which is the same as
the action of the ^G key except that the user core is dumped
in a file called "core".
.in -10
.ST "Program Control."
.PG
For more detail of the
characters
mentioned in this section see SH(I).
.sp 2
.in +10
.TL "p > o"
Output from a program to a file.
.TL "p < i"
Input to a program from a file.
.TL |
Filter - output of one program to the input of another.
.TL &
Placed at the end of a line means detach from the process
which has just been specified
and leave it running.  UNIX replies
with a process number which may be used to kill the process - see
PS(I), KILL(I) and SH(I).
.TL >>
Append standard output to a file - similar to > except does
not delete the named file.
.in -10
.bp
.tl 'HELP -FILES''4-May-76(PC)'
.sp 2
.ce
FILE CONTROL.
.PG
This file contains a brief list of
the most used UNIX file handling programs.
Every file is referenced by a 'pathname', if the
pathname starts with
.in +10
.TL " /"
The search for the file starts at the root.
.TL " ."
The search for the file starts at the current
directory.
.TL " .."
The search for the file starts at the level above the
current working directory - the 'parent' directory.
.TL " name"
The search for the file starts
in the current directory.
.in -10
.ST "Name matching."
.ti +10
A file name used in a search may contain several
wild characters to enable a group of similarly named files
to be referenced.  Note that the matching is performed before
the command is executed and only refers to the current directory.
These special characters are:
.in +10
.TL *
Match with any sequence of characters of any length.
.TL ?
Match with any single character.
.TL "[  ]*"
Match with any of the characters within the brackets,
.ti +10
i.e z[12345] matches z1 z2 z3 z4 z5
.ti +10
and z[a-f] matches za zb zc zd ze zf.
.TL """"""
Escapes all the above characters, double quotes are also used
to enable
spaces to be input in argument strings.  Arguments are separated by
spaces unless enclosed in "".
.in -10
.ST "File handling programs."
.ti +10
For more details on these programs see Section 5 of this
document.
.in +10
.TL ls
Summarise current directory.
.TL pwd
Print working directory name.
.TL chdir
Change working directory.
.TL chmod
Change access mode on a file.
.TL cp
Copy a file, does not delete the old file.
.TL mv
Rename a file, deletes the old file.
.TL rm
Remove a file.
.TL mkdir
Make a directory.
.TL rmdir
Remove a directory (must be empty).
.TL cat
Copy a file to the standard output, used mainly for rough
file listing.
It is generally better to use pr for file listing when good
copy is required.
.TL pr
Print a file with some formatting - use argument -wd
for the Decwriter.
.TL list
List a file on the output device with or without line numbers - this program calls pr
with arguments correctly specified for the Dec-writer.
.in -10
.bp
.tl 'HELP -IODEV''14-February-76(PC)'
.sp 2
.ce
DECWRITER.
.PG
With the current set position of the Decwriter platen it is
difficult to read the information written
on the page because of the nasty bit of metal.  I have changed the
system so that the page can be inset to the right.
The Decwriter is set automatically at login but to do it manually
say
.ti +10
stty dec
.br
If you press return after the next % you will see that
the page is indented 5 spaces to the right. To turn this indenting off
say 
.ti +10
stty -inset
.br
as before stty by itself will tell you what is set up for you.
.pn 1
.bp
.nr s 4
.ce
SECTION 4
.sp
.ce
A Tutorial Introduction to the UNIX text Editor
.sp 3
.PG
The following paper describes the UNIX editor 'ed'.  We currently have
a more advanced editor 'em', which is much easier to use. 'em' and 'ed'
are effectively the same editor except that 'em' gives
prompts in the form of
.br
	>
.br
before each command line.  See Section 6 of this manual for detailed descriptions of 'ed' and 'em'.
New users are advised to use 'em'.
.pn 1
.bp
.nr s 5
.ce
SECTION 5
.sp
.ce
File handling.
.sp 3
.PG
This section contains manual pages for the most important file
handling commands on the UNIX system, the programs described are:
.in +10
.TL "cat"
list a file, if you wish to have a listing of a long file paginated with a heading use 'pr', 'list'
will give you a listing of a file with line numbers.
.TL chdir
change current directory.
.TL chmod
change the access mode on a file.
.TL cp
copies data from one file to another (does not delete the first file).
.TL list
A UKC produced program to list files with or without line numbers.
.TL ln
Make a link to a file, does not copy any data but justs sets a pointer to the file.
.TL ls
summarise a directory.
.TL mkdir
make a directory.
.TL mv
effectively renames a file, but will move it about the file system if necessary.
.TL pr
print a file  with headings but no line numbers.
.TL prot
protect a file from being over-written or deleted (see below).
.TL pwd
print current directory name, if you are currently in  /usr/rk1/fred it will only print 'fred'.
.TL rm
delete a file.
.TL rmdir
delete a directory - will not unless the directory is empty.
.TL unprot
allow writing on a file.
.in-10
.sp 3
.PG
It is very easy to delete or overwrite important files unless you ensure that the correct file 
protection is set up for them.  To make this easier two
programs have been written, 'prot' which sets the protection to prohibit writing or deleting a file
and 'unprot' which allows writing. It is
a good idea to get into the habit of protecting your files, perhaps by including a call to prot in the '.off'
file (see off(I) in Section 3) and a call to 'unprot' in the '.init' file.
.pn 1
.bp
.nr s 6
.sp 3
.ce
SECTION 6
.sp 2
.ce
Editors
.sp 2
.PG
This section contains the manual pages for 'ed' and 'em'.  On the whole
it is better to use 'em'.
.pn 1
.bp
.nr s 7
.sp 2
.ce
SECTION 7
.sp 2
.ce
System programs
.sp 2
.PG
This section contains manual pages for various useful
system programs, there are:
.sp 2
.in+10
.TL "ascii"
A table of ASCII characters and their octal equivalents.
.TL "date"
print current date.
.TL "kill"
Terminate processes.
.TL off
Log off UNIX.
.TL mail
send and receive mail.
.TL passwd
change your login password, please set a password to prevent un-authorised usage of UNIX.
.TL "ps"
Print process status, useful for looking at what is going on in the system.
.TL stty
set up a teletype.
.TL ttyn
give current teletype name.
.TL who
who is on the system and where.
.TL write
write to another logged in user.
.sp 2
.in -10
.pn 1
.bp
.nr s 8
.sp 2
.ce
SECTION 8
.sp 2
.ce
Shell programming.
.sp 2
.PG
This section gives the manual pages relating to the shell
(or command processing program).  New users need not bother about reading this
section until they are more familiar with the system.
.PG
Anything which you are able to type in as a command on a teletype may be put in
a command file and executed by the shell.  If the file name is 'cmd', say
	sh cmd
.br
to execute the file.  If the mode of the file is set to 'execute' (see chmod(I))
the file may be executed directly as a command, say
	cmd
.br
by itself to call the file.
.PG
Command files may be parameterised and tests performed on the results
of programs.  The following pages give you information on how to
write more complex command files, the pages are:
.sp 2
.in+10
.TL echo
echo arguments - useful for messages from command files.
.TL exit
exit from a command file.
.TL goto
goto a labelled line in a command file.
.TL if
test conditions and perform operations depeding on the result.
.TL sh
the shell program itself, this should probably be read first.
.TL sleep
suspend execution for an interval.
.TL shift
manipulate the arguments to a command file.
.TL wait
Wait for processes to finish.
.in -10
