MLIL 001 (English)
MLIL 001 (English)
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
- Indira Gandhi
lte'l\i Indira Gandhi PGDLAN
~.Jt National Open University
LAB MANUAL
School of Social Sciences
101
Section3 CirculationModule
113
Section4 SerialsControl Module
* MLIL-007 Programming
Section 1 ,'Java
277
Section 2 ThrboC++
286
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.
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
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
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.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
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:
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:
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
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
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.
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,
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
b) Command
c) Notepad
d) WordPad
e) Paint
5) Using the find command find the file/folder Hindustan.
,
Activity:
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
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.
[Hint: Go to window explorer and select the file and click on rename in file menu and type the
new name]
7) Copy Hindustan folder to other folder (Create other folder and copy the Hindustan folder
to it)
10) Using the shortcut key copy the folder from the new folder and paste it in floppy disk.
Activity:
1) Open your word processing program (you do not have to really type anything unless you
wish).
4) Find the Temp folder and double click on it. It will pop (appear) in to the save in box
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.
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.
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:
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
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.
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
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
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.
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.
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.
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.
I
26 Introduction to Computers
3) Under Desktop icons, click an icon to change, and then click Default Icon.
1) Open the Display Properties dialog box, click on the Screen Saver tab.
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.
1) Open the Display Properties dialog box, click on the Screen Saver tab.
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.
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.
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.
3) Open the Display Properties dialog box, click on the Settings tab.
1) Open the Display Properties dialog box, click on the Settings tab.
3) On the General tab, in Font Size, click the size you want your displayed fonts to be.
3) Double-click the icon that represents the settings you want to change.
5) Click=.
.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.
4) Click an operator.
7) Click=.
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.
Draw a curve
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.
You can draw a perfect circle by holding down SHIFT while you drag.
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
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).
Erase an area
On the View menu, point to Zoom, and then click Normal Size, Large Size, or Custom.
• 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.
Exercise 1
1) Start the computer and give the command to start Windows at the C:/> prompt.
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
2) Now create a new program group window and label this with your own name.
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.
9) Using the File Manager, copy a set of continuous files to your floppy disk.
15) Associate all files with the extension .Doc with the application notepad.
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
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?
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.
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.
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
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. ,. ,
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 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
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.
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 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
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.
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
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
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
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
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
Redirecting output
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
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
to search the /etc/passwd file for any lines containing the string "jon".
48 Introduction to Computers
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
50 Introduction to Computers
one foreground job. That is because you only have one screen, and one keyboard at your
terminal,
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
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.
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
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
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
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
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
Use more to view the last item from command number ten:
more ! 10: $
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
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
mount, umount
Attaches, or detaches, a file system (super user only)
mkfs
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
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