You are on page 1of 15

An Introduction to MS DOS

An Introduction to
MS DOS

? St. Xavier College

An Introduction to MS DOS

1.0

Introduction

DOS is an acronym for Disk Operating System. When IBM released the
Personal Computer in 1981, using the Intel 8088 as the CPU, Microsoft
Corporation was approached to provide the operating system for the same.
Microsoft created MS DOS, the Microsoft Disk Operating System for the IBM
personal computers. It controls different parts of the personal computer i.e. the
Input / Output devices like monitors, printers, disk drives etc.

(C:\ and A:\ are known as C prompt and A prompt respectively. This is an
indication for the user to know that the computer is ready for executing
commands)
In case a floppy is present while booting, it must be bootable, i.e., it should
have the three main files COMMAND.COM, IO.SYS and MSDOS.SYS.
Otherwise, after confirming that a floppy is inside the drive which is not
bootable, the computer will give an error message.
Bad or missing command interpreter

DOS is a single user and single tasking system. The first software was called
as DOS Version 1.0 which had all the basic features. Since then, several new
features have been incorporated. The latest version of DOS, is Ver 6.22. The
basic hardware requirement for ver 6.22 is a 16 bit Personal Computer with
640 KB RAM and a hard disk & Floppy drives.

Booting DOS
The basic software which makes the user to interact with the machine and
control to some extent is called the Operating System. Whenever the computer
is switched on the operating system gets loaded into the memory. The process
of loading DOS is called as booting DOS. To boot DOS, switch on the
computer. Once started up, the computer performs its self-test i.e. power-on
hardware diagnostics called POST (Power ON Self Test). At this time, the
computer examines most of its critical hardware components. The computer
then displays the amount of memory present on the system. It checks the
floppy drive (if available on the machine) to see if a floppy has been inserted. If
there is no floppy, it checks the hard disk, loads IO.SYS and MSDOS.SYS
into the RAM and runs a file called CONFIG.SYS and then loads
COMMAND.COM. Thereafter, AUTOEXEC.BAT is executed.
Once the system boots up properly it displays the DOS prompt along with a
blinking cursor which tells that anything typed will appear at that point:
C:\> if the booting is done from the harddisk., A:\> if the booting is done from
Floppy disk.

In such a case, remove the earlier floppy diskette and insert a bootable diskette
and start the computer again.

An Introduction to MS DOS
DIR filename

Types of DOS Commands


DOS has basically two types of commands: internal and external.

It will display the file and other related information, if the file is present,
otherwise it gives the message as file not found.
C:\>DIR CONFIG.SYS

MS DOS

DIR filename options


The options are preceded by a slash (/) which is also called a switch.

Internal DOS Commands

External DOS Commands

/P Pauses at the end of the screen and waits for a key to be pressed.
/S Displays files in a specified directory and all subdirectories.
Internal commands are built into DOS and can be executed at any time. They
get loaded into the computers memory as soon as the machine is switched on.
External commands are disk-based commands that reside on the DOS disk
and require other special specific files, apart from the three main files.

1.2

Internal Commands

The CPU, i.e., the Central Processing Unit, is the main controller i.e. heart of
the computer and all the commands are processed by it. The internal
commands are present in the RAM while the machine is on. Whenever the user
issues a command, the CPU checks up the RAM. If the command is an internal
one, the CPU performs the operation as per the command and the output is
displayed to the user. The main advantage internal command is that they are
executed faster. Therefore, the commands which are needed most often are
internal as it saves a lot of time.
1.2.1

Listing Contents of a Directory

It is used to list any or all the files and subdirectories in a directory. The drive,
path, switches and wildcards can be used.
Syntax: DIR
C:\>DIR
? St. Xavier College

/A Displays all the files with set attributes like hidden files etc.
C:\>DIR/P
1.2.2

Wildcard Characters

Wildcard characters, i.e., * (asterisk) and ? (question mark) are used in cases
when a number of files have to be referred or a specific file when full-name is
not known. * can be used to replace characters anywhere from 1 to 8 (from
that location to end of the extension) before the . and 1 to 3 characters after
the . while ? can be used to replace only one character.
1.2.3

TYPE

It displays the contents of a specified file on the screen. Wildcards are not
allowed. The output of TYPE can be redirected to the printer or to another file.
Syntax: TYPE filename
C:\>TYPE CONFIG.SYS

An Introduction to MS DOS
1.2.4

CLS

Any name which is not indicated by hyphen lines means that it is a filename
and not a directory name.

This command clears the screen and displays the command prompt and
cursor.
Syntax: CLS
1.2.5

Making a Directory

Take an example of an institute in which there are many Programs. Each


Program further has many sections and each of those sections have many
students.
Similarly, while storing data on any media one may like it to be placed
methodically. This is done by the MD command with the help of which different
directories and subdirectories can be made.
On the machine when no directories have been created all the files are in one
main directory which is referred to as the ROOT; also known as C:\ or A:\ or B:\.
With reference to root every other directory becomes a child directory or a
subdirectory. If the directories in the above example were to be created, the
hierarchy would be something like:

Here INSTITUTE1, INSTITUTE2 signify that they are child directories or


subdirectories of the parent directory ROOT. Further PROGRAM1,
PROGRAM2 are subdirectories of the directory INSTITUTE1. SECTION1 is a
child of the directory PROGRAM1 and is also the parent for ST1 which further
has FILE1. This kind of hierarchy is also known as a TREE structure, with each
subdirectory being its branch and the files of that subdirectory being its leaves.
Syntax: MD <directory name>

or

MKDIR <directory name>

or

MD path\<directory name>
C:\>MD DOE <RETURN>
Creates subdirectory DOE in the root directory.
1.2.6

Changing a Directory

CD stands for change directory.


C:\

Syntax: CD [path]dirname
C:\>CD XAVIER1

INSTITUTE1

PROGRAM1

INSTITUTE2

This will move the user from the current directory, i.e., root to the directory
XAVIER1. After execution, the prompt will change to:
C:\XAVIER1>

PROGRAM2

1.2.7
SECTION1

SECTION2

DEL

The Delete command erases one or more files from the directory. Wildcard
characters can be used with this command.

ST1

Syntax: DEL filename

An Introduction to MS DOS
C:\>DEL TEMP
1.2.8

Copies ABC to XYZ thereby creating two files ABC and XYZ which have the
same contents.

PROMPT
COPY path \ sourcefilename(s) path

This is an internal command used to customise the DOS prompt. To use certain
characters, the appropriate options should be entered in the prompt string.
Syntax: PROMPT options

It will copy the specified file or files from the directory mentioned in the path to
the target path under the same name or names (in case many files are being
copied). If a different name is desired in the target directory, then a new name
has to be mentioned for the copied file in the target path.

Options are:
C:\>COPY C:\YACH\FILE1 C:\TEMP <RETURN>
$P Displays the current disk drive and path.
$G Displays the greater than symbol.

It will copy file1 from the yach directory to the temp directory under the same
name, i.e., file1.

$V Displays the version number of DOS.

1.2.10 REN

$D Displays the date.

This is an internal command that renames a file on the disk. (The old and the
new names have to be specified). Wildcard character can also be used, either
in the old or the new name. If a file in the directory already exists with the new
file name, a Duplicate file name message is displayed and the operation is
terminated.

$T Displays the time.


C:\>PROMPT $P$D$G<RETURN>
Anything typed after Prompt without $ sign will be displayed as the
prompt.So, C:\> Prompt Abinash $G will display following prompt:

Syntax: REN oldfilename newfilename

or

RENAME oldfilename newfilename


Abinash>
C:\>REN LETTER.TXT LETTER.DOC <RETURN>
1.2.9

COPY
Try out the following command: C:\>REN LETTER.TXT LETTER.DOC

This command copies files between disk drives and/or devices, either keeping
the same file name or changing it. COPY can concatenate two or more files into
another file or append one or more files to another file.
Syntax: COPY sourcefilename targetfilename
It will make a duplicate copy of the sourcefile under the new targetfile name.
C:\>COPY ABC XYZ <RETURN>
? St. Xavier college

An Introduction to MS DOS
1.2.11 Removing a Directory

1.3

RD removes subdirectories from the disk. Only empty directories can be


removed; the current directory cannot be deleted nor can the root directory in
the disk.

In the DOS there are few commands which have the extension as .COM or
.EXE. These commands are called as external commands as they have to be
available on the disk if required to be executed.

Syntax:

In case the command is an external one, i.e., not present in the RAM, then the
CPU checks up the disk from where the system has been booted and picks up
for its execution. Thereafter, it executes the command and then clears that
command from the RAM.

RD dirname or RD path/dirname
Before executing the RD command certain things are necessary to be taken
care of :
Rule 1.

Always make sure that the directory to be deleted is empty, i.e., no


files and no subdirectories should be present in the directory.

Rule 2.

Always remove the child directory from the parent directory. Never try
removing a directory without exiting it. However, the child directory
can be removed without giving the path from the parent directory.
CD.. always takes the user to the immediate parent.

External Commands

Some of the external Commands for File Operations


1.3.1

MORE

Normally whenever a big file is typed, the contents scroll off the screen until the
end of the file is reached. The MORE command displays one screenful of
information. If the size of the file is more than a screen then the screen pauses
at the end of a page displaying the message More--.
Syntax: MORE filename
Less than symbol is used to redirect the programs input. MORE is going to
take the file contents as input and then display them one screen at a time. To
abort any such operation midway press CTRL key and C key simultaneously.
C:\>MORE <README.TXT <RETURN>
It will display the contents of readme.txt file page by page.
1.3.2

PIPE

This is used to pass on the output of one command as input to the other
command and is represented as !.
Syntax: command1 ? command2
C:\>DIR ? MORE

An Introduction to MS DOS
It will redirect the output of DIR command to MORE command which will
display it page by page. If there is some more information then the message
appears more- displayed at the end of every page.
1.3.3

On screen, it will look like


C:\YACH>PRINT P

MOVE

C:\YACH\P is currently being printed

This command moves one or more files to another directory. It is also used for
renaming a directory.

C:\YACH>
C:\YACH>PRINT P DOS_1

Syntax: MOVE SOURCEFILENAME TARGETFILENAME


C:\YACH\P is currently being printed
It will move the source file under a new name, i.e., target file name
C:\YACH\DOS_1 is in queue
C:\>MOVE ABC XYZ <RETURN>
To display the contents of the print queue type PRINT without parameters.
Moves ABC to XYZ in the root directory itself. After execution of this command
the screen will look like:
C:\MOVE ABC XYZ <RETURN>
ABC => XYZ

1.3.5

XCOPY

Copies files (except hidden and system files) and trees directly. This command
is most helpful when a copy of a full directory along with its subdirectories is
required, without going through the process to create subdirectories and then
copying their files etc.

OR
Syntax: XCOPY sourcefile ? sourcedir sourcefile ? sourcedir [/option 1]
MOVE PATH\SOURCEFILENAME(s) PATH
!

indicates or

It will move the source file from its original path to the new directory under a
new name, if a new name is mentioned.

source Specifies the file(s) to copy

1.3.4

destination

PRINT

Prints a list of files on the printer while the computer performs other tasks. It
prints a text file while other MS-DOS commands are being executed.

Specifies the location and/or name of new files

OPTIONS:
/P

Prompts the user before creating each destination file.

/S

Copies directories and subdirectories except empty ones.

/W

Prompts the user to press a key before copying.

Syntax:
PRINT filename1 [filename2]
C:\YACH>PRINT P <RETURN>
? St. Xavier college

An Introduction to MS DOS
To copy file PAIR to another file RARE in the same directory the following
command is given

The FAT is simply a table of numbers with one place in


the table for each cluster on the disk. The entries in each
FAT area indicates whether the corresponding cluster is
in use or not. It also holds a pointer to the next cluster
where the file is continued (in case the file does not
completely fit into one cluster).

C:\>XCOPY PAIR RARE <RETURN>


1.3.6

TREE

This command displays the files, directories and their subdirectories in a


pictorial manner.
Syntax:: TREE C:\>TREE <RETURN>
the root.
1.3.7

ROOT Directory

It will show a tree like hierarchy from

The root directory area records details about the files that
are stored on the disk. For each file stored, there is a
directory entry that records the file name, size, date and
the time corresponding to when the file was last
modified.
The root directory also holds the starting cluster number
for the file. The size of the root directory is fixed for each
type of disk and this size determines the number of
entries it can hold.

FORMAT

The DOS FORMAT command prepares a disk for use. It divides a disk into two
areas.
System area

DOS stores information which is of use to itself

Syntax: FORMAT <drive>:

User area

Stores programs or data files

1.3.8

System area consists of the boot area (which is the first sector on the disk), the
file allocation table and the root directory.
Boot Area

The boot area is the first sector on the disk which


contains the boot record. The boot record holds a short
program which is used for booting.

CHKDSK

Checks the directory and the file allocation table (FAT) of the disk and reports
about the disk and memory status. CHKDSK can also repair errors in the
directories.
Syntax:
CHKDSK drive: /F

File Allocation

The next part of the system area is the file allocation


table (FAT) area which records the status of the sectors
in the user area, i.e., whether the various sectors hold
any data or not.
DOS stores files on the disk in one or more clusters. A
cluster is a collection of sectors. When the user wants to
store a program or a data file, DOS assigns one or more
clusters to the file.

An Introduction to MS DOS
1.4

Main features of latest version of DOS (ver 6.22)

Exercise

a)

Improved Input / Output speed

1.

Copy all files with an extension .EXE or .COM from you DOS floppy (from
hard disk if your computer has one) onto the floppy you have formatted.

b)

Improved device interfaces


2.

c)

Facility to simulate earlier versions

Delete all files with secondary name as .BAK and primary name less than
6 characters. Execute this command, under you instructors supervision.

d)

Facility to load a program above lower memory

3.

COPY the file SYS.COM from C disk onto the A disk.

e)

Doubling the storage space

4.

Change the DOS prompt, so as to display the directory name with the
prompt.\

f)

A DEL TREE command that deletes a directory along with all its files
and subdirectories

5.

Write a batch file called DELFILE.BAT to do the following:

g)

MOVE command that moves one or more files from one directory or
drive to another

h)

Start-up commands could be bypassed after switching on the machine.


More than one CONFIG.SYS can also be defined

i)

MS BACKUP, a totally menu oriented program, which makes data


backup and restoration simpler.

? St. Xavier college

6.

a.

delete all the files of the directory specified as first argument

b.

delete all files the sub-directory.

Write a batch file called CREAT.BAT, which should do the following:


a.

include a comment You are executing a Batch file, for formatting


disks.

b.

check for the file FORMAT.COM in C disk, if found display the


message Insert New Disk in Drive A, and Press any Key.

c.

If the file FORMAT.COM is not found, display an appropriate error


message, and copy it from DOS sub-directory of Boot Floppy onto C
drive.

d.

Once floppy is inserted, format it.

e.

At the end of formatting, display the message Formatting is Over.

An Introduction to MS DOS

LAB BOOK FOR MS DOS


1.0 Introduction
2.0 Organisation
2.2 Procedure
2.3 Lab Session Objectives

.3.0 Lab Session I


3.1 Objectives

1.0 INTRODUCTION
This work book is intended for students enrolled in B. Sc.
Computer Science of SXC. This lab work book deals with use of
various commands and features available in MS-DOS for
computer operation, file and disk management, and batch file
processing.

2.0 ORGANISATION
This lab work book introduces you to, various components of a
computer and their uses, operating system and its importance,
and various commands of DOS, various facilities available in DOS
for file and disk management, printing and displaying disk files.

4.0 Lab Session II

2.1 Procedure

4.1 Objectives

To make best use of the practical, you are advised to take the
following steps:
1.

schedule your lab session

2.

read this book let carefully before attending the lab session

3.

workout the difficult questions beforehand

4.

attend the practical session, where you have to follow the


procedure outlined for each of the lab session in this work
book.

An Introduction to MS DOS

5.

repeat the topic, which you didn't understand thoroughly.


To make best out of it and work efficiently you should
know the DOS commands, and be able to enter them
correctly.

3.1 Objectives
At end of this session, you will be able to do the following:
?? identify various parts of a computer

6.
in case of any difficulties consult the lab supervisor for
clarification.
7.
workout
possible
answers
(commands),
necessary, before you go to Lab for practical session.

?? distinguish between various types of softwares


?? name a file, and use DOS command to rename a file
.

wherever

?? create, remove and change directories

2.3 Lab Session Objectives


At the end of the two lab sessions, you should be able to:
?? explain various parts of a computer and their uses
?? use various file and disk management commands of
DOS
?? write programme using DOS commands

?? use DOS commands for file management.

EXERCISE 1
This exercise, needs a computer in front of you to answer the
following questions by making observations. As soon as you enter
into your Lab room, request your instructor to take you to a
computer. Some of the questions may require certain amount of
discussion among your fellow students and instructor. Try your
best to answer all the questions.
1.

What is the type of your computer ?

2.

Does your computer have a built-in Hard Disk?

3.

Locate the switches to control the display on the monitor.

4.
How many floppy drives does your computer have? Identify
the drives.

? St. Xavier college

An Introduction to MS DOS

5.
What is the size and capacity of floppy drive used by your
computer ?

13.
What is the system reset keys,or combination of keys for
your computer?

6.
Does your computer have a hard disk? If yes, what is the
storage capacity?

14.
Does your computer have a mouse? If yes, identify the
connecting port and type of the mouse you are using.

7.
Identify the CPU of your computer. What is the processing
speed of your computer?

15.

8.

What type of CPU is your computer using?

9.

Check whether a printer is connected to your computer?

10.
What type of printer is connected to your computer? What
is the printing speed?
11.

What is the memory capacity of your computer?

12.

List the softwares and their types,availablefor use on your


computer.

Software Types

How many ports does your computer have? List the names
and their types.

EXERCISE II
So far this booklet has introduced you to the micro computer, its
various part and their uses. In this exercise you are expected to
do the following.
?? obtain the floppy disk, use it and put it back in the
correct location after you finish your work.
?? start the system from a switched-off state and shut it
down when finished.
Proceed through the following steps one at a time :
1.
Obtain the Disk Operating System disk (normally known as
Boot Disk).

S1.NO.

1.
2.
3.
4.
5.

2.

Go to the computer assigned to you, insert the disk


properly into the disk drive A and close the latch. If there
is only one drive in your computer, it is the drive A. If there
are two drives, to identify the drive A, take the help of
instructor.

An Introduction to MS DOS

3.

Switch on the computer and the monitor. The drive light will
be on and the Operating System will be copied from
the inserted disk into the computer's memory.

4.

Copy all files with an extension .EXE or .COM from your


DOS floppy (from hard disk if your computer has one) onto
the floppy you have formatted.

4.

Wait for the Date message to appear on the monitor. The


computer will show the date on the screen and give you the
opportunity to change it.

5.

Change the name of the file DISKCOPY.COM to DSK.EXE.

5.

6.

6.

Type-in the date of the day in the form Month-Day-Year


and then press the Enter key. If wrong date is entered, an
error message will be displayed. Re-enter the date
correctly.
The computer will show the current time, in the format
Hour-Minute-Second. If you want to change the time, go
ahead and change it, otherwise press Enter.
Once you complete this, the Operating System Prompt 'A>'
will appear on the screen, and now computer is ready for
your use.

EXERCISE III
1.

Display the version of MS-DOS in use.

2.
Using DATE and TIME commands, change the system
date and time.
3.

Insert a blank disk in the drive and give appropriate


command to format the disk- Make sure that you are using
blank floppy and your instructor is present, when you enter
and execute this command.

? St. Xavier college

6.
Copy the file DSK.EXE from drive A into DISKCOPY.COM
onto A itself.
7.

Issue command to display the result.

8.
Issue command to display all files with extension .EXE. one
screen full at a time.
9.

Clear the Screen.

10.
Change the, name of all files with extension.COM on disk A
as.BAK files.
11.

Delete all files with secondary name as .BAK and primary


name
less
than
6
characters.
Execute
this
command, under your instructor's supervision.

12.

List all the files to display the changes.

13.

COPY the file SYS.COM from C disk onto the A disk.

14.
List the contents of the A disk and simultaneously take a
printout.
15.
Change the DOS prompt, so as to display the directory
name with the prompt.

An Introduction to MS DOS

16.

Switch off the computer and make sure that all the
connected devices such as monitor, printer etc. are
switched off.

3.
Set the path on disk A so as to include all directories and
sub-directories.

LAB SESSION II

4.1 Objectives
This session deals with advance commands sequence of MSDOS. At the end of this session, you shall be able to:
?? understand the use of advance commands of DOS
?? write batch files in DOS, using various DOS
commands

EXERCISE I
1.

2.
Copy all the files with an extension of. COM from C disk
onto the SXCMAIN sub-directory of A.

4.
Copy all files with extension .EXE from disk C to the subdirectory EXE on disk A.
5.

6.
Copy all files with extension .BAT from sub-directory SXC
to sub-directory BAT on disk A.
7.

9.

Display all the directory and sub-directory structures under


ROOT directory in Disk A. Repeat the same for Disk C.

10.

Remove all sub-directories under the ROOT directory on


the disk A.

ROOT

SXCMAIN

EXERCISE II
1.

EXE

COM

BAT

Clear the screen.

8.
Go to the directory BAT and display the contents of the file
AUTOEXEC.BAT.

Create the following directory structure on disk A

SXC

Go to the sub-directory EXE and display the files.

Insert a floppy in drive A and charge to drive A, if you are


using a computer with a Hard-disk check for any error.

2.
Create a file STUDENT.DOC containing 15 names of any
of your friends, using EDLIN.

An Introduction to MS DOS

3.
In the file STUDENT.DOC delete the names at the 6th. and
8th. position.

7.
far.

Take the printout of all the batch files you have written so

4.

8.

Switch off the computer and make sure that all the
connected devices such as monitor, printer etc. are
switched off.

Write a batch file called DELFILE.BAT to do the following:

a.
argument

delete all the files of the directory specified as first

b.
delete all files from the sub-directory EXE (consider
the directory structure given in Exercise 1).
5.

Write a batch file DELCHK.BAT, which will delete all files


from the directory, specified as the first argument and
having extension as second argument, in drive A.

5.

Write a batch file called CREAT.BAT, which should do the


following:

a.
include a comment 'You are executing a Batch file,
for formatting disks'
b.

check for the file FORMAT.COM in C disk, if found


display the message 'Insert New Disk in Drive A,
and Press any Key'.

c.

if the file FORMAT.COM is not found, display an


appropriate error message, and copy it from DOS
sub-directory of Boot Floppy onto C drive.

d.

Once floppy is inserted, format it.

e.
At the end of formatting, display the message
'Formatting is Over'.

? St. Xavier college

THE END

You might also like