<<inapoi la documentatie<<

Information Services

Introduction to UNIX

Edition: 4.2 S.Barbaresi & D.Roberts

Date: November 1997 Applications Support Group

e-mail: d.roberts@bangor.ac.uk



Introduction to UNIX Page 2

Tips to remember:

+ UNIX is case sensitive

+ Case sensitivity also applies to passwords

+ Only ONE version of a file is saved

+ To logout of the system use ctrl-d or type 'logout'

+ An interrupt can be issued with ctrl-c

+ Many programs will terminate with a ctrl-d

Introduction to UNIX

This service course is intended to demonstrate the rudimental of UNIX and give you a flavour

of what is available, so by the end of the session you should have gained enough knowledge to

manipulate files and issue simple commands.

An operating system is a means of communicating with a computer; on a VAX the operating

system is VMS, on a PC it is DOS, and on a Alpha it is UNIX. UNIX is one of the most popular

operating systems in the World, it runs on more platforms than any other, it is not tied down to

any architecture and it has a rich assortment of utilities and commands.

UNIX is available on so many platforms there is no need to learn a new operating system each

time you change hardware vendor, it is far cheaper than any other operating system, and it is

slowly standardising itself. The problem many new users discover is the fact it was designed by

computer specialists for computer specialists, and consequently the syntax of the commands are

very user unfriendly. But X Windows has conquered this problem.

Connection via a PC

To access a UNIX host from a PC in one of the computer rooms a connection must be made to

it from either DOS or Winows, this is done by means of a program called telnet. We shall be using

a UNIX host called thunder.

Thunder is the name given to the newest and fastest machine the University possesses.

It is a Digital 2100 Server Model A500MP and was purchased to provide the UNIX based

compute server. The configuration is a three processor system with 384Mb of main

memory and 10 Gbytes of disk. The operating system is Digital's OSF/1 unix.

Here is an example of a telnet call:{NFS} M:\>telnet thunder OR

Note: if you need to use graphics orwould like a multi-windows environment then you can use eXceed/W rather than


{NFS} M:\>telnet thunder

OSF/1 (thunder) (ttyp8)

login: iss133


Last login: Tue Oct 11 09:45:22 from simone

DEC OSF/1 [EXT] V3.2 (Rev. 214); Mon Apr 24 16:15:57 BST 1995

DEC OSF/1 V3.2 Worksystem Software (Rev. 214)

Welcome to Thunder!


| If you have any problems using this system or software on this system |

| please send E-mail to: |

| helpdesk |

| |

| explaining in sufficient detail what you require help with. |


Good Morning! There are currently 6 user(s) running 30 programs.


Below is what you should see when you login to thunder.


To exit the system use:

thunder:/homedir/iss133> exit


yppasswd will change a user's password, by first prompting the user for the old password followed

by the new password which is then typed in again for verification. The password can be of any

length but must be greater than six characters, and the characters can be any

letter/digit/punctuation mark or escape sequence.

thunder:/homedir/iss133> yppasswd iss033

Old NIS Password: <bangorpass>

New Password: <banana23>

Verification: <banana23>

NIS Passwd changed on clss1

Note: you should not allow any other person to login as you, if you think your account

has been compromised then please change your password.



Introduction to UNIX Page 4

The Editor

Unlike DOS where file names cannot use certain characters and a file has a concept of prefix and

suffix, UNIX has no restrictions on characters or on the form of the file name, as the example

below illustrates:


Note: Directories don't have to have an extension of dir.

There is an editor available on thunder that is identical to the editor on the VAX, it is called edt,

and has the same functionality as edt on the VAX. A file is created by the following command

(note the -nodisplay command line option):

thunder:/homedir/iss133> edt -nodisplay new_file

Remember that a word processor is just a glorified editor, so editors you find on a multi-user

machines are simplified word processors.

To exit edt press: ctrl-Z

then type exit

at the asterix (*) prompt.

Listing Files

The command 'ls' is used to list files, on its own it provides a brief listing which only includes the

file name, but ls can take many options:

thunder:/homedir/iss133> ls -l long listing

-rw-rw-rw- 1 iss033 is 14683 Sep 25 16:58 autumn95.wp6

drwxrws--- 2 iss033 is 2048 Aug 23 15:07 bin

-rw-r--r-- 1 iss033 is 3970 Sep 29 09:40 country-codes

drwxrwsrwx 2 iss033 is 512 Apr 28 10:39 cpm

thunder:/homedir/iss133> ls -t displays the files in chronological order

-rw-r--r-- 1 iss033 is 3970 Sep 29 09:40 country-codes

-rw-r--r-- 1 iss033 is 72475 Sep 28 09:52 reg.ps

-rw-rw-rw- 1 iss033 is 14683 Sep 25 16:58 autumn95.wp6

thunder:/homedir/iss133> ls -lat does all of the above

-rw--w--w- 1 iss033 is 2445 Oct 2 09:17 .Xauthority

-rw-r--r-- 1 iss033 is 8863 Oct 2 08:58 .pinerc

drwxr-sr-x 3 iss033 is 1024 Sep 29 15:19 win

-rw-rw-rw- 1 iss033 is 14668 Sep 29 15:18 htmlref.wp6

thunder:/homedir/iss133> ls -a displays hidden files



Introduction to UNIX Page 5

thunder:/homedir/iss133> ls -l data.dat long listing of the file data.dat

-rw-rw-rw- 1 iss033 is 1106 Aug 24 17:14 data.dat

thunder:/homedir/iss133> ls -la .login login listing of the hidden file .login

Viewing Files

To display the contents of a file on the screen the command:

thunder:/homedir/iss133> more file

is used, where the following key strokes have a special meaning:

<space> forward a page

b back a page

<return> forward a line at a time

/ search for a word

q quit

Copying Files

The command cp is used to make a duplication of a file, the only difference being its name:

thunder:/homedir/iss133> cp original new

thunder:/homedir/iss133> cp document.wp new_document.wp

Deletion of Files

To remove a file use the remove command:

thunder:/homedir/iss133> rm file_name

thunder:/homedir/iss133> rm new_document.wp

Renaming of Files

Renaming of files is accomplished with the move command:

thunder:/homedir/iss133> mv file new_file

thunder:/homedir/iss133> mv old_letter.wp new_letter.wp


The UNIX manual can be accessed from the command line by the command man. man displays

information from the reference manuals which are complete manual pages that you select by title.

thunder:/homedir/iss133> man cp help on copy

thunder:/homedir/iss133> man joe displays the man page on joe

thunder:/homedir/iss133> man lpr man page on local printing (lpr)




ab ee os is so ma ou

iss001 iss002 iss003 iss004 iss033 iss036 iss026

project source programs wordperfect quattro paradox

letters courses

UNIX internet programming




dev etc tmp homedir var

File Store Structure

The print command used on a UNIX host, is lpr followed by a -P<printer name>

thunder:/homedir/iss133> lpr -Plg01 file

omitting the -P (capital P) will cause the file to be printed on the default printer, the flag -P

indicates a specific printer. The printers that are available are (See APPENDIX B, for full list):

clmps1 monochrome postscript

clcps1 colour postscript, 30p/sheet

lg01 80 column dot matrix print

File Store Structure

Unlike a personal computer where a sole user owns all the files on the machine, a multi-user

machine such as a UNIX host will have many users, thus there needs to be some sort of file

organisation as to segregate the different users.

As can be seen from the diagram on the previous page, every user has a portion of the filestore

devoted to them. The way the filestore is divided is by the use of directories. The file store can be

compared to a filing cabinet, you would not put all your documents in the one folder, and

consequently you would not put all files into the one directory. Files are seen as documents, and

directories can be thought of as folders. When you login into the system it automatically places

you in your home directory.

Manipulating Directories/Folders

To create a folder the following command is used:



Introduction to UNIX Page 7

thunder:/homedir/iss133> mkdir directory_name

Directories can be used to arrange work into different folders for example, spreadsheet, word

processing, databases, programming:

thunder:/homedir/iss133> mkdir wordperfect

thunder:/homedir/iss133> mkdir quattro

thunder:/homedir/iss133> mkdir programming

thunder:/homedir/iss133> mkdir paradox

To navigate around the directory hierarchy you can use cd:

thunder:/homedir/iss133> cd wordperfect (change directory to wordperfect)

thunder:/homedir/iss133> mkdir personal courses (make dir personal and courses)

thunder:/homedir/iss133> cd personal (change dir. to personal)

thunder:/homedir/iss133> cd .. (change directory to wordperfect, ie parent)

thunder:/homedir/iss133> cd .. (go up one level again, ie the home dir)

to find out where you are in the hierarchy the command present working directory can be used:

thunder:/homedir/iss133> pwd

to return to your login directory (your home directory) type:

thunder:/homedir/iss133> cd or

thunder:/homedir/iss133> cd ~

to remove a directory use:

thunder:/homedir/iss133> rmdir directory_name

thunder:/homedir/iss133> rmdir wordperfect [Note: The dir. must be empty!]

I/O Redirection

Normally any input will come from the keyboard and any output will be displayed on the screen,

this can be modified by using input/output redirection. This is accomplished by utilising the

following metacharacters:

> direct the output to a file

>> append the output to a file

< direct the input from a file

For example,

thunder:/homedir/iss133> ls -l >> filelist Appends the directory listing to "filelist"

thunder:/homedir/iss133> sort < filelist Sort the file to alphabetic order

thunder:/homedir/iss133> cat file1 file2 > allfiles Directs file1/2 to allfiles

thunder:/homedir/iss133> who > loggedin Lists loggedin users in file "loggedin"



Introduction to UNIX Page 8


A pipe is a means of connecting the output of one command to the input of another, there are two

advantage in doing this; first, there is no temporary file space required, and secondly output can

start coming out of a pipeline before the input has fully completed. Here are a few examples of


thunder:/homedir/iss133> ls -l | more Page the output from the ls command

thunder:/homedir/iss133> ls | wc -l Count the number of files in a dir

thunder:/homedir/iss133> who | wc -l Count the number of user logged in

thunder:/homedir/iss133> ls -l | grep file Search for a particular file in a dir

thunder:/homedir/iss133> man cp | lpr print the man page on cp

Electronic Mail

Electronic mail: is a method of sending messages to different users via the computer, it is the

most popular form of inter-computer communication, probably because it is far quicker and

cheaper than normal postal mail and consequently far easier to exchange information. It is even

quicker than the FAX and much cheaper. Most default utilities on UNIX are very difficult to learn

and master, and the mailer is no exception, which is why most users use pine as opposed to mail.

Addressing Schemes: just like any person has a home address, there is an equivalent home

address for each computer user. Each user has a unique username which identifies them in the

Bangor domain, and the domain Bangor is part of the academic domain, which is a member of the

United Kingdom, so my address becomes:


Any user in the world can be identified by their unique user address, and consequently electronic

mail can be addressed to them. In general the form of the address is as follows:

machine - the machine name (for example, thunder)

bangor - town or organisation

ac - type of organisation (company, government, academic, military)

uk - country

All countries follow this addressing convention, where the country is the last part of the address,

apart from the US where it denotes the type of organisation - com, edu, mil or gov.


A program that offers users the ability to read and write mail is called a mailer, the one we

recommend is pine because of its ease of use. To run pine, enter pine on the command line. The

screen that will be presented is the main menu of pine from here you can send and read mail, each

screen that is presented will reserve the bottom two lines for on-line help. To send a message

PINE 3.90 MAIN MENU Folder: INBOX 13 Messages

? HELP - Get help using Pine

C COMPOSE MESSAGE - Compose and send a message

I FOLDER INDEX - View messages in current folder

L FOLDER LIST - Select a folder to view

A ADDRESS BOOK - Update address book

S SETUP - Configure or update Pine

Q QUIT - Exit the Pine program

Copyright 1989-1994. PINE is a trademark of the University of Washington.

? Help P PrevCmd R RelNotes

O OTHER CMDS L [ListFldrs] N NextCmd K KBLock

you must first compose it, before sending it. To read a mail item go into folder list and INBOX,

use the arrow keys to navigate through the index.

Main Menu Level

On entering pine this is the screen that will be presented to the user, and from here all functions

can be accessed.

Message Compose Screen - Sending A Message

To send a message to a user you must select the compose feature from the top level, which will

result in the following screen.



Introduction to UNIX Page 10

PINE 3.90 COMPOSE MESSAGE Folder: INBOX 13 Messages

To : iss033

Cc :


Subject :

----- Message Text -----


this is where the message is type in by the user.



^G Get Help ^X Send ^R Read File ^Y Prev Pg ^K Cut Text ^O Postpone

^C Cancel ^J Justify ^W Where is ^V Next Pg ^U UnCut Text^T To Spell

There are a number of fields to note in this screen:

to: this is where the destination address is entered. Below are a few examples of addresses:

to: iss033, abu147, phil@manweb.co.uk

to: simone@bangor.ac.uk

to: osp123@sos.bangor.ac.uk

to: rosa@durham.ac.uk

to: marco@plaza.aarnet.edu.au

cc: the cc filed is used to send a copy of a message to a number of other people, for example:

cc: iss033, iss008

cc: phil@manweb.co.uk, roy@norweb.co.uk

Attachment: at this point you can include any file, even a WordPerfect file, for example

Attachmnt: course1.wp

Attachmnt: spread.wb1, letter.wp

Subject: here is where the subject of the mail item is entered

Subject: Minutes of Meeting 10/12/94

Subject: Construction Work

the message: below the Message Text line is where the users enters their message. Since this

part is based on the pico editor, then any function that is available to pico is available to the

Message Text. To insert an ordinary text file (ASCII) into the Message Text then press ctrl-R and

enter the file name.



Introduction to UNIX Page 11



INBOX sent-mail saved-messages courses

received sent sentmail wastebasket

? Help M Main Menu P PrevFldr - PrevPage D Delete R Rename

O OTHER CMDS V [ViewFldr] N NextFldr Spc NextPage A Add

PINE 3.90 FOLDER INDEX Folder: INBOX Message 13 of 13

+ 1 Jul 21 T.E.Preece (500) mosaic and images

2 Jul 25 Mr. D.Roberts (3,567) dir/date and dir *.dir

+ 3 Sep 12 pine390-DocServer@ (22,347) Pine info you requested (last changed

4 Sep 15 BITNET list server (4,940) You are now subscribed to the ROADMAP

5 Sep 15 BITNET list server (899) Output of your job "iss033"

+ 6 Sep 16 Mr T. Crummey (985) Re: login

+ 7 Sep 19 Mr. C.S.Wilding (1,135) newsnet

+ 8 Sep 21 Ifor G. Jones (752) Re: HotMetal

+ 9 Sep 23 Mr T. Crummey (1,325) Re: e-mail and file store problems

10 Sep 25 Jones, E (2,266) RE: hello

+ 11 Sep 27 Brian Kelly (1,516) Re: forms and www

12 Sep 27 Patick Douglas Cri (8,087) ROADMAP TRAFFIC REPORT - SEPTEMBER 25

+ 13 Sep 28 psp022@uk.ac.bango (1,684) what a lot of gauls !

? Help M Main Menu P PrevMsg - PrevPage D Delete R Reply

O OTHER CMDS V [ViewMsg] N NextMsg Spc NextPage U Undelete F Forward

Folder list - Reading a New Mail Message

On entering pine it will notify the user of any new mail messages they may have. All new message

are stored in the INBOX, which can be accessed from the FOLDER LIST option in the main


To access any mail folder from the folder index then highlight the folder, with the arrow keys, and

press return, this will display an index of that particular folder.

Folder Index Screen

From this screen all message can be accessed

Use the arrow keys to go up and down the index and enter to view a mail item. Other useful keys


d mark a mail item for deletion

f forward the mail item to another user



Introduction to UNIX Page 12

PINE 3.90 ADDRESS BOOK Folder: INBOX Message 13 of 13

pwd R.P.Wood, Mr. iss026@clss1.bangor.ac.uk

sims simy iss033

max York, Max iss032

freinds Friends DISTRIBUTION LIST:




[Now in addressbook .addressbook]

? Help M MainMenu P PrevEntry - PrevPage D Delete S CreateList

O OTHER CMDS E [Edit] N NextEntry Spc NextPage A Add Z AddToList

r reply to the author of the received message

i returns to the index - lists all mail items in the mailbox

y prints the item on a pre-specified printer

s extracts and saves a message in a named file

t take address and place in address book

Address Book Screen

Very often it is more convenient and more memorable to assign a nick name or alias to an address

of a user name, this can be done with the address book. Occasionally the same message needs to

be sent to a number of different user names, this is either achieved by entering each user name at

the to prompt of the compose message, or a far better way, is to create a distribution list. Below

is the address book screen with aliases and a distribution list called friends.

Useful Internet Commands

Finger: a simple way to establish if an e-mail has arrived at its destination is to use finger, this

command will display the number of unread e-mail messages, and the contents of their .plan file.

The format of the command is:

thunder:/homedir/iss133> finger user@address

thunder:/homedir/iss133> finger carol@sol.cs.ruu.nl

thunder:/homedir/iss133> finger iss033@vaxa.bangor

thunder:/homedir/iss133> finger @vaxa

thunder:/homedir/iss133> finger buckmr@rpi.edu

Who’s Who at Bangor

Often a username is known but not the real name, or visa versa, therefore a useful command to

know is whos which will either give details about the surname or the username:

thunder:/homedir/iss133> whos string

thunder:/homedir/iss133> whos barbaresi

Username | Real Name




Introduction to UNIX Page 13

iss033 | S.L.Barbaresi

thunder:/homedir/iss133> whos jones abs

Username | Real Name


abs028 | Dr. D.R.Jones

abs048 | S.J.Jones

abs047 | J.W.Williams-Jones

thunder:/homedir/iss133> whos os


talk can be used to talk to people on any machine in any part of the world assuming they are

connected to the world wide network called the internet. To exit talk use ctrl-d

thunder:/homedir/iss133> talk iss033

thunder:/homedir/iss133> talk iss033@kirk

thunder:/homedir/iss133> talk harry@pluto.madrid.ac.es

File transfer from a remote machine

The method used for transferring files from remote machines to local machines is ftp, for this to

work both machines must be able to run ftp (ie, must be talking TCP/IP). To access a file on

another machine you must first have its Internet address.

If the file you are transferring is a binary file, such as a WordPerfect document then you must issue

the binary command at the ftp prompt before you "get" the file.

Additional commands that are available from the ftp prompt are:

get - transfers a file from the remote machine to the local machine

put - transfers a file from the local machine to the remote machine

mget - receives multiple files

mput - sends multiple files

help - displays help information

status - displays technical information about the connection

thunder:/homedir/iss133> ftp vaxa

Connected to vaxa.

220 vaxa FTP Server (Version 3.2) Ready.

Name (vaxa:iss033): iss033

331 Username ISS033 requires a Password.

Password: password

230 User logged in.

Remote system type is VMS.

ftp> cd mtb

250 CWD command succesful.



Introduction to UNIX Page 14

ftp> dir

200 PORT command successful.

150 Opening data connection for (,1796)

Directory DISK$IS:[ISS033.MTB]

BLOOD.MTW;2 1/4 1-JUL-1992 [ISS033] (RWE,RWED,,)


DATA.DAT;1 1/4 28-MAY-1992 [ISS033] (RWE,RWED,,)

Total of 3 files.

226 LIST Directory transfer complete.

ftp> get data.dat

200 PORT command successful.

150 Opening data connection for data.dat (,1798)

226 Transfer complete.

43 bytes received in 0.036 seconds (1.2 Kbytes/s)

ftp> quit

221 Goodbye.


Configuring Your UNIX Session

There are two important files which defines your Unix environment. They are:called:




These two files are obeyed every time you login to the system and many packages (e.g. UNIRAS)

assume that these files are correctly set up. These are just ASCII text files which you can edit

yourself but be careful since an incorrectly laid out .login or .cshrc can stop you from working!

You will notice lines starting with alias which is a way of using your favourite command names,


alias type 'cat \!*'

In your .cshrc file will let you use type to display a file.

Often, when using eXceed/W, you need to check an environment variable called DISPLAY.

You can check it with the command:


and define it with the command:

setenv DISPLAY nescafe:0

(nescafe is one of the Pentium PCs in G2)

Other Topics:

grep -- search file(s) for given strings

sort -- flexible sorting command

find -- multi-purpose file-lookup program

script -- record your commands



Introduction to UNIX Page 16

APPENDIX B - Printers available on the UNIX service

The following printers are available from any UNIX host

Name Format Pages/ Double Colour Cost Width

Side Sided

clmps1 PostScript 1 No No 10p A4

clmps2 PostScript 1 Yes No 15p A4

clmps4 PostScript 2 Yes No 15p A4

clman1 ASCII 1 No No 10p A4

clman2 ASCII 1 Yes No 15p A4

clman4 ASCII 2 Yes No 15p A4

almps1 PostScript 1 No No 10p A4

clcps1 PostScript 1 No Yes 30p A4

clcps2 PostScript 1 No Yes 20p A4

clmlp1 ASCII 1 No No none 80 col

clfx1 ASCII 1 No No none 80 col

cllp ASCII 1 No No none 132 col

lj250 sixel 1 No Yes 20p A4

clhp HP Plotter 1 No Yes 10p A4/A3



Introduction to UNIX Page 17


Title: Mastering SunOS

Authors: Brent Heslop and David Angell

Publisher: Sybex

Edition: 1990

ISBN: 0-89588-683

Comment: A good, comprehensive hand-on text to SunOS and OpenWindows ...

Title: UNIX Shell Programming

Authors: Stephen Kochan and Patrick Wood

Publisher: Hayden

Edition: 1990

ISBN: 0-672-48448-X

Comment: A classic on using and programming Bourne Shell (and Korn Shell) ...

Title: The Waite Group's UNIX Communications

Authors: Bart Anderson, Brian Costales & Harry Henderson

Publisher: Sams

Edition: 2nd ed. 1991

ISBN: 0-672-22773-8

Comment: A really excellent book on e-mail (Mail, elm), netnews (rn, nn) and UUCP ...

Title: The UNIX Programming Environment

Authors: Brian Kernighan and Rob Pike

Publisher: Prentice-Hall

Edition: 1984

ISBN: 0-13-937681-X

Title: The Whole Internet - User's Guide & Catalog

Author: Ed Krol

Publisher: O'Reilly

Edition: Second 1994

ISBN: 1-56592-025-2

Comment: Definitely a MUST for any new and not-so-new Internet users

Title: Advanced Programming in The UNIX Environment

Author: Richard Stevens

Publisher: Addison-Wesley

Edition: 1992

ISBN: 0-201-56317-7

Comment: Highly Recommended for programmers

Title: A Directory of Electronic Mail Addressing & Networks

Author: Donnalyn Frey & Rick Adams

ISBN: 1-56592-031-7



Introduction to UNIX Page 18

Title: UNIX in a Nutshell: Desktop Quick Reference for SV & Solaris 2.0

Author: Daniel Gilly & the staff

Publisher: O'Reilly & Associates

Edition: 2nd Edition June 1992 ISBN: 1-56592-001-5

Comment: "...the most comprehensive quickref on the market, a must for any UNIX user..."

Title: UNIX Power Tools

Author: Jerry Peek , Mike Loukides , Tim O'Reilly, & others

Publisher: Bantam ISBN

Edition: 1st

ISBN: 0-553-35402-7

Comment: ideal for UNIX users who hunger for technical--yet accessible--information.



Introduction to UNIX Page 19

UNIX Practical

1. Connection + connect to a UNIX host - thunder

2. Passwords + set your password

3. The editor + create a file with the edt editor (Hint: edt -nodisplay report.txt)

4. Directory + use ls in its various forms to list the directory

5. Type + look at the file with more

6. Files + copy the file a few times (Hint: cp report.txt report.save)

(Hint: cp report.txt report.new)

+ delete one of the copies (Hint: rm report.save)

+ rename a file (Hint: mv report.new 1995-annual-report.txt)

7. Printing + print the newly created file with lp (Hint: lp 1995-annual-report.txt)

8. Quota + How much quota have you?

9. Help + Use the on-line manual to obtain help on intro

10. Mail + issue the pine command for mail and send a message

+ read a new mail message

+ create a mail alias

+ create a signature file: (Hint: edt -nodisplay .signature)


<<inapoi la documentatie<<