0% found this document useful (0 votes)
12 views64 pages

MLIL 001 (English)

The document is a lab manual for the PGDLAN program at Indira Gandhi National Open University, aimed at enhancing the competencies of library and information professionals in an automated environment. It includes detailed sections on various topics such as computer introduction, library automation, information systems, networking, internet resources, content development, and programming, with practical exercises for each course. The manual serves as a user-friendly guide for learners to work under the supervision of instructors, emphasizing practical skills in technology and library management.

Uploaded by

casadoorlib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views64 pages

MLIL 001 (English)

The document is a lab manual for the PGDLAN program at Indira Gandhi National Open University, aimed at enhancing the competencies of library and information professionals in an automated environment. It includes detailed sections on various topics such as computer introduction, library automation, information systems, networking, internet resources, content development, and programming, with practical exercises for each course. The manual serves as a user-friendly guide for learners to work under the supervision of instructors, emphasizing practical skills in technology and library management.

Uploaded by

casadoorlib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

Ite~1Indira Gandhi PGDLAN

~ National Open University


School of Social Sciences

Pr. .
°Ject

LA8 MANUAL
"~lffT 1fPfCl qff ~rfFffw- ~ qmfr ~ ~ 317Vf
.cff ~ -if rrT ~ <'17Cfm'?{ qfJ '#fTCffl CffT 31Tem- '*
~I IJ'Rf rT21T 3RJ ",I'<on W-. i3fCF:r vrrffr vel
mrr RltSflff1731T qff err cpffl $V ~ qff ~
~ GiWBOTffI ~ In

. "Education is a liberating force, and in our


age it is also a democratising force, cutting
across the barriers of caste and class,
smoothing out inequalities imposed by birth
and other circumstances. "

- Indira Gandhi
lte'l\i Indira Gandhi PGDLAN
~.Jt National Open University
LAB MANUAL
School of Social Sciences

MLIL-OOl . Introduction to Computers


09
Section 1 MS-DOS
18
Section2 . Windows98
34
Section3 Unix

MLIL-002 Library Automation


65
Section 1 AcquisitionModule
89
Section2 CataloguingModule

101
Section3 CirculationModule
113
Section4 SerialsControl Module

MLIL-003 Information Systems


127
Section 1 DesigningDatabase in MS SQL Server

MLIL-004 Networking and Internet Technology

Section 1 NetworkComponents 147

Section2 SettingUp a NetworkConnectivityunder WindowsEnvironment 156

Section3 Network Servicesand Protocols 170

Section4 WebBrowsersand Search Engines 191

Section5 AccessingLibrary and Information Networks 206


r

MLIL-005 Internet Resources

Section 1 Internet Resources 221

MLIL-006 Content Development

Section 1 HTML Thtorial


249

Section 2 XML : Extensible Markup Language 263

Section 3 Z 39.50 Standard for Retrieval . 268

* MLIL-007 Programming

Section 1 ,'Java
277

Section 2 ThrboC++
286

Section 3 Visual Basic


299
Programme Design Committee
Prof. S.B. Ghosh (Chairman) Prof. I.K. Ravichandra Rao Or. S.S. Murthy
Faculty of Library and Director,DRTC University Librarian
Information Science Bangalore G.G. Indraprastha University
IGNOU, New Delhi New Delhi
Dr. Neela Jagannathan
Dr. A Wahid (Special Invitee) Prof. Uma Kanjilal
Scientist Librarian, (Retd.) Faculty of Library and
NISSTAD, New Delhi IGNOU, New Delhi Information Science
Prof. B.K. Sell Or. Neena Talwar Kanungo IGNOU, New Delhi
INSDOC (Retd.) Faculty of Library and Or. Pravakar Rath (Convenor)
New Delhi Information Science Faculty of Library and'
IGNOU, New Delhi Information Science
Prof. Harsha Parekh
SNDT, Women's University Prof. R.Satyanarayana(Retd.) IGNOU, New Delhi
Murnbai Faculty of Library and
Dr. H.K.KaUI Information Science
IGNOU, New Delhi
Director,DLENET
New Delhi

Programme Coordinators: Dr. Jaideep Sharma and Mr. R. Sevukan

Course Code Contributors


MLlL-OOI Dr. N.S. Harinarayana
MLlL-002 Mr. R.K. Srivastava and Mr. R. Sevukan
MLlL-003 Mr. Ram Kumar
MLlL-004 Dr. Devika P. Madali
MLlL-005 Dr. Usha Mujoo - Munshi
MLlL-006 Dr. Devika P. Madali
MLlL-007 Or. Deepti and Mr. Shashi Bhushan

Editor: Mr. J.M. Bhardwaj Editorial Assistance : Ms. Sujata Santosh

Material Production Secreterial Assistance


Mr. J itender Sethi Mr. Devbrat Singh Chauhan
Mr. S.S. Venkatachalam
Mr. Manjit Singh
June, 2010 (Reprint)
ID lndira Gandhi National Open University, 2005
All rights reserved. No parr ofthis work may be reproduced in any form, by mimeograph or (/I1Y other means, without
permission in writing from the Indira Gandhi National Open University.
Further information on lndira Gandhi National Open University courses may be obtained from the University's office at
Maidan Garhi, New Delhi-l It) 068.
Printed and published on behalf of the Indira Gandhi National Open University. New Delhi by
Director. School of Social Sciences.
Paper Used: Agrobased Environment friendly
Laser typcscucd at Graphic Printers. 204. Pankaj Tower, Mayur Vihar, Phase-I. Dclhi-vl. I'h.:22758444
Printed at: Vijayalakshmi Printing Works Pvt. Ltd., B-117, Sector-5, Noida-201301
INTRODUCTION
PGDLAN Programme aims at developing the professional competencies of library and informa-
tion professionals in an automated and networked environment. The programme provides op-
portunities for in-depth, intensive practicals to enhance technological skills of the learners to
develop or manage independently a computerised library or information centre.
To inculcate comprehensive technological skills, there is an adequate stress on the practical
aspects of the different components of information and networking technology. The distribution
of various components in practicals is shown in the following table:
SI. Course Code Block Hours to be
No. and Name devoted
1. MLIL-OOl Block 2 : Software 40
Introduction to
Computers
2. MLIL-002 Block 2 : Management of Library Automation 40
Library Block 3 : Automation of Housekeeping
Automation Operations
3. MLIL-003 Block 3 : Data Models and Database Design 40
Information Block 4 : Query Language and Query
Systems ProcessinL
4. MLIL-004 Block 2 : Library and Information Networks 60
Networking and Block 3 : Internet Technology
;
Internet
Technology
5. MLIL-005 Block 1 : Types of Resources ( by Form) 60
Internet Block 2 : Types of Resoures ( by Subject)
Resources
6. MLIL-006 Block 1 : Content Analysis 80
Content Block 2 : Content Development
Development
7. MLIL-007 Block : Programming in Specific Languages 60
Programming Java or VB or C++

Thus, the duration of hours to be spent on practicals varies from 40 hours to 80 hours. 50%
marks is devoted to practicals in all the courses.
The learners will be doing the practicals under the supervision of the lab instructor. The lab
manual has been designed with a view to act as an interface between the learner and the lab
instructor. It provides step-by-step help to work through the different softwares concerned with
the different courses. Adequate stress has been laid on making the manual user-friendly and
lucidly illustrated with suitable examples.
The manual is divided into seven parts corresponding to the different courses, MLIL-OO1 to
MLIL-007. Each part has been appropriately structured in sections as per the conceptual struc-
ture of each course. The various subsections have been explained using screen shots, diagrams
and jllustrations. All the parts have exercises appended to them. The exercises have been divided
into' sessions that have been designed keeping in view the hours to be devoted to each course.
As mentioned above the lab manual is an interface between the learner and the instructor. The
learner is advised to use it under the supervision of the instructor. It is no way an alternative to the
instructor. Any doubts and clarifications regarding the manual can be clarified with the instructor.
r
.•.

MLIL - 001

INTRODUCTION TO COMPUTERS
r
SECTION 1 MS-DOS
Structure
1.0 MS-DOS
1.1 Working with Files and Directories
1.2 Drive
1.3 Copy
1.4 Replace Command
1.5 Rename (REN)
-
1.6 Path
1.7 Diskcopy
1.8 Print
1.9 More
1.10 Date and Time Command
1.11' Batch File
1.12 Exercises for Practice in Lab Session

1.0 MS-DOS
MS -DOS (Microsoft Disk Operating System) provides all of the basic file manager and device
manager functions required by most application programs running on an IBM compatible PC ..
MS-DOS handles file 110,character 110,memory management and other miscellaneous functions
in consistent manner. Though MS-DOS is no longer preferred operating system, familiarity
with DOS helps to understand other operating systems.

1.1 WORKING WITH FILES AND DIRECTORIES


For easy identification and retrieval of data DOS uses the concept of files to organize the data on
disk. Related data are stored in the form of a file. Instead of expecting us to remember the
physical location of each file on the disk, DOS enables us to give just a file name for processing.
i) Naming the file

Every file has a file name which is made up of a primary name and optional extension and its
format is given below:
<name>. <extension name>

where name is the primary name,' .' is period followed by extension of file which is optional.
Primary names are 1 to 8 character long and the extension if used is 1 to 3 character long.
DOS permits the following characters in the file name:
10 Introduction to Computers

A to Z, a to z, 0 to 9, and wildcard character, !, @, #, $, %, ", &, *, ( )


It should be noted that DOS does not allow the same name for any two files on the same
location.
it) Directories
A directory is a way of organizing and grouping of files on a disk. DOS maintains a directory on
every disk whereby it keeps trackof the files on the disk, their addresses and some other details.
This directory is called the root directory. Apart from files this directory may accommodate
further directories also called subdirectories.
DIR command displays a list of files and subdirectories in the current directory. This command
has a number of options which have not been discussed here. (Note: DOS commands are not
case sensitive i.e. you can enter any command in upper or lower case)
iii) Creating a new directory
The MD (or MKDIR) command is used to make (or create) a new subdirectory that is subordinate
to the current logged directory
Syntaxr
MD <directory name>, here' directory name' is the name of the subdirectory to be created.
iv); Sorting the files
SORT command sorts the input and displays the output to the screen, a file, or another device.
Activity:
• To-sort the file NAMES on drive C and send the output to a new file NAME2 on drive D,
enter
sort < c:names > d:name2
• To reverse sort (Z to A) the file *.TXT on drive C and send the output to a new file on drive
D,enter
sort Ir < C:* .txt > D: phone-a
• To create a sorted file TEMP, sorting on the character in column three, by using input from
the keyboard, enter
sort 1+3 > b:temp
Then, enter lines and press the Enter key at the end of each line. When you have finished, press
and hold the Ctrl key and then press the letter Z key. The data you have entered will be sorted
(based on the third character you have entered on each line) and the TEMP file will be created
and stored on the current drive.
v) Deleting the directory
To delete a directory RD (or RMDIR) command is used. For deleting a directory you must
delete its files and subdirectories. The directory must be empty except for the "." and ".."
symbols.
MS-OOS 11

Activity:
• To erase the file LETTER3.TXT from the LETTERS directory on the diskette in drive B,
enter
del b:\letters\letter3.txt
• To erase all the files in the current directory, enter
del *.*
If you use this form of the command (to delete all files in a directory), the program will display the
prompt
Are you sure (YIN)?
If you are sure you are deleting the files you want to delete, press the letter 'Y' key to start the
. '
erasmg process.

1.2 DRIVE
Each drive available in the computer system is identified by the drive letter. For example for the
hard disk drive identifier letter is "C" whereas the identifier letter for the floppy disk drive is "A"
or "B".
Now if you are working in the "C" drive i.e., hard disk and if you want to work with the "A" drive
i.e., floppy diskjust type the following in the command prompt:
C:\>A:
Formatting the floppy disk
The FORMAT command is an external DOS command that is available on all the versions of the
DOS. This command prepares a new disk for use by organizing the disk into magnetic tracks
and sectors and also creates new root directory and file allocation table for the disk. It can also
check bad area for the disk and it can delete all the data available in the disk. This command has
a number of options.
Examples:
format a: Would erase all the contents of a disk on a: drive. Commonly used on a diskette that
has not been formatted or on a diskette you wish to erase.
format a: Iq- Quickly erases all the contents of a floppy diskette. Commonly used to quickly
erase all information on the diskette.

1.3 COpy
COPY command is usually used to copy one or more files from one location to another. However,
COPY can also be used to create new files. By copying from the keyboard console (COPY
CON:) to the screen, files can be created and then saved to disk.
The first filename you enter is referred to as the source file. The second filename you enter is
referred to as the target file. If errors are encountered during the copying process, the COPY
12 Introduction to Computers

program will display error messages using these names.


Unlike the BACKUP command, copied files are stored in the same format they are found in. The
copied files can be used just as you would use the original (whether the copied file is a data file or
a program).
COpy can also be used to transfer data between any of the system devices. Files may also be
combined during the copy process.

Activity:

• The first filename you enter is the source file; the second file is the target file. To copy the file
TEST.DOC from the current directory to drive B (with the same name), enter
copy test.doc b:
• Copy the file TEST.DOC to the current directory with the new name, TEST2, by entering
copy test.doc test2
• Copy and combine (concatenate) the files TESTl.DOC and TEST2.DOC to a new file,
TEST3, by entering
copy testl.doc+test2.doc b:test3
You can also combine files by using wildcard characters (? and *). To copy all files with a .DOC
filename extension on drive C to a new file ALLDOCS on drive B, enter copy c: * .doc b:alldocs

1.4 REPLACECOMMAND
This command replaces files in the target path designation with files of the same name in the
source location.
You can use wildcard characters (? and *) to indicate groups of filenames in the source directories.
You cannot use this command to replace hidden files or system files.
• As files are replaced, the program displays their filenames on the screen. After the replace
operation is complete, it displays
n file(s) added/replaced
Activity:
• To replace all copies of the file MAIN .EXE on all directories within the root directory of
drive C with a file of the same name that is stored in the SPECIAL directory on drive A,
enter
a: \special\main.exe c:Vs
To add all files from the NEWFILES directory on drive A that have the .PCX filename extension
to the FILES directory on drive C (as long as no file of the same name already exists there), enter
a:\newfiles\* .pcx c:\fIles/a
MS-OOS 13

1.5 RENAME (REN)


RENAME changes the name of the first filename you enter to the second filename you enter. If
you enter a path designation for the first filename, the renamed file will be stored on that path.
Wildcard characters (* or ?) may be used with either the first or second filename designation.
Activity:
To change the name of the file SALES.TXT on drive A to NEWSALES.TXTon drive A, enter
ren a:sales.txt newsales.txt
To change the filename extensions to TXT on all files on drive D that have SAL as the first three
characters of the main filename, enter
renD:sal*.* sal*.txt

1.6 PATH
PATH tells DOS which directories should be searched for external commands after DOS searches
your working directory. DOS searches the paths in the order specified in the PATH command.
If you enter the PATH command without options, the program will display the currently set path
designations.
To search for external DOS commands and other executable programs in the PROGRAM
directory that is within the root directory on drive C, enter
path c:\program
You can search more than one path by specifying several pathnames separated by semicolons.
For example:
path \program; \files\sales;\data2

1.7 DISKCOPY
This command is used only for copying diskettes, not fixed disks.
The first drive you specify is the drive for the source diskette. The second is the drive for the
target diskette. DISKCOPY checks to determine if the disk in the target drive has been previously
formatted. If not, DISKCOPY will format it before it starts the copy (except in early versions of
DOS).
If the target drive is the same as the source drive (or if you do not enter a drive designator), the
copying will be done using one drive. The program will prompt you when to insert each diskette.
Example:
diskcopy a: - This would make a copy of the disk that is currently in your drive.
After copying, the program will display
Disk copy OK
14 Introduction to Computers

Copy another (YIN) ?


If you press the letter Y key, you will be prompted to insert another disk to copy using the same
parameters. Press the letter N to terminate DISKCOPY.
Activity:

To copy the contents of the disk in drive A to the disk in drive D (erasing any data already on the
disk), enter
diskcopy a: D:

1.8 PRINT
U sing the PRINT command, you can set up one or more files to print and continue to use other
programs (often referred to as background printing). This command has a number of options
which have not been discussed here.
Activity:

• To stop printing and cancel the print queue, enter


Printlt
• To remove the files LETTER.TXT, START.EXE, and RATE.COM (all on drive B) from
the PRINT queue, enter
print b:letter.txtlc b:start.exe b:rate.com
• To remove the file SALES.DOC from the PRINT queue and, at the same time, add the files
OLDSALE.DOC and NEWSALE.DOC, enter
print sales.doc/c oldsale.doc/p newsale.doc

1.9 MORE
MORE is a filter command (reads from input, transforms it, and sends output to the screen, to a
file, or to a printer).
MORE displays the output one screen at a time, then pauses and displays the message MORE
at the bottom of your screen.
Pressing any key will display another screen full of information. This process continues until all
the input data has been read. The MORE command is useful for viewing a long file one screen at
a time.
Syntax:

MORE < (filename or command)


(name)IMORE
You can use the MORE command with the redirection symbol < to send the output to a file or for
use by another command.
1
MS-OOS 15

You can also use the piping symbol (I) to pipe the output of a program or a DOS command
(referred to as name in the command format) to MORE.
Activity:

• To display the file SALE2.TXT, one screen full of data at a time, enter
more < sale2.txt
• To display the output of the TYPE command one screen at a time, you can enter the command
using the following format:
TYPE (filename)IMORE
For example, to display the file LET3.DOC in the LETTERS directory on drive B, enter
type b:UettersUet3.doclmore

1.10 DATE AND TIME COMMAND


TIME command

When the DATE command is entered the program prompts you when to enter the date. You can
also enter the date at the same time you enter the date command. Either way, you must enter the
date in the following format:
Syntax:

DAlE

DATEmm-dd-yy
Activity:

When you enter date if the current date IS set the program will display

Current date is Sat 06-11-1994


Enter new date (mm-dd-yy):
Press Enter to leave the date as it is, or type in the date using the format shown. Be sure to enter
one or two numbers to indicate the month, then a hyphen, one or two numbers to indicate the day
of the month, another hyphen, and one or two numbers to indicate the year. For example, to set
the date on May 24,1994, enter
5-24-94
TIME command

You can enter the TIME command alone and the program will prompt you when to enter the
time. You can also enter the time at the same time you enter the time command. Either way, you
must enter the time in the following format:
Syntax:

TIME
16 Introduction to Computers

TIMEhh:mm[:ss] [.cc][AlP]
where hh is a one or two digit hours designation, mm is a one or two digit designation of minutes
after the hour, ss is a one or two digit designation of seconds after the minute, and cc is a one or
two digit designation of the hundredths of a second past the second. The following numbers are
allowed:
hh 0-23 for hours
mm 0-59 for minutes
ss 0-59 for seconds
cc 0-99 for hundredths of seconds
AlP A.M. or P.M: (default is A.M.)
NOTE:

Your version of DOS may require slightly different forms of this entry format.
If you enter the TIME command without any time designation, the screen will display:
Current time is hh:mm:ss
Enter new time:_ ,
You can enter a. new time or press the Enter key to leave the time setting as it is.
If DOS carries out a time-dependent function (such as time-stamping a file for storage on a disk),
the system time (based on the starting time you set) will be used. On some computers the system
time is maintained by a battery-backup system; in this case, you will rarely use the TIME command
(you can stop the initial presentation of both the DATE and TIME prompts by creating any
AUTOEXEC.BAT file that does not include these commands). Other computers lose the system
time whenever the computer is turned off. In this case, it must be reset each time the computer is
restarted.

1.11 BATCH FILE


A batch file or batch program is an unformatted text file that contains one or more MS-DOS
commands and is assigned a .BAT extension. When you type the name of the batch program at
the command prompt, the commands are carried out as a group. Any MS-DOS command you
use at the command prompt can also be put in a batch program.

1.12 EXERCISES FOR PRACTICE IN LAB SESSION


SESSION 1

Exercises
1) Write a small batch file using replaceable parameter to invoke any of the tutors for the hard
disk.

2) Write a batch file to invoke Norton's edition program so that user can open any file and to
any line number in the file.
3) Write a batch file which will set the path to sub directory.
MS-DOS 17

4) Make three subdirectories by name of A, Band C in the root directory. Copy any 3 files
into these subdirectories, then write a batch file to remove the sub-directory and files.
SESSION 2

Exercises
1) Create a batch file DEMO.BAT.
2) Display the content of a file.
3) Test the batch file and display the content of the file if it is available on the current location.
4) Create another batch file PROEBAT.
5) Call on batch file to another batch file.
[Hint: use @ECHO OFF, IF, CALL, REM and ADD
SESSION 3.

Exercises
1) Create the following file named "Country.txt"
.India Dellii Rupees
Germany Bonn Deutschmark
Japan Tokyo Yen
America Washington Dollar
Pakistan Karachi Rupees
France Paris Francs
China Beijing Yen
Australia Melbourne Dollar,

2) Using the Country.txt do the following:


a) Sort the file in the ascending order of country names and redirect the output;
~"ncountry.txt". ,
)-

b) Sort the file in the descending order of capital names and redirect the output "ncap.txt".
c) Display details from the file where the word "Rupees" occurs.
d) Display details from the file where the word "yen" does not occur along with the
corresponding line number.
e) Display the number of lines where the word "yen" is appearing.
3) Use-the prompt command to change the prompt to:
a) yourname>current drive letter (should be in reverse video)
b) system date and time
c) Dos version number (should blink)
4) Copy the file "country.txt" onto floppy disk
SECTION 2 WINDOWS 98

Structure
2.0 Introduction
2.1 Windows Basics
2.2 Working with Files and Folders
2.3 Working with Control Panel
2.4 Working with Calculator
2.5 Working with Notepad
2.6 Working with Paint
2.7 Exercises for Practice in Lab Session

2.0 INTRODUCTION
The medium through which we communicate with a computer is called the user interface. We
can categorize it into two types:
• Character User Interface (CUI)
• Graphical User Interface (Gill)
Character User Interface (CID) - Character User Interface uses text to communicate with
the user. In this type of interface the user gives commands to interact with the system. The
commands are given at the command line with the user required to remember the exact syntax of
the commands.
Graphical User Interface (GUI) - Graphical User Interface uses pictures/ graphics to interact
with an application. In a GUI environment the user interacts with a computer on a visual level.
What is expected of the user is to communicate with computer, by selecting the application of his/
her choice, through the pictures available on the screen.
Windows 98 is a 32 bit multi-user OS which supports GUI.

2.1 WINDOWSBASICS
Working on computer
Activity:
1) Switch on the computer and give a command to start windows at the C:\> prompt.
2) Exit windows and start again.
3) Start to windows and give the name and a password in Log-on Screen.
4) Activate the program group "Main" by using one of these methods:
a) by selecting the pull down menu window from the menu bar of program manager using
the mouse. '
b) by double clicking on the "Main" icon
r 1
Windows 98 19

Working with taskbar


Activity:
1) Identify the following in the windows 98
a) Start Button
b) Taskbar
c) Status Area
d) Time and Date
2) Open the taskbar properties to configure the taskbar.
3) Move the taskbar, simply click on the bar and drag it towards the edge on which you want
itto appear
4) Enable this option (by checking the box), the taskbar will always be visible; that is it will
.never be "covered up" by a running application
5)' Auto Hide taskbar by enabling this option, find theresult in the taskbar [Note: Don't panic
if you don't get the taskbar.If you need to view the taskbar when it is hidden, either click or
drag it open].
6)' Reduce the size of the menu when you click start.
7) Display the time to appear in status area of the taskbar.
Working with Start Menu
Activity:
Switch on the computer, click on the start menu and try to do the following:
1) Using Run command change the windows to MS DOS prompt.
2) Exit from MS DOS prompt.
3) Using Run command go the Notepad.
4) Using the shortcut key go to run Command and select the following programs
a) D:/Games/

b) Command
c) Notepad
d) WordPad
e) Paint
5) Using the find command find the file/folder Hindustan.
,

6) Find all files having extension. TXT and .DOe


7) Find the file containing the word India using fmd command.
20 Introductionto Computers

8) Find the file that is modified on two days of this session.


9) Using help option in start menu learn about the files and folders.
10) Using the menu option select a program notepad.
11) Using the menu on start open the document that is recently opened.
12) Open up the control panel using s~ menu.
13) Open up the folder option using start menu.
14) Open up the taskbar using start menu.
15) Open up the favorite website using favorite option.
Setting the time and date and configuring the display setting

Activity:

1) Change date and time using the date/time properties.


2) Using timezone select the standard time.
3) Using the taskbar open up the date/time properties.
4.) Open the display properties and change the background of the window.
, 5) Using the browse option select the background files.
6) Display the background "tile".
7) View the background using center option.
8) Move the display properties window from left to right.
9) Using the shortcut method open the display properties window.
10) Change the setting of the screensaver.
11) Using appearance change the display setting of windows.
12) Using setting option change the screen area from 640 by 480 pixels to 800 by 600 pixels.
13) Using web option view active desktop as a web page.
14) Using visual effects change the size of the icons.
Working with explorer

Activity:

1) Click on the folders on the left side to see how the subfolders and files are displayed on the
right side of the window.
2) Use the scroll bars in the windows to navigate.
3) Click on the items on the menu bar to see the options provided.
4) Identify in your Explorer all the items identified above.
1
Windows 98 21

5) Open Explorer by clicking Start, Programs, Windows Explorer.

6) Open the Find program by clicking on Tools, Find, Files or Folders.

7) In the 'Named'box, Type *.TXT.

8) In the 'Look in' box click Browse and select C:

2.2 WORKING WITH FILES AND FOLDERS


Creating Folders

Activity:

1) In My Computer or Windows Explorer, open the folder in which you want to create a new
.folder.

2) On the file menu point to new, and then click Folder.The new folder appears with a temporary
name.

3)· Type a name INDIA for the new folder.

4) Change the name of the folder INDIA to Hindustan

[Hint: Go to window explorer and select the file and click on rename in file menu and type the
new name]

5) Delete the folder Hindustan and send it to Recycle Bin.

6) Restore from the Recycle Bin.

7) Copy Hindustan folder to other folder (Create other folder and copy the Hindustan folder
to it)

8) Copy the Hindustan folder to floppy disk.

9) Using cut option copy the folder to other folder.

10) Using the shortcut key copy the folder from the new folder and paste it in floppy disk.

Creating and Saving a File

Activity:

Perform the following steps to save file:

1) Open your word processing program (you do not have to really type anything unless you
wish).

2) Click on 'File' - 'Save As'

3) In the 'save in:' box, click on the drop-down menu and go to C:

4) Find the Temp folder and double click on it. It will pop (appear) in to the save in box

5) In the 'File name:' box, type 'test doe'

6) Click on the'save' button.


22 IntroductiontoComputers

7) Now close the program and open it up again.

8) Click on 'File', 'Open', and follow the same procedure as above to locate the file.
9) When you locate it double click on the file to open it into your word processing program.
10) You have now completed the exercise and can close your program.
Copying Files
,
.- Activity:

Try the following ways to copy files using the different methods:
a) Right clicking

1) Put a floppy disk with at least 3 expendable files to play with in your A drive.
2) Open windows explorer.

3) Click once on [A:] to reveal all the files on your floppy disk (A drive).
4) Right click on one of the files and choose copy.

5) On the left side click on C: and navigate down to the Temp folder
6) Right click on Temp and choose Paste (left click)

7) Check it by double clicking on the Temp directory folder to see it displayed on the
right side.
b) Menu Bar

1) Click once on a file on your floppy disk (A:), on the menu bar choose edit, copy.
2) Navigate to the directory folder where you wish to place your file (Temp). Select it by
clicking on it once.

3) On the menu bar choose edit, paste.

4) Check it by double clicking on Temp to see it displayed on the right side.


c) KeyBoard

1) Select a file on your A Drive by clicking on it once, press Ctrl C then release it, you
have just copied it.

2) Navigate to the directory where you wish to place your file (Temp). Select it by left .
clicking on Temp once.
3) Press Ctrl V.

4) Check it by double clicking on Temp and see it displayed on the right.


d) Dragging

1) In one window locate the file to be copied.


nd
'2) In the 2 window scroll to the desired target <hiveand folder so that it is visible. ,
1
Windows 98 23

3) Then click and hold the left mouse button on the file in the first window and drag it to
2nd window to the desired folder.
a) If copying it to the same drive, hold down the letter C on your keyboard while
you drag it.
b) If copying to different drive just drag it
Drop it precisely on the folder to which it will go, a small box will be visible around the selected
folder, so that you can drop it within the folder. If you miss, check the folder above and below
your selected folder to see if the file landed there, otherwise, you may have to search to locate it
Tip:You can copy several files at a time by
• Left clicking on 1 file, hold down the Ctrl while you select the other files.
• Release theCtrl key and on anyone ofthe selected files drag to desired location .
Moving Files

Activity:

Try moving a file by doing the following:


1) Left, click on A: to reveal your files on the right side.
2) Right click on one of the files and choose Cut.
3) Then scroll to your Temp directory on the left, right click on Temp and choose Paste.
4) Now click once on the same file in the Temp.
5) Click on Edit on the menu bar and choose Cut.
6) Now click on A: and on the menu bar choose Edit, Paste.
Deleting Files

Activity:

Try deleting files by doing the following (be sure these are your "play" files that can be trashed) :
1) Close one of the Explorer windows if still open.
2) Click on A: to reveal your files on the right side.
3) Left click on one of the files to select it.
4) Press your Delete key on the keyboard.
5) Now select another file on A:
6) Copy that file to your Temp directory .
7) Double click on the Temp folder to see the file.
8) Now left click on the file to select it.
9) Drag the file to the Recycle Bin.
24 Introduction to Computers

Creating Folder Directories

Activity:

Creating folder
1) Open windows Explorer.
2) Scroll the left side scroll bar up until you see [C:] and click once onJC:],
3) Go up to 'File' on the menu bar and choose 'New', 'Folder'.
4) Replace 'New Folder' with 'Downloads' and hit Enter. Now when you download something
from the web, you can put the file in this directory.
5) Click on [C:) again and make another folder called 'Coursework'.
6) Now click once on the 'Coursework' folder and create a folder with the name of one of
your courses. You may want to create another folder for another course. Now you can see
how this works to organize your files.

2.3 WORKING WITH CONTROL PANEL


Activity: ;

Add anew font to your computer

1) Click Start, point to Settings, click Control Panel, and then double-click Fonts.
2) On the File menu, click Install New Font.
3) Click the drive, and then click the folder that contains the fonts you want to add.
4) Click the font you want to add.
Install accessibility options

5) Open the Add/Remove Programs Properties dialog box at the Windows Setup tab.
6) Under Components, click to select the Accessibility Options check box.
7) Click OK.
Turn on accessibility features

To start the Accessibility wizard follow the instructions on the screen.


Change your desktop theme

8) Click Start, point to Settings, click Control Panel, and then double-click Desktop
Themes.

9) In the Desktop Themes dialog box, click the theme you want in Themes, and then click
OK. '-

10) If you don'twant to use one of the theme's desktop items, make sure its check box is clear.
1

Windows 98 25

Change the way items on the desktop look

11) Open the Display Properties dialog box and click on the Appearance tab.

12) If you want to change the appearance of only one screen element, click that element in
Item, and then change the settings in Size and Color for the item and its font.

If you want to change the appearance of all screen elements simultaneously, click an appearance
scheme in Scheme.

Change the background of the desktop

1) ,Open the Display Properties dialog box.

2) 'in WallpaPer, click the background you want to use or click Pattern to choose or modify
the background.

3) Click Apply to see the changes before you close the dialog box, or click OK to accept the
changes and close the dialog box.

Create or modify desktop patterns

1) Open the Display Properties dialog box and click on the Background tab.

2) Click Pattern, click the one you want to modify, and then click Edit Pattern.

3) If you want to create a new pattern, type a new name for it. If you want to modify an existing
pattern, skip to the next step.

4) To change squares from one color to another, click them in Pattern. Repeat this until the
pattern in Sample looks the way you want it to.

5) When you have finished, click Done, and then click Yes when Windows prompts you to
save the pattern.

Change the appearance of a desktop icon

1) Open the Display Properties dialog box.

2) Click the Effects tab.

3) Under Desktop icons, click the icon you want to change, then click Change Icon.

4) To use an icon from the default icon file, double-click an icon in the Current icon list.

Change the visual settings for your desktop

1) Open the Display Properties dialog box.

2) Click the Effects tab.

3) Under Visual effects, click the item you want to change.

Use the default icon for a desktop icon

1) Open the Display Properties dialog box.

2) Click the Effects tab.

I
26 Introduction to Computers

3) Under Desktop icons, click an icon to change, and then click Default Icon.

Protect your files by assigning a screen saver password

1) Open the Display Properties dialog box, click on the Screen Saver tab.

2) In Screen Saver, click the screen saver you want to use.

3) Make sure the Password protected check box is selected, and then click Change.

4) Type your password, and then confirm the password by typing it again.

Set up a screen saver

1) Open the Display Properties dialog box, click on the Screen Saver tab.

2) In Screen Saver, click the screen saver you want to use.

3) To customize the screen saver, click Settings.

Calibrate your display to actual dimensions

1) Open the Display Properties dialog box, click on the Settings tab.

2) In Screen area, make sure the setting is higher than 640 by 480 pixels. If 640 by 480
pixels is the only setting available to you, you cannot calibrate your display to actual
dimensions.

3) Click Advanced to open the properties page for your computer.

4) On the General tab, in Font Size, click Other.

5) Hold a ruler up to the ruler on your screen, and then drag the screen ruler until it
matches the ruler you are holding.

Change the number of colors your monitor displays

1) Open the Display Properties dialog box, click on the Settings tab.

2) In Colors, click the number of colors that you want your monitor to display.

Change the size of the screen area

3) Open the Display Properties dialog box, click on the Settings tab.

4) In Screen area, click the desktop size.


Use larger or smaller display fonts

1) Open the Display Properties dialog box, click on the Settings tab.

2) Click Advanced to open the properties page for your monitor.

3) On the General tab, in Font Size, click the size you want your displayed fonts to be.

To customize the size of displayed fonts, click Other.

Change your computer's settings

1) Click Start, and then point to Settings.


l
Windows 98 27

2) Click Control Panel.

3) Double-click the icon that represents the settings you want to change.

2.4 WORKING WITH CALCULATOR


Activity:

To perform a simple calculation

1) Enter the first number in the calculation.

2) Click + to add, - to subtract, * to multiply, or I to divide.


3) Enter the next number in the calculation.

4) Enter any remaining numbers.

5) Click=.

To perform a statistical calculation

1) On the View menu, click Scientific.

'2) Enter your first piece of data.

3) Click Sta, and then click Dat.

.4) Enter the rest of the data, clicking Dat after each entry.

5) . Click Sta.

6) Click the button for the statistics function you want to use.

To perform a scientific calculation

1) On the View menu, click Scientific.

2) Click a number system.


.,
3) Enter the first number.

4) Click an operator.

5) Enter the next number in the calculation.

6) Enter any remaining operators and numbers.

7) Click=.

To convert a value to another number system

1) On the View menu, click Scientific.

2) Enter the number you want to convert.

3) Click the number system ~ou want to convert to.


28 IntroductiontoComputers

2.5 WORKING WITH NOTEPAD


Activity:
f
1) Create a new folder 'food'.

2) Create and Save the file under the name of 'dinner '.
J
3) Add the time and date to the file.

4) 'Type the content of your own and change the font using set font option.

I
5) 'Take the print and use page setup to set the page to A4 size.

6) ,Find the word dinner in the file using find option.

2.6 WORKING WITH PAINT


Activity:

Draw a straight line

1) In the toolbox, click Line tool.

2) At the bottom of the toolbox, click a line width.

3) To draw the line, drag the pointer.

Draw a free-form line

1) In the toolbox, click Pencil tool.

2) To draw the line, drag the pointer.

Draw a curve

1) In the toolbox, click Line tool.

2) At the bottom of the toolbox, click a line width.

3) Draw a straight line by dragging the pointer.

4) Click where you want one arc of the curve to be, and then drag the pointer to adjust the
curve. Repeat this step for a second arc.

Draw an ellipse or circle

1) In the toolbox, click Oval tool.

2) Drag the pointer diagonally.

You can draw a perfect circle by holding down SHIFT while you drag.

Draw a rectangle or square

1) In the toolbox, click Rectangle tool to create a square-cornered shape, or click round
corner box tool to create a round-cornered shape.

2) To draw a rectangle, drag the pointer diagonally in the direction you want.
1
Windows 98 29

3) To draw a square, hold down SHIFf while dragging the pointer.


Draw a polygon
4) In the toolbox, click Polygon tool
5) To draw the polygon, drag the pointer and click at each corner, and then double-click when
done.
To use only 45- and 90-degree angles, hold down SHIFf while dragging.
Type and format text
1) . in the toolbox, click the' N Button.
2) To create a text frame, drag the pointer diagonally to the size you want.
3) . On the text toolbar,clickthe font, size, and style you want for the text.
4) . .Click inside the text frame, type the text, and then do any of the following as needed.
• Move or enlarge the text frame.
• Click a color to change the color of the text.
• In the toolbox click on the "fill with color' tool to insert the text on a colored background.
Then right-click in the color box to change the background color.
Set the default foreground and background colors
• To set the foreground color, click a color in the color box.
• To set the background color, right -click a color in the color box.
Fill an area or object with color
1) In the toolbox, click "Fill with color' tool.
2) Click the area or object you want to fill.
Notes:
• If the shape being filled has any breaks in its border, the filling color leaks through to the rest
of the drawing area. You can find and close any openings by clicking the View menu,
pointing to Zoom, and then clicking Large Size or Custom.
• The default background and foreground colors appear at the left in the color box. You can
fill with the foreground color by clicking the area, or you can fill with the background color
by right-clicking the area.
• You can undo up to three changes by clicking the Edit menu and then clicking Undo for
each change.
Paint with a brush
1) In the toolbox, click Brush.
2) At the bottom of the toolbox, click a brush shape.
30 Introduetion to Computers

3) To paint, drag the pointer over the image.

Create an airbrush effect

1) In the toolbox, click the spray paint can.

2) At the bottom of the toolbox, click a spray size.

3) To spray, drag the pointer over the image.

Create custom colors

1) In the color box, click the color you want to change.

2) On the Colors menu, click Edit Colors.

3) Click Define Custom Colors.

4) Click thecolor swatch to change the Hue and saturation (Sat), and then move the slider in
the color gradient to change the luminescence (Lum).

5) Click Add to Custom Colors, and then click OK.

Erase an area

1) In the toolbox, click the Eraser tool.

2) At the bottom of the toolbox, click an eraser shape.

3) Drag the pointer over the area you want to erase.

Zoom in or out of a picture

On the View menu, point to Zoom, and then click Normal Size, Large Size, or Custom.

Use a picture as the desktop background

1) Save the picture.

2) On the File menu, click either of the following commands:

• Set As Wallpaper (Tiled) covers the screen with repetitions of your picture.

• Set As Wallpaper (Centered) places your picture in the center of the screen.

2.7 EXERCISES FOR PRACTICE IN LAB SESSION


SESSION 1

Exercise 1

1) Start the computer and give the command to start Windows at the C:/> prompt.

2) Exit Windows and start again.

3) Open the progran; group Accessories.

4) Write down all the accessories.


1
Windows 98 31

5) View system information and note down the system configuration.


Exercise 2
1) Start the program group, " Control Panel" from the start menu.
2) Activate the program "Date and Time" from the "Control Panel" window. Try out and test
the various options in this-program.
3) Move the window by "Dragging" it with the mouse. Resize the window using the mouse.
4) Switch between program manager window and Date & Time window using the Task List.
5) Close the program by invoking the pull-down menu from the box at the left hand top corner
of the "Date & Time" window.
6) Now close the control panel window.
7) Move the Main window to a corner of the window explorer.
8) Without closing the window explorer start another program group from Explorer.
Exercise 3
; 1) Close all windows except the Window Explorer. Resize the program Manager window to
make it small so that only a few icons are visible.
2) From the windows pull-down menu use the "Arrange Icons" option to arrange icons.
3) Now use the "Scroll Bar" on the left of the window to scroll the icons in the window.
Exercise 4
1) Run the program" Explorer" from the Control Menu program group from the Main program
group.
2) Try out and test the various options in this program.
3) In this program window, identify :
various control buttons
a scroll bar
a text box
a "Drop Down list box"
a Spinner
Radio button
Check boxes
4) Then close the various windows except explorer.
Exercise 5
Try out the following operations on a program group window:
a) Changing size
32 Introduction to Computers

b) Moving

c) Maximize

d) Minimize

e) Restore

t) Scrolling

g) Close

h) Help
~ SESSION 2

You already have practice of using the window menu of the explorer. Now you carry out the
following exercises:

Exercises

1) U se the "window" menu to open at least 2 windows in the explorer.

2) Now create a new program group window and label this with your own name.

3) Copy a few icons from other windows to this one.

4) Select one of the icons you have copied by clicking it once.

5) Now try out the commands in the "File" menu.

6) Again, on copies of icons try out the commands in the "option" menu.

7) Create a program item and assign it an icon of your choice. Associate this item with the file
DOSPRMPT.PIF.

8) Use the File Run Menu to execute a Batch [tie.

9) Using the File Manager, copy a set of continuous files to your floppy disk.

10) Copy a whole sub - folder to your floppy.

11) Move a sub folder to another folder on the hard disk.

12) Copy a sub folder to another folder on the hard disk.

13) Delete the whole folder.

14) Search for a file using the Explorer.

15) Associate all files with the extension .Doc with the application notepad.

16) Print a file using the Explorer.

SESSION 3

Exercise 1

1) Interchange the left and right buttons on your mouse using the appropriate software in
windows.
r 1
Windows 98 33

2) Change the wallpaper using Desktop program in Control panel.


3) Display a message on the screen whenever the keyboard is untouched for more than 2
minutes.

4) Forward the system time by 5 minutes.


5) Print 3 files one after the other.
6) Using the print Manager change the order of the 2nd and 3rd files.
7) Try out the other options of print Manager.
8) Save the screen you are currently working on in the clipboard.
9) ..View it now in the clipboard viewer.
10) If you are working on a computer having a color monitor practice changing the color schemes
.of windows to your style.
SESSION 4

Exercise 1
1) Using paintbrush draw a geometrical or abstract pattern of your choice and save it as a bit
map. In doing so use as many tools as you can without making your pattern grotesque.
2) U se the output of the above as the wallpaper on your desktop screen.
3) Write a short letter to a prospective employer applying for ajob. Use different fonts to
.._highlightyour strengths.
4) Save this document.
5) Copy this document to your floppy.
6) Prepare your schedule for the next two days.
7) Display the calculator iri'scientificmode.
SECTION3 UNIX
Structure
3.0 What is Unix?

3.1 Accessing a Unix System


3.2 Logging In and Logging Out
3.3 The UNIX Shell
3.4 Working with Files and Directories
3.5 Redirecting Input and Output

3.6 Pipelines and Filters


3.7 Process Control and Multitasking

3.8 Interaction and Job Control


3.9 The Execution Environment
3.10 Customizing the UNIX Shell
3.11 Interactive Use of the Shell
3.12 The UNIX File System
3.13 Exercises for Practice in Lab Session

3.0 WHATIS UNIX?


UNIX is an operating system. The job of an operating system is to orchestrate the various parts
of the computer - the processor, the on-board memory, the disk drives, keyboards, video
monitors, etc. - to perform useful tasks. The operating system is the master controller of the
computer, the glue that holds together all the components of the system, including the administrators,
programmers, and users. When you want the computer to do something for you, like start a
program, copy a file, or display the contents of a directory, it is the operating system that must
perform those tasks for you.
UNIX was created in the late 1960s, in an effort to provide a multiuser, multitasking system for
use by programmers. The philosophy behind the design of UNIX was to provide simple, yet
powerful utilities that could be pieced together in a flexible manner to perform a wide variety of
tasks.
The UNIX operating system comprises three parts: the kernel, the standard utility programs, and
the system configuration files.

The kernel: The kernel is the core of the UNIX operating system. Basically, the kernel is a large
program that is loaded into memory when the machine is turned on.and it controls the allocation
of hardware resources from that point forward. The kernel knows what hardware resources are
available (like the processor(s), the on-board memory, the disk drives, network interfaces, etc.),
and it has the-necessary programs to talk to all t!te devices connected to it.
Unix 35

The standard utility programs: These programs include simple utilities like cp, which copies
files, and complex utilities, like the shell that allows you to issue commands to the operating
system.
The system configuration files: The system configuration files are read by the kernel, and
some of the standard utilities. The UNIX kernel and the utilities are flexible programs, and certain
aspects of their behavior can be controlled by changing the standard configuration files. One
example of a system configuration file is the filesystem table "fstab" , which tells the kernel where
to find all the files on the disk drives. Another example is the system log configuration file
"syslog.conf', which tells the kernel how to record the various kinds of events and errors it may
encounter.

3.1 ACCESSING A UNIX SYSTEM


There are many ways that you can access a UNIX system. The main mode of access to a UNIX
machine is through a terminal, which usually includes a keyboard, and a video monitor. For each
terminal connected to the UNIX system, the kernel runs a process called a tty that accepts input
from the terminal, and sends output to the terminal. Tty processes are general programs, and
must be told the capabilities of the terminal in order to correctly read from, and write to, the
terminal. If the tty process receives incorrect information about the terminal type, unexpected
, results can occur.
Console
Every UNIX system has a main console that is connected directly to the machine. The console is
a special type of terminal that is recognized when the system is started. Some UNIX system
operations must be performed at the console. Typically, the console is only accessible by the
system operators, and administrators.
Dumb terminals
Some terminals are referred to as "dumb" terminals because they have only the minimum amount
.of power required to send characters as input to the UNIX system, and receive characters as
output from the UNIX system.
Personal computers are often used to emulate dumb terminals, so that they can be connected to
a UNIX system. Dumb terminals can be connected directly to a UNIX machine, or may be
connected remotely, through a modem or a terminal server. --
Smart terminals

Smart terminals, like the X terminal, can interact with the UNIX system at a higher level. Smart
terminals have enough on-board memory and processing power to support graphical interfaces.
The interaction between a smart terminal and a UNIX system can go beyond simple characters
to include icons, windows, menus, and mouse actions.

3.2 LOGGING IN AND LOGGING OUT


To ensure security and organization on a system with many users, UNIX machines employ a
system of user accounts. The user accounting features of UNIX provide a basis for analysis and
control of system resources, preventing any user from taking up more than his or her share, and
preventing unauthorized people from accessing the system. Every user of a UNIX system must
36 Introduction to Computers

get permission by some access control mechanism.


Logging in

Logging in to a UNIX system requires two pieces of information: A usemame, and a password.
When you sit down for a UNIX session, you are given a login prompt that looks like this:
1ogin:

Type your usemame at the login prompt, and press the return key. The system will then ask you
for your password. When you type your password, the screen will not display what you type.
Your username

Your usemame is assigned by the person who creates your account. Your usemame must be
unique on the system where your account exists since .itis the means by which you are identified
on the system.
Your password

When your account is created, a password is assigned. The first thing you should do is change
your password, using the passwd utility. To change your password, type the command
Passwd

after you have logged in. The system will ask for your old password, to prevent someone else
from sneaking up, and changing your password. Then it will ask for your new password. You will
be asked to confirm your new password, to make sure that you didn't mistype.It is very important
that you choose a good password, so that someone else cannot guess it. Here are some rules for
selecting a good password:
• Do not use any part of your name, your spouse's name, your child's name, your pet's name,
or anybody's name. Do not use any backward spellings of any name, either.
• Do not use an easily-guessable number, like your phone number, your social security number,
your address, license plate number, etc.
• Do not use any word that can be found in an English or foreign-language dictionary.
• Do not use all the same letter, or a simple sequence of keys on the keyboard, like qwerty.
• Do use a mix of upper-case and lower-case letters, numbers, and control characters.
• Do use at least six characters.
If you have accounts on multiple machines, use a different password on each machine. Do not
choose a password that is so difficult to remember that you must write it down.
Logging Out

When you're ready to quit, type the command


exit

Before you leave your terminal, make sure that you see the login prompt, indicating that you have
successfully logged out. If you have left any unresolved processes, the UNIX systeIJ1will require
you to resolve them before it will let you log out. Some shells will recognize other commands to
log you out, like "logout" or even "bye".
1
Unix 37

It is always a good idea to clear the display before you log out, so that the next user doesn't get
a screenful of information about you, your work, or your user account. You can type the command
clear
right before you log out, or you can press the return key until all the information is scrolled off the
screen. ,. ,

3.3 THE UNIX SHELL


The shell is perhaps the most important program on the UNIX system, from the end-user's
standpoint. The shell is your interface with the UNIX system, the middleman between you and
the kernel.

The shell is a type of program called an interpreter. An interpreter operates in a simple loop-.
it accepts a command, interprets the command, executes the command, and then waits for another
command. The shell displays a "prompt," to notify you that it is ready to accept your command.
The shell recognizes a limited set of commands, and you must give commands to the shell in a
way that it understands. Each shell command consists of a command name, followed by command
options (if any are desired) and command arguments (if any are desired). The command name,
options, and arguments, are separated by blank space.
The shell is a program that the UNIX kernel runs for you. A program is referred to as aprocess
while the kernel is running it. The kernel can run the same shell program (or any other program)
simultaneously for many users on a UNIX system, and each running copy of the program is a
separate process. Many basic shell commands are actually subroutines built into the shell program.
The commands that are not built into the shell require the kernel to start another process to run
them.
When you execute a non built-in shell command, the shell asks the kernel to create a new sub
process (called a "child" process) to perform the command. The child process exists just long
enough to execute the command. The shell waits until the child process finishes before it will
accept the next command.
Activity:

1) Explain why the exit (logout) procedure must be built into the shell.
Answer: If the logout procedure were not built into the shell, the kernel would start a new child
process to run it. The new process would logout, and then return you to the original shell. You
would thus find yourself back where you started, without having logged out.
Unlike DOS, the UNIX shell is case-sensitive, meaning that an uppercase letter is not equivalent
to the same lowercase letter (i.e., "A" is not equal to "a"). Almost all unix commands are in lower
case.
Entering shell commands

The basic form of a UNIX command is: commandname [-options] [arguments]


The command name is the name of the program you want the shell to execute. The command
options, usually indicated by a dash, allow you to alter the behavior of the command. The arguments
are the nameS of files, directories, or programs that the command needs to access.
38 Introduction to Computers

The square brackets ([ and ]) signify optional parts of the command that may be omitted.
Example: Type the command
18 -1 /tmp

to get a long listing of the contents of the Itmp directory. In this example, "Is" is the command
name, "-I" is an option that tells Is to create a long, detailed output, and "/tmp" is an argument
naming the directory that Is is to list.
Aborting a shell command
Most UNIX systems will allow you to abort the current command by typing Control-C. To issue
a Control-C abort, hold the control key down, and press the "c" key.
Special characters in UNIX
UNIX recognizes certain special characters as command directives. If you use one of the UNIX
special characters in a command, make sure you understand what it does. The special characters
are: I < > ! $ % ." & * I { } - and;
When creating files and directories on UNIX, it is safest to only use the characters A-Z, a-z, 0-
9, and the period, dash, and underscore characters.
The meaning of the other characters, and ways to use them, will be introduced as the tutorial
progresses -,
Getting help on UNIX
To access the on-line manuals, use the man command, followed by the name of the command
you need help with.
Example: Type
rnan 18

to see the manual page for the "Is" command.


Example: To get help on using the manual, type
man man
to the UNIX shell.

3.4 WORKING WITH FILES AND DIRECTORIES


Here-isan index to the topics in this section:
• The UNIX file system structure
•. File and directory permissions
• Changing directories
• Listing the contents of a directory
• Viewing the contents of a file
Unix 39

• Copying files and directories


• Moving and renaming files
• Removing files
• Creating a directory
• Removing a directory
The UNIX filesystem structure
Allthe stored information on a UNIX computer is kept in afilesystem. Any time you interact
with the UNIX shell, the shell considers you to be located somewhere within a filesystem. Although .
. it may seem strange to be "located" somewhere in a computer's filesystem, the concept is not so
• different from real life. After all, you can't just be, you have to be somewhere. The place in the
filesystem tree where you are located is called the current working directory.
The UNIX filesystem is hierarchical (resembling a tree structure). The tree is anchored at a place
called the root; designated by a slash "/". Every item in the UNIX filesystem tree is either a file,
or a directory. A directory is like a file folder. A directory can contain files, and other directories.
A directory contained within another is called the child of the other. A directory in the filesystem
tree may have many children, but it can only have one parent. A file can hold information, but
cannot contain other files, or directories.
To describe a specific location in the filesystem hierarchy, you must specify-a "path." The path to
a location can be defmed as an absolute path from the root anchor point, or as a relative path,
starting fromthe current location. When specifying a path, you simply trace a route through the
filesystem tree, listing the sequence of directories you pass through as you go from one point to
another. Each directory listed in the sequence is separated by a slash.
UNIX provides the shorthand notation of"." to refer to the current location, and ".." to refer to
the parent directory.
Activity:
1) Specify the absolute path to the directory named "jon" at the bottom of the tree diagram.
Answer: Since the absolute path must always begin at the root (f) directory, the path would be:
/users/admin/jon
2) Specify the relative path from the directory named "student" to the directory named "jon" in
the tree diagram.
_ Answer: Starting from the student directory, we would first have to move up the filesystem tree
(using the ".." notation) to the directory called "users" before we could descend to the directory
called ''jon''. The path would be:
../admin/jon
File and directory permissions
UNIX supports access control. Every file and directory has associated with it ownership, and
access permissions. Furthermore, one is able to specify those to whom the permissions apply.

I
40 Introduction to Computers

Permissions are defined as read, write, and execute. The read, write, and execute permissions
are referred to as r, w, and x, respectively. Those to whom the permissions apply are the user
who owns the file, those who are in the same group as the owner, and all others. The user, group,
and other permissions are referred to as u, g, and 0, respectively.
UNIX allows users to be placed in groups, so that the control of access is made simpler for
administrators.
The meaning of file and directory permissions
Read permission
-
For a file, having read permission allows you to view the contents of the file. For a directory,
having read permission allows you to list the directory's contents.
Write permission "
For a file, having write permission allows you to modify the contents of the file. For a directory,
write permission allows you to alter the contents of the directory, i.e., to add or delete files.
Execute permission
For a file, execute permission allows you to run the file, if it is an executable program, or script.
Note that file execute permission is irrelevant for nonexecutable files. For a directory, execute
permission allows you to cd to the directory, and make it your current working directory.
Viewing permissions

To see the permissions on a file, use the Is command, with the -1option.
Example: Execute the command
,
ls -1 /etc/passwd

to view the information on the system password database. The output should look similar to this:
-rw-r-r-1 root sys 41002 Apr 17 12:05 /etc/passwd
The first 10 characters describe the access permissions. The first dash indicates the type of file (d
for directory, s for special file, - for a regular file). The next three characters ("rw-") describe the
permissions of the owner of the file: read and write, but no execute. The next three characters
("r-") describe the permissions for those in the same group as the owner: read, no write, no
execute. The next three characters describe the permissions for all others: read, no write, no
execute.
Setting permissions
UNIX allows you to set the permissions on files that you own. The command to change the file
permission mode is chrnod. Chrnod requires you to specify the new permissions you want, and
specify the file or directory you want the changes applied to.
To set file permissions, you may use the "rwx" notation to specify the type of permissions, and
the "ugo" notation to specify those the permissions apply to.
To defme the kind of change you want to make to the permissions, use the plus sign (+) to add a
permission, the minus sign (-) to remove a peimission, and the equal sign (=) to set a permission
directly.
42 Introduction to Computers

Answer: The "cd .." command should have moved you up one level in the directory tree, because
".." is UNIX shorthand for the parent directory. The result of the second "pwd" command
should be the same as the first, with the last directory in the path omitted.

Listing the contents of a directory .


The Is command allows you to see the contents of a directory, and to view basic information (like
size, ownership, and access permissions) about files and directories. The Iscommand has numerous
options. See the manual page on Is (type man 1 s) for a complete listing. The Is command also
accepts one or more arguments. The arguments can be directories, or files.
Example: Type the command
Is -lr /etc/i*

to the UNIX shell.


In the example, the "I" and "r" options of the Is command are invoked together. Some commands
permit you to group options in that way, and some commands require the options to be named
separately, e.g., 1 s - 1 - r. The 1option calls for a long output, and the r option causes Is to
operate recursively, moving down directory trees.
The last part of the example, "fetcli *", directs the Is command to list files and directories in the f
etc directory, that begin with the letter i. The wildcard character, "*", matches any character(s).
Activity:
1) Type the command
Is -m /etc/i*g

to the shell. How did the shell respond, and why?


Answer: The shell responded by printing all the entries in the fetc directory that start with the
letter i, and end with the letter g. The -rn option causes the output to be streamed into a single
line. See the online manual page for Is to get a complete/description of the Is command's options.
2) Find the permissions on your home directory.
Answer: There are many ways to accomplish this. You could type
cd

to get to your home directory, and then type


Is .-la

The -a option instructs the Is command to list all files, including those that start with the period
character. The directory permissions are listed next to the "." symbol. Remember that"." is
UNIX shorthand for the current working directory.
Viewing the contents of a file
Text files are intended for direct viewing, and other files are intended for computer interpretation.
The UNIX file command allows you to determine whether an unknown file is in text format,
suitable for direct viewing.
Unix 43

Activity:
1) Type the command
file /bin/sh

to see what kind of file the shell is.


Answer: The shell is a shared executable, indicating that the file contains binary instructions to be
executed by the computer.
The cat command
The 'cat command concatenatesfiles.and sends them to the screen. You can specify one or more
files as arguments. Cat makes no attempt to format the text in any way, and long output may
scroll off the scrt!t!nbefore you can read it.
Example: Send the contents of your. profile file to the screen by typing
eat -/.profile

to the shell. The wild character (- ) is UNIX shorthand for your home directory.
Thernorecommand
The more command displays a text file, one screenful at a time. You can scroll forward a line at
atime by pressing the return key, or a screenful at a time by pressing the spacebar. You can quit
at any time by pressing the q key.
Example: Type
more fete/re
to the shell. Scroll down by pressing return, and by pressing the spacebar. Stop the more command
from displaying the rest of the file by typing q.
The head and tail commands
. The head command allows you to see the top part of a file. You may specify the number of lines
you want, or default to ten lines.
Example: Type
head -15 fete/re
to see the first fifteen lines of the fetclrc file.
The tail command works like head, except that it shows the last lines of file.
Example: Type
tail fete/re
to see the last ten lines of the file fetclrc. Because we did not specify the number of lines as an
option, the tail command defaulted to ten lines.
Copying files and directories
The UNIX command to copy a file or directory is cp. The basic cp command syntax is cp
source destination.

I
44 Introduction to Computers

Example: The command

cp -/ .profile -/pcopy

makes a copy of your .profile file, and stores it in a file called "pcopy" in your home directory.
Activity:

1) Describe the permissions necessary to successfully execute the command in the previous
example.
Answer: To copy the .profile file, one must have read permission on the file. To create the new
file called pcopy, one must have write permission in the directory where the file will be created.
Moving and renaming files

The UNIX mv command moves files and directories. YO\lcan move a file to a different location
in the filesystem, or change the name by moving the file within the current location.
Example: The command

mv - /pcopy - / qcopy

takes the pcopy file you created in the cp exercise, and renames it "qcopy".
Removing flies

The rm command is used for removing files and directories. The syntax of the rm command is rm
filename. You may include many filenames on the commarid line.

Example: Remove .shrccopy file in your home directory by typing

rm - / . shrccopy

Creating a directory

The UNIX mkdir command is used to make directories. The basic syntax is mkdir directoryname.
If you do not specify the place where you want the directory created (by giving a path as part of
the directory name), the shell assumes that you want the new directory placed within the current
working directory.
Example: Create a directory called foo within your home directory by typing

mkdir -/foo

Activity:

1) Create a directory called bar, within the directory called foo, within your home directory.
Answer: Once the foo directory is created, you could just type
mkdir - / foo/bar

Alternately, you could type


cd - / foo; mkdir bar

In the second solution, two UNIX commands are given, separated by a semicolon. The first part
of the command makes foo the current working directory, The second part of the command
1
Unix 45

creates the bar directory in the current working directory.


Removing a directory

The UNIX nndir command removes a directory from the filesystem tree. The nndir command
does not work unless the directory to be removed is completely empty.
The nn command, used with the -r option can also be used to remove directories. The nn -r
command will first remove the contents of the directory, and then remove the directory itself.
Activity:

1) Describe how to remove the "foo" directory you created, using both nndir, and nn with the
-r option,
Answer: You could enter the commands
rmdir -/foo/bar; rmdir -/foo

to accomplish the task with the nndir command. Note that you have to nndir the bar subdirectory
before you can nndir the foo directory. Alternately, you could remove the foo directory with the
command .

rm -r -/foo

3.5 REDIRECTING INPUT AND OUTPUT


Every program you run from the shell opens three files: standard input, standard output, and
standard error. The files provide the primary means of communications between the programs,
and exist for as long as the process runs.
The standard input file provides a way to send data to a process. As a default, the standard input
is read from the terminal keyboard.
The standard output provides a means for the program to output data. As a default, the standard
output goes to the terminal display screen.
The standard error is where the program reports any errors encountered during execution. By
default, the standard error goes to the terminal display.
A program can be told where to look for input and where to.send output;using input/output
redirection. UNIX uses the "less than" and "greater than" special characters «and» to signify
input and output redirection, respectively.
Redirecting input

Using the "less-than" sign with a file name like this:


< filel

in a shell command instructs the shell to read input from a file called "file 1" instead of from the
keyboard.
Example: Use standard input redirection to send the contents of the file /etc/passwd to the more
command:
46 Introduction to Computers

more < /ete/passwd

Many UNIX commands that will accept a file name as a command line argument, will also
accept input from standard input if no file is given on the command line.
Example: To see the first ten lines of the letc/passwd file, the command:

head /ete/passwd

will work just the same as the command:


head < /ete/passwd

Redirecting output

Using the "greater-than" sign with a file name like this:


> fi1e2

causes the shell to place the output from the command in a file called "file2" instead of on the
screen. If the file "file2" already exists, the old version will be overwritten.
Example: Type the command

ls /tmp> - /ls. out

to redirect the output of the Iscommand into a file called "Is.out" in your home directory. Remember
that the tilde (-) is UNIX shorthand for your home directory. In this command, the Is command
will list the contents of the Itmp directory.
Use two "greater-than" signs to append to an existing file. For example:
>> fi1e2

causes the shell to append the output from a command to the end of a file called "file2". If the file
"file2" does not already exist, it will be created.
Example: In this example, list the contents ofthe/tmp directory, and put it in a file called myls.
Then, list the contents of the letc directory, and append it to the file myls:
ls /tmp > my1s
ls fete >> my1s

Redirecting error

Redirecting standard error is a bit trickier, depending on the kind of shell you're using (there is
more than one flavor of shell program). In the POSIX shell and ksh, redirect the standard error
with the symbol "2>".
Example: Sort the letc/passwd file, place the results in a file called foo, and trap any errors in a
file called err with the command:
sort < /ete/passwd > foo 2> err

3.6 PIPELINES AND FILTERS


UNIX allows you to connect processes, by letting the standard output of one process feed into
Unix 47

the standard input of another process. That mechanism is called a pipe.


Connecting simple processes in a pipeline allows you to perform complex tasks without writing
complex programs.
Example: Using the more command, and a pipe, send the contents of your .profile and .shrc
files to the screen by typing
cat .profile .shrc I more
to the shell.
.Activity:
1) How could you use head and tail in a pipeline to display lines 25 through 75 of a file?
Answer: The command
cat file I head -75 I tail -50
would work. The cat command feeds the file into the pipeline. The head command gets the first
75 lines of the file, and passes them down the pipeline to tail. The tail command then filters out all
but the last 50 lines of the input it received from head. It is important to note that in the above
; example, tail never sees the original file, but only sees the part of the file that was passed to it by
the head command.
It is easy for beginners to confuse the usage of the input/output redirection symbols < and >, with
the usage of the pipe. Remember that input/output redirection connects processes withfiles,
while the pipe connects processes with other processes.
GREP
The grep utility is one of the most useful filters in UNIX. Grep searches line-by-line for a specified
pattern, and outputs any line that matches the pattern. The basic syntax for the grep command is
grep [-options] pattern [file]. If the file argument is omitted, grep will read from standard input.
It is always best to enclose the pattern within single quotes, to prevent the shell from misinterpreting
the command.
The grep utility recognizes a variety of patterns, and the pattern specification syntax was taken
from the vi editor. Here are some of the characters you can use to build grep expressions:
• The carat (1\) matches the beginning of a line.
• The dollar sign ($) matches the end of a line.
• The period (.) matches any single character.
• The asterisk (*) matches zero or more occurrences of the previous character.
• The expression [a-b] matches any characters that are lexically between a and b.
Example: Type the command
grep 'jon' /etc/passwd

to search the /etc/passwd file for any lines containing the string "jon".
48 Introduction to Computers

Example: Type the command


grep "jon' /etc/passwd
,

to see the lines in /etc/passwd that begin with the character string "jon".
Activity:
1) List all the files in the /tmp directory owned by the user root.
Answer: The command
1s -1. /tmp I grep 'root'

would show all processes with the word "root" somewhere in the line. That doesn't necessarily
mean that all the processes would be owned by root, but using the grep filter can cut the down
the number of processes you will have to look at.

3.7 PROCESSCONTROLANDMULTITASKING
The UNIX kernel can keep track of many processes at once, dividing its time between the jobs
submitted to it. Each process submitted to the kernel is given a unique process ID.
Single-tasking operating systems, like DOS, or the Macintosh System, can only perform one job
at a time. A user of a single-tasking system can switch to different windows, running different
applications, but only the application that is currently being used is active. Any other task that has
been started is suspended until the user switches back to it. A suspended job receives no operating
system resources, and stays just as it was when it was suspended. When a suspended job is
reactivated, it begins right where it left off, as if nothing had happened. The UNIX operating
system will simultaneously perform multiple tasks for a single user.Activating an application does
not have to cause other applications to be suspended.
Actually, it only appears that UNIX is performing the jobs simultaneously. In reality, it is running
only one job at a time, but quickly switching between all of its ongoing tasks. The UNIX kernel
will execute some instructions fromjob A, and then set job A aside, and execute instructions
from job B. The concept of switching between queued jobs is called process scheduling.
Viewing processes
UNIX provides a utility called ps (process status) for viewing the status of all the unfinished jobs
that have been submitted to the kernel. The ps command has a number of options to control
which processes are displayed, and how the output is formatted.
Example: Type the command
ps

to see the status of the "interesting" jobs that belong to you. The output of the ps command,
without any options specified, will include the process ID, the terminal from which the process
was started, the amount of time the process has been running, and the name of the command that
started the process.
Example: Type the command
ps -ef
1
Unix 49

to see a complete listing of all the processes currently scheduled. The -e option causes ps to
include all processes (including ones that do not belong to you), and the -f option causes ps to
give a long listing. The long listing includes the process owner, the process ID, the ID of the
parent process, processor utilization, the time of submission, the process's terminal, the total time
for the process, and the command that started the process.
Activity:

1) Use the ps command, and the grep command, in a pipeline to find all the processes owned
by you.
Answer: The command
ps - ef I grep yourusername

where "yourusemame" is replaced by your user name, will cause the output of the ps -ef command
to be filtered for those entries that contain your username.
Killing processes

Occasionally, you will find a need to terminate a process. The UNIX shell provides a utility called
kill to terminate processes. You may only terminate processes that you own (i.e., processes that
you started). The syntax for the kill command is kill [-options] process-ID.
To kill a process, you must first find its process ID number using the ps command. Some processes
refuse to die easily, and you can use the" -9" option to force termination of the job.
Example: To force termination of a job whose process ID is 111, enter the command

kill -9 111

'3.8 INTERACTION AND JOB CONTROL


When you log in to a UNIX system, the kernel starts a shell for you, and connects the shell to
your terminal. When you execute a command from the shell, the shell creates a child process to
execute the command, and connects the child process to your terminal. By connecting the child
process to your terminal, the shell allows you to send input to the child process, and receive
output from it. When the child process finishes, the shell regains access to the terminal, redisplays
the shell prompt, and waits for your next command.
Any task that requires you to actively participate (like word processing) must be in the foreground
to run. Such jobs, termed "interactive," must periodically update the disI?lay, and accept input
from you, and so require access to the terminal interface.
Other jobs do not require you to participate once they are started. For example, ajob that sorts
the contents of one file and places the results in another file, would not have to accept user
commands, or write information to the screen while it runs. Some UNIX shells allow such non
interactive jobs to be disconnected from the terminal, freeing the terminal for interactive use.
Note.that it is even possible to log out, and leave a background process running. Unfortunately,
there is no way to reconnect a backgroundjob to the terminal after you've logged out.
Jobs that are disconnected from the terminal for input and output are called "background" jobs.
You can have a large number of background jobs running at the same time, but you can only have
r

50 Introduction to Computers

one foreground job. That is because you only have one screen, and one keyboard at your
terminal,

Background and foreground jobs


The process that is connected to the terminal is called thejoreground job. Ajob is said to be in
the foreground because it can communicate with the user via the screen, and the keyboard.
A UNIX process can be disconnected from the terminal, and allowed to run in the background.
Because background jobs are not connected to a terminal, they cannot communicate with the
user.If the background job requires interaction with the user, it will stop; and wait to be reconnected
to the terminal. Jobs that do not require interaction from the user as they run (like sorting a large
file) can be placed in the background, allowingthe. user to access the terminal, and continue to
work, instead of waiting for a long job to finish.
Starting ajob in the background
To place ajob in the background, simply add the ampersand character (&) to the end of your
shell command.
Example: To sort a file called "foo", and place the results in a file called "bar", you could issue
the command
sort < foo > bar &
Examining your jobs

The UNIX command jobs allows you to see a list of all the jobs you have invoked from the
current shell. The shell will list the job ID of each job, along with the status (running, stopped, or
otherwise), and the command that started the job. The shell considers the most recently-created
(or most recently -manipulated) job to be the current job, marked with a plus sign. Other jobs
are referred to as previous jobs, and are marked with a minus sign. The commands related to
job control will apply to the current job, unless directed to do otherwise. You may refer to jobs
by job ID by using the percent sign. Thus,job 1 is referred to as %1,job 2 is %2, and so forth.
Suspending the foregroundjob
You can (usually) tell UNIX to suspend the job that is currently connected to your terminal by
typing Control-Z (hold the control key down, and type the letter z). The shell will inform you that
the process has been suspended, and it will assign the suspended job a job ID.
There is a big difference between a suspended job,and a job running in the background. A
suspended job is stopped, and no processing will take place for that job until you run it, either in
the foreground, or in the background.
Placing a foregroundjob into the background
If you started ajob in the foreground, and would like to place it in the background, the first thing
you must do is suspend the job with a Control-Z, freeing your terminal. Then, you can issue the
UNIX command
bg

to place the suspended job in the background. The bg command can accept a job ID as an
argument. If no job ID is given, bg assumes you are referring to the current (suspended) job.
l
Unix 51

Bringing a backgroundjob to the foreground


You can reconnect a background job to your terminal with the UNIX command
fg

The fg command will accept a job ID as an argument. Make sure to include the percent sign:
fg %2

will bringjob 2 into the foreground. If no job ID is given, fg will assume you are referring to the
current (suspended) job. .
Starting a suspended job
If you have a suspended job that you'd like to resume running, first you must decide whether you
want it running in the foreground, or the background. Find the job ID of the suspended job with
the jobs command, and then use bg (to run the job in the background), or fg (to run the job in the
foreground).

3.9 THEEXECUTIONENVIRONMENT
The exact behavior of commands issued in the shell depends upon the execution environment
provided by the shell.
The UNIX shell maintains a set of environment variables that are used to provide information,
like the current working directory, and the type of terminal being used, to the programs you run.
The environment variables are passed to all programs that are not built into the shell, and may be
consulted, or modified, by the program. By convention, environment variables are given in
uppercase letters .
.To view all the environment variables, use the command
printenv
You can also view a particular environment variable using the echo command:
echo $TERM

The above command echos the value of the TERM environment variable to the standard output.
The creation of the execution environment
When you log in, a sequence of events establishes the executionenvironment. The exact sequence
of events depends on the particular flavor of UNIX, and also depends upon the default shell for
your account. The following is a description of the login process for the HP-UX operating system.
Other operating systems may differ.
The getty process
The getty process provides the log in: prompt that you see on the terminal screen. The getty
process reads your usemame, and invokes the login program.
The login program
The login program receives the usemame from getty, and prompts you for your password. Login

I
52 Introduction to Computers

then consults the system database fete/passwd to verify your password. (Note that login will
request your password even if there is no entry in fetcfpasswd for the usemame you've given.
That prevents someone from finding valid usemames by trial and error.) Login turns off terminal
echo so that your password is not displayed on the screen.
Having verified your password, login then uses information in fete/passwd to invoke your default
shell. If no default shell is specified in the fete/passwd entry, login starts the Boume shell (lbinlsh).
Shell startup: System login scripts

When the shell program starts, it reads configuration files called login scripts to configure the
execution environment. On HP-UX, the file fete/profile provides initialization parameters for ksh
and sh, while the file fete/csh.login is used for csh. After the system login scripts are read, the shell
looks for user-specified login scripts.
Shell startup: User login scripts

After the system login scripts are read, the shell reads user login scripts. User login scripts are
kept in one's home directory, and are the means by which one can customize the shell environment.
Sh and ksh look for a file called. profile. Ksh also reads a file defined in the environment variable
ENV. Csh reads it file called .cshrc, and (if it is the login shell), the file .login.
Important environment variables

Given below are some of the important environment variables, and examples of how some variables
can affect the execution of commands.
TERM

The TERM environment variable defines the type of terminal that you are using. Most UNIX
systems have a database of terminal types, and the capabilities of each terminal type.
PATII

The PATH variable contains the names of directories to be searched for programs that correspond
to command names. When you issue a command to the shell, the shell searches sequentially
through each directory in the PATH list until it fmds an executable program with the command
name you typed. .

USER

The USER variable contains your usemame. Any time you access a file or directory, the access
permissions are checked against the value of USER.
HOME

The HOME variable contains the name of your home directory. When you issue the cd command
with no directory argument, you will be placed in the directory defined in the HOME environment
variable. The HOME variable is also where the shell will look for the user login scripts.
MAIL

The MAIL variable contains the name of the directory where your incoming mail is stored. When
you start a mail program, the program will look in the directory stored in the MAIL environment
•variable for your incoming mail messages.
1
Unix 53

EDITOR

The EDITOR variable is used by programs that must invoke a text editor to provide the ability to
edit or compose documents. One example is the elm program, which is used to read and send
electronic mail. If you elect to compose a new mail message while in elm, the elm program will
check the contents of the EDITOR variable to determine which editor to invoke.
HOST

The HOST environment variable contains the name of the host machine that is running your shell
program. When you connect to a remote host through telnet or ftp, the name of your host is
relayed to the remote machine, so the administrators of the remote machine can keep track of
who is connecting, and from where.
Setting environment and shell variables

The exact mechanism for setting the environment and shell variables depends upon the type of
shell you're using.
sh, or ksh

To set an environment variable in sh or ksh, use the syntax VAR=value;export VAR, where VAR
is the name ofthe environment variable and value is the value you wish to assign. Do not put
spaces on either side of the equal sign. The export command instructs the shell to propagate the
value of the variable to all programs that are run by the shell. If an environment variable is reset,
but not exported, the change will only apply to the shell itself. To set the EDITOR variable to the
value emacs in ksh or sh, use the command:
EDITOR=emacs; export EDITOR

It is also possible to unsetenvironment variables, with the unset command Unsetting an environment
variable removes the definition of the variable.
csh

To set an environment variable in csh, use the setenv command. The command has the syntax:
setenv VARIABLE value. To set the EDITOR variable to the value ernacs in csh, use the command:
setenv EDITOR emacs

For more information about the shell environment, consult the online manual page for the shell
you're using.

3.10 CUSTOMIZING THE UNIX SHELL


The UNIX shell is actually a user program that the kernel runs for you when you log in. There is
usually more than one shell available on most UNIX systems. The most common shells available
on UNIX systems are the Bourne Shell (sh), the C Shell (csh) and the Korn shell (ksh). Here is
a summary of features available on these three shells, adapted from the Hewlett Packard
"Beginner's Guide to HP-UX."
54 Introduction to Computers

Feature Function sh Csh ksh


Allows processes to be
Job control No Yes Yes
run in the backzround
Allows previous commands to
History substitution be No Yes Yes
saved edited and reused
Allows automatic completion of
File name completion No Yes Yes
partially typed file name
Command line Allows the use of an editor to
No No Yes
editing modify the command line text
Allows the user to rename
Command aliasing No Yes Yes
commands

Choosing your shell


It is possible to invoke any available shell from within another shell. To start a new shell, you can
simply type the name of the shell you want to run, ksh, csh, or sh.
It is also possible to set the default startup shell for all your future sessions. The default shell for
your account is stored in the system database /etc/passwd, along with the other information
about your account. To change your default shell, use the chsh command. The chsh command
requires one argument, the name of the shell you want as your default. To change your default
shell to the C shell, you could enter the command
chsh /bin/ csh

Default file access permissions


Whenever you create a file or directory in a UNIX filesystem, the newly created file or directory
is stamped with a default'set of permissions. That default set of permissions is stored in a variable
called the urnask. You can change the value of umask to suit your preferences. To see the current
value of the umask variable, enter the shell command:
umask

The umask is stored as an octal (base 8) number, that defines which permissions to deny. As you
recall, three kinds of file permissions (read, write, and execute) are given for each of three
classes of users (owner, group, and others). Each of the nine permissions is specified as a zero
(allow access), or a one (deny access).
To set your umask to deny write permission to group and others, use the command
umask 022

To deny all access to group and others, use the command


umask 077

Some versions of UNIX provide a more user-friendly way of specifying your umask. In HP-UX
sh-posix (or ksh), you are allowed to specify the access permissions in manner ofthe chmod
~
command. The command
umask u=rwx, g=r, o=r
Unix 55

would set the umask to deny write and execute pennissions to the group, and to others. That
kind of command syntax will not work in HP-UX's C shell or Bourne shell. The HP-UX posix
shell also allows the use of the command
umask -S

to print your umask setting in a more readable fashion.

3.11 INTERACTIVE USE OF THE SHELL


This section provides you with tips to make the shell work more efficiently for you.
File name completion
Both ksh and csh will perform file name completion for you. You can type in a partial file name,
and press the ESCAPE key (once for csh, twice for ksh). The shell will then complete the name
of the file for you. If no file exists that begins with the characters you typed, the shell will beep at
you, and will not complete the name. If more than one file begins with the characters you typed,
the shell will complete the name up to the point where the names differ. Then you can type
additional letters to specify the file name you want, reusing the ESCAPE key if desired.
Command name aliasing
Both csh and ksh provide command name aliasing, to allow you to rename commands. Aliasing
can save a lot of keystrokes if you must frequently issue the same lengthy command. The alias
command requires two pieces of information: the command you wish to alias, and the alias you
wish to use to refer to it.
Example: To alias the "history" command to "hi" you could use the following command in the
Kornshell:
alias hi=' history'

After entering that alias, you could type the command "hi" and the shell would,substitute "hi" with
the string "history" before executing it. The same command could be accomplished in the C shell
with the syntax:
alias hi history

Activity:
1) Create an alias in the Korn shell called "clean" that would remove any files from your home
directory that have the extension .gif or .jpg.
Answer: The command
alias clean='rm -/*.gif; rm -/*.jpg'

would work.
Command aliasing can be tricky. Surround the alias string with single quotes (') to prevent the
shell from interpreting special characters. If you use command history substitution in an alias, use
the backslash character (\) to escape characters that you don't want the shell to interpret.
Example: This example, written for the C shell, creates an alias for the cd command so that it
56 Introduction to Computers

stores the current location in a shell variable called old before it changes to the new location. It
also creates a new command alias called back that allows us to go back to the previous location:
alias cd 'set old=$cwd; chdir \! *; pwd'
alias back 'set foo=$old; cd $foo; unsetfoo'

There are several things to note in the above example. The alias for cd has three parts: - the
first reads the current working directory from the shell variable cwd, and saves it in a shell
variable called old. The second part uses history substitution and chdir to change the current
location. The use of chdir prevents an "aliasing loop," where the cd command calls itself. The
third part executes the pwd command to print the new location on the screen.
The alias for back also has three parts: - the first part reads the previous location from the shell
variable old, and stores it in a shell variable called foo. That is necessary because the new cd alias
will change the value of old when we call it in the second part of the back alias. The third part
cleans up our mess by unsetting the variable foo, removing it from the environment.
You can remove an alias using the unalias command. To remove the "clean" alias you created in
a previous exercise, enter the command:
unalias clean

Command history substitution

The C shell and Korn shell will keep an ordered list of the commands you have issued, and allow
you to retrieve commands from the list, That facility, called command history substitution,
makes it possible to reuse all or part of your previously issued commands. Each command on the
list is given a command number, according to the order it was issued. You can view the command
history list by issuing the command:
history

The exact mechanism of retrieving commands from the command history list depends on the shell
you're using, and how you have customized your shell.
ksh

When using the Korn shell, the number of commands remembered by the shell is controlled by
the IllSTSIZE environment variable. Use the command
HISTSIZE=50; export HISTSIZE

to set the length of the history list to fifty. By default, the history size is set to 128 lines.
csh

The C shell allows you to recall previous commands in whole or in part. In the C shell, the history
shell variable is usedto specify the number of lines the shell will remember. The statement
s et; history=60

will cause the C shell to remember sixty coinmands.


To recall previous commands from the history list, the C shell uses the exclamation point (!)
character, sometimes referred to in computer jargon as "bang." The bang character can be used
in combination with history line numbers and text patterns. Here are some examples of how to
1
Unix 57

use history substitution in the C shell :


Recall the last command:
! !

Recall the third most recent command:


! -3

Recall command number ten from the history list:


!10

Recallthe last command that began with the letters "Is" :


!ls

You can also recall specific pieces of previous commands and use them to create new commands.
The colon character is used to select specific words from a command. Each word in the command
is referred to by position. The command name itself is item number zero. Here are some examples:
Recall the third word from the last command:
!: 2

Perform an "Is" on the second word from command number 8 :


ls ! 8: 1

Use more to view the last item from command number ten:
more ! 10: $

Editing the command line


The Kom shell (ksh) provides the ability to edit the command history list almost as if your were
in an editor program like vi, or emacs. The current command is always the last line in the history
list and begins blank:.You can type in a new command, or recall an earlier command from the list.
You can also modify the text on the current line using basic text editor commands.
The mechanism for setting the editor style in ksh is the "set -0" command. To edit in emacs mode,
issue the command:
set -0 emacs

3.12 THE UNIX FILE SYSTEM


Most UNIX machines store their files on magnetic disk drives. A disk drive is a device that can
store information by making electrical imprints on a magnetic surface. One or more heads skim
close to the spinning magnetic plate, and can detect, or change, the magnetic state of a given spot
on the disk. The drives use disk controllers to position the head at the correct place at the correct
time to read from, or write to, the magnetic surface of the plate. It is often possible to partition a
single disk drive into more than one logical storage area. This section describes how the UNIX
operating system deals with a raw storage device like a disk drive and how it manages to make
organized use of the space.
58 Introduction to Computers

How the UNIX me system works

Every item in a UNIX file system can de defined as belonging to one of four possible types:
Ordinary files

Ordinary files can contain text, data, or program information. An ordinary file cannot contain
another file, or directory. An ordinary file can be thought of as a one-dimensional array of bytes.
Directories

In a previous section, we described directories as containers that can hold files, and other
directories. A directory is actually implemented as a file that has one line for each item contained
within the directory. Each line in a directory file contains only the name of the item, and a numerical
reference to the location of the item. The reference is called an i-number, and is an index to a
table known as the i-list. The i-list is a complete list of all the storage space available to the file
system.
Special files

Special files represent input/output (i/o) devices, like a tty (terminal), a disk drive, or a printer.
Because UNIX treats such devices as files, a degree of compatibility can be achieved between
.device i/o, and ordinary file i/o, allowing for the more efficient use of software. Special files can
be either character specialfiles, that deal with streams of characters, or block specialfiles,
that operate on larger blocks of data. Typical block sizes are 512 bytes, 1024 bytes, and 2048
bytes.
Links

A link is a pointer to another file. Remember that a directory is nothing more than a list of the
names and i-numbers of files. A directory entry can be a hard link, in which the i-number points
directly to another file. A hard link to a file is indistinguishable from the file itself. When a hard link
is made, then the i-numbers of two different directory file entries point to the same inode. For that
reason, hard links cannot span across file systems. A soft link (or symbolic link) provides an
indirect pointer to a file. A soft link is implemented as a directory file entry containing a pathname.
Soft links are distinguishable from files, and can span across file systems. Not all versions of
UNIX support soft links.
The I-List

When we speak of a JJNIX file system, we are actually referring to an area of physical memory
represented by a single i-list. A UNIX machine may be connected to several file systems, each
with its own i-list.One ofthose i-lists points to a special storage area, known as the rootfile
system. The root file system contains the files for the operating system itself, and must be available
at all times. Other file systems are removable. Removable file systems can be attached, or
mounted, to the root file system. Typically, an empty directory is created on the root file system
as a mount point, and a removable file system is attached there. When you issue a cd command
to access the files and directories of a mounted removable file system, your file operations will be
controlled through the i-list of the removable file system.
The purpose of the i-list is to provide the operating system with a map into the memory of some
physical storage device. The map is continually being revised, as the files are created and removed,
1
Unix 59

and as they shrink and grow in size. Thus, the mechanism of mapping must be very flexible to
accomodate drastic changes in the number and size of files. The i-list is stored in a known
location, on the same memory storage device that it maps.
Each entry in an i-list is called an i-node. An i-node is a complex structure that provides the
necessary flexibilityto track the changing file system. The i-nodes contain the information necessary
to get information from the sto~ge device, which typically communicates in fixed-size disk blocks.
An i-node contains 10 direct pointers, which point to disk blocks on the storage device. In
addition, each i-node also contains one indirect pointer, one double indirect pointer, and one
triple indirect pointer. The indirect pointer points to a block of direct pointers. The double
indirect pointer points to a block of indirect pointers, and the triple indirect pointer points to a
blockof double indirect pointers. By structuring the pointers in a geometric fashion, a single i-
node can represent a very large file.
lt now makes a little more sense to view a UNIX directory as a list of i-numbers, each i-number
referencing a specific i-node on a specific i-list. The operating system traces its way through a file
path by following the i-nodes until it reaches the direct pointers that contain the actual location of
the file on the storage device.
File system related commands

. Here are some commands related to file system usage, and other topics discussed in this section:
bdf
Reports file system usage statistics
df
Reports on free disk blocks, and i-nodes
du
Summarizes disk usage in a specified directory hierarchy
In
Creates a hard link (default), or a soft link (with -s option)
mount, umount
Attaches, or detaches, a file system (super user only)
mkfs

Constructs a new file system (super user only)


fsck
Evaluates the integrity of a file system (super user only)
A brief tour of the UNIX filesystem

The actual locations and names of certain system configuration files will differ under different
implementations of UNIX. Here are some examples of important files and directories under
version 9 of the HP-UX operating system:
1
Unix 59

and as they shrink and grow in size. Thus, the mechanism of mapping must be very flexible to
accomodate drastic changes in the number and size of files. The i-list is stored in a known
location, on the same memory storage device that it maps.
Each entry in an i-list is called an i-node. An i-node is a complex structure that provides the
necessary flexibility to track the changing file system. The i-nodes contain the information necessary
to get information from the sto~ge device, which typically communicates in fixed-size disk blocks.
An i-node contains 10 direct pointers, which point to disk blocks on the storage device. In
addition, each i-node also contains one indirect pointer, one double indirect pointer, and one
triple indirect pointer. The indirect pointer points to a block of direct pointers. The double
indirect pointer points to a block of indirect pointers, and the triple indirect pointer points to a
block.of double indirect pointers. By structuring the pointers in a geometric fashion, a single i-
node can represent a very large file.
It now makes a little more sense to view a UNIX directory as a list of i-numbers, each i-number
referencing a specific i-node on a specific i-list. The operating system traces its way through a file
path by following the i-nodes until it reaches the direct pointers that contain the actual location of
the file on the storage device.
File system related commands

, Here are some commands related to file system usage, and other topics discussed in this section:
bdf
Reports file system usage statistics
df

Reports on free disk blocks, and i-nodes


du

Summarizes disk usage in a specified directory hierarchy


In
Creates a hard link (default), or a soft link (with -S option)

mount, umount
Attaches, or detaches, a file system (super user only)
mkfs

Constructs a new file system (super user only)


fsck
Evaluates the integrity of a file system (super user only).
A brief tour of the UNIX filesystem

The actual locations and names of certain system configuration files will differ under different
implementations of UNIX. Here are some examples of important files and directories under
version 9 of the HP-UX operating system:
60
Introduction to Computers

/hp-ux

The kernel program


ldevl

Where special files are kept


/bin!

Executable system utilities, like sh, cp, rm


lete!

System configuration files and databases


!lib!

Operating system and programming libraries


Itmpl

System scratch files (all users can write here)


/lost+found/

Where the file system checker puts detached files


lusr/bin!

Additional user commands


lusr/include!

Standard system header files


lusrllibl

More programming and system call libraries


lusr!local/

Typically a place where local utilities go


lusr/man

The manual pages are kept here


Other places to look for useful stuff

If you get an account on an unfamiliar UNIX system, take a tour of the directories listed above,
and familiarize yourself with their contents. Another way to find out what is available is to look at
the contents of your PATH environment variable:
echo $PATH

You can use the Is command to list the contents of each directory in your path, and the man
command to get help on unfamiliar utilities. A good systems administrator will ensure that manual
pages are provided for the utilities installed on the system.
1
U~ 61

3.13 EXERCISES FOR PRACTICE IN LAB SESSION


Exercises
1) Display the name of your home directory on the screen.
2) List out the names of all the files in your home directory.
3) Change the working directory to root directory.
4) Create a new directory called newdir under the directory temp under home directory.
5) . Rename the newdir as olddir.
6) .Remove all the files under the directory "olddir" under the "temp directory"
7) Display the name of all users logged in currently.
8) Create a new directory letters under the temp directory. From your home directory, move
'all files from the directory temp to the directory letters.

You might also like