University of Strathclyde Computer Centre
Curran Building
100
Cathedral Street
Glasgow
These course notes are intended to be used as an introduction to MS-DOS version 5.0 although much of the material is also relevant to version 6 and its revisions.
They are not intended to be a sole source of reference for anyone learning or using DOS; reference will need to be made to the on-line Help utility and/or appropriate manuals as necessary.
After a number of introductory pages and background material the rest of the course is largely 'hands-on'.
DOS is an operating system used on PCs (Personal Computers).
The Operating System is software which controls the hardware of the machine
(the disks, keyboard, mouse, monitor, etc.) and allows the user's programs and
packages to be run on the machine. It is the interface between your word
processor or spreadsheet or other program and the electrical signals which the
CPU (the Central Processing Unit or Processor), the heart of the computer,
understands.
Sometimes DOS is stored on a Diskette, but normally it is stored on the Hard
Disk, and it is easier to use when it is.
As with all programs (or software), different parts of DOS are brought into
RAM and executed as they are needed.
It might be helpful to discuss some of the above terms before further
discussing DOS.
To actually perform or execute the instructions that make up computer
programs they have to be brought into the Main Memory or RAM (Random Access
Memory) of the computer. This an electronic medium and so when the machine is
switched off and the power is lost the contents of memory are lost. Hence RAM is
often characterised as Temporary Storage.
In order to preserve the instructions in a computer program (as well as
computer data in general) a Permanent Storage medium is needed. This is provided
by Disks and Tapes (Magnetic Media). Programs and data stored on disk or tape
are not lost when the computer is switched off.
Once the computer has been switched on or 'powered up', programs and data are
moved from permanent storage (usually the Hard or Fixed disk inside the computer
but possibly a floppy disk or a tape) to Main Memory / RAM as required. When
they need to be saved permanently they are written from Memory / RAM back to
disk (or tape).
The capacity of any computer storage medium is usually measured in Bytes,
Kilobytes or Megabytes.
A Byte can store 1 character. How do Disks and Tapes compare -
Cost - based on the same storage capacity, a Tape/Cassette is much cheaper
than a Hard Disk. e.g. 520 MB storage - tape c. £12-13, Disk c. £170. Therefore, because of its speed compared to tape, disk is the permanent
storage medium which forms part of the computer system; whereas because of its
cheapness and portability tape may be used for large scale backup/archiving
(e.g. Hard Disk backup).
How does RAM compare -
Speed - much faster than disk (or tape).
Cost - more expensive than disk or tape (e.g. £25 - £30 for 1MB).
Storage Capacity - less than hard disk or tape.
More about Disks -
There are two types: the Hard Disk (referenced above) which is fixed
inside the computer (hence it is also known as the Fixed disk) and has a
large capacity, and the Diskette or Floppy Disk (discussed in more detail below)
which has a smaller capacity but is portable.
The Disk Operating System (DOS) is a computer program which is loaded
from disk into the main memory of an IBM compatible PC, when the machine starts
up, to control its operations. 'IBM compatible PC' is a generic term used to
refer to the majority of PCs, made by a number of manufacturers, e.g., Viglen,
DEC, Compaq, Dell, IBM etc., which all run DOS. This term has come to mean, in
effect, all PCs other than Apple Macintosh personal computers, (commonly
referred to as Macs, rather than PCs) and Mac clones.
Over recent years three companies have produced DOS (or a brand of it);
Microsoft, IBM and Novell. The latter has now dropped out of the market and
IBM's share is marginal. Microsoft DOS i.e. MS-DOS is now the de facto standard.
Here is a summary of the development of Microsoft DOS (MS-DOS)
DOS is composed of a number of files. You can choose to keep all of its
components available on disk so that you can use all the facilities it offers
(this is the norm if space is not a constraint). Alternatively you may choose to
have a minimal setup in which case not all of its features will be available.
However at a minimum there are three system files which you must have.
These are IO.SYS, MSDOS.SYS and COMMAND.COM.
The disk which your computer uses to load and run DOS must contain these
files and is called the System, or Startup, or Boot, disk.
COMMAND.COM, the command processor (or shell) is the part of DOS that
executes (or processes) the commands we will be looking at. These commands are
either internal to the command processor (i.e. part of it), or
external to it.
You must not create a file with the same name as an Internal Command.
Examples of such commands are DIR, DEL and COPY, which are part of the
COMMAND.COM program. You will find that the names of these commands cannot be
seen when you list the files on your disk.
Each External Command is a separate executable program. When the user enters
the name of an external command DOS reads the appropriate program file into
memory and control of the computer system is passed to it; when the command
terminates the command processor regains control of the system. External
Commands e.g. XCOPY, can be seen when you list your files.
All IBM compatible PCs have a program which is not part of DOS but interacts
with it to provide peripheral device support. This software is called the BIOS
(Basic Input/Output System) and it contains the basic instructions for
controlling such things as the disk drives (see below), keyboard and
serial/parallel ports while the machine is running. It also contains
instructions for testing various parts of the computer (e.g. memory, floppy disk
drives and the various interfaces) which are executed when the computer is
starting or 'powering' up. This POST (Power On Self-Test) routine will display a
message if there are any problems.
Once the tests are all passed the operating system is loaded from disk and
the machine is ready for use. This BIOS program is classed as firmware and
stored in ROM (Read Only Memory). It is supplied by a number of companies, for
example Phoenix, AMI, Quadtel.
Disk drives are those parts of the computer hardware which hold the disks and
perform the writing and reading of data to and from disk. Within a DOS command
line they are referenced by a letter plus a colon. The hard disk drive,
containing the large capacity, fast access, fixed disk, is normally referred to
as C:(i.e. the C drive), the floppy drive is A: and if there is a
second floppy drive it is B:
When your PC is running a Prompt appears at the left of the screen indicating
that the computer is ready for you to type in commands. This System, or
DOS, or Command, Prompt includes a letter to indicate the
current or default drive. That is the disk drive DOS will use when
executing the command if no other is specified in the command line. For example
A>and C> are both common prompts indicating the floppy and
hard drives respectively.
When the floppy disk drive writes data to a floppy disk it places it in
concentric circles called tracks. A floppy disk contains either 40 or 80
tracks each of which is divided into small sections called sectors, each
sector containing 512 bytes. The disk drive contains a read/write head which
moves from one track to the next as the disk rotates either finding data to be
read, or locating free space to which it can write (depending on whether DOS has
requested a read or write operation).
The following table shows the types of disk drives (for floppy disks /
diskettes) a personal computer can have
5.25 " Single-sided Double-Density 160KB/180KB 40 Tracks 8/9 Sectors * indicates the 2 most common types of floppy.
On a floppy disk it is possible to physically enable or disable writing to
the disk. This allows you to prevent accidental writing to the disk or
unintentional formatting of the disk.
To disable writing to a 5.25" floppy disk a notch called the write protect
notch should be covered by non transparent tape on both side of the disk.
If you look at the back of a 3.5" disk you will see there is a write protect
window with a plastic sliding tab in the lower right corner. Sliding the tab
down to open the window Write Protects the disk.
Always ensure that you insert your diskette in the correct way, namely - the
label side should be up, and the edge containing the silver slider should go
into the machine first.
Never force the disk into the disk drive. If it does not slide in
easily then there is something wrong.
A new floppy disk must be formatted before DOS can read from and write to it.
DOS provides the FORMAT command to allow the user to format disks. Information
on how to use the FORMAT command will be given later. When you format a disk DOS
reserves a small part of it for its tracking system. This consists of the File
Allocation Table and Root Directory which allow DOS to store and locate files on
the disk (see next section). When formatting a disk DOS also marks defective
sectors so that it will not store information there.
Formatting a disk creates the following data structures on it -
The Root Directory - This contains the name, attributes (see later),
time and date of last modification and size of each file on the disk. It also
identifies the disk location of the first cluster of each file.
A Cluster, or Allocation Unit, is a group of consecutive sectors (in the case
of a floppy disk 2 sectors). It is the smallest unit of disk space that can be
allocated to a file.
Files are divided into clusters because there is not always a single piece of
free disk space big enough to accommodate a particular file. Therefore it has to
be broken up and distributed over different parts of the disk where there is
free space i.e. where there are free clusters. As a result of this files, and
disks themselves, are often referred to as being fragmented, a characteristic
which slows down the processes of writing to and reading from the disk.
The File Allocation Table (FAT 1) - After the
first cluster of a file has been located the FAT is used to locate subsequent
clusters. It contains the address of each subsequent cluster in the allocation
chain.
FAT 2 - A copy of FAT 1 which DOS uses to verify the integrity
of the filing system.
The Boot Sector - When a disk is formatted as a boot (or system) disk
a small program called the Bootstrap Loader is placed in the Boot Sector, the
first sector on the disk. This program loads the operating system from disk into
memory after the BIOS has successfully completed its POST.
It is possible to store hundreds of files on a disk and it can a tedious task
trying to find a particular one you are looking for if they are not categorised
in any way. Therefore DOS allows you to group related files together in
directories. The main directory on a disk is called the ROOT directory, which is
represented by \ (a back slash) and it is created by DOS when formatting
the disk. You can create directories in the ROOT directory and within each other
and they can each contain a number of files. The directory structure is often
thought of as an inverted tree structure with the root at the top branching down
into lower layer directories and subdirectories. For example -
Data and programs are stored on disks in files. DOS itself consists of a
number of files working together to provide the operating system. Other computer
programs such as word processors and spreadsheets are also constructed from a
number of files. When you save work produced with one of these packages (e.g. a
document from a word processor) you save it to a file. When naming a file it is
always a good idea to use a name which indicates the contents of the file.
Likewise when naming a directory, which is a special type of file, you should
use a name which helps to identify the files it contains.
DOS has certain rules governing the naming of files -
Filenames are not case sensitive. File extensions can have special meaning to DOS or other programs and are
often used to indicate the type of a file.
e.g. The .BAT extensions signifies a Batch files. A batch file contains a
batch or group of DOS commands which are performed one after the other when the
file is executed (or run). You execute a batch file by typing its name,
without the .BAT extension, at the DOS prompt. AUTOEXEC.BAT is a
batch file which is often found on the boot disk. DOS accesses this file in the
last stage of booting (i.e. starting) your system and executes each command it
contains.
Here are some commonly used extensions and the type of file they indicate
BAK Backup file
These follow the same rules as ordinary file names except that extensions are
not allowed in version 5 and earlier versions of MS-DOS. Remember that a
directory is just a special kind of file - i.e. a file which can contain other
files.
When a list of files is displayed on screen the label <DIR>is
appended to those names which in fact indicate directories.
Commands are entered at the DOS prompt, e.g. A> or C> or F> which,
as previously noted, informs you of the default or current drive. The exact form
of the initial prompt depends on what type of disk booted the computer and
whether the startup file AUTOEXEC.BAT, has customised the prompt. A letter plus
> (greater than sign) is the default prompt.
For example A> indicates that the computer was booted with a floppy
disk, whereas C> means the computer was booted from a hard disk and
F> indicates that the computer may have been booted from a networked
machine.
A command line can contain just a command itself i.e. a single word, but most
commands can take parameters (or arguments) indicating files or directories on
which the command is to operate. Parameters are separated from commands by one
or more spaces.
You finish a command line by typing the Return or Enter key (<return>
or <enter), and this signals the computer that you have finished typing in
your command and that it should carry it out.
An example of an acceptable DOS command is
CLS
This is the clear the screen command. All existing text on the screen will be
cleared and the prompt placed at the top left hand corner of the screen ready
for the next command.
Unless you specify in a command line a particular (Disk) Drive to use, DOS
will attempt to
execute the command on the current, or default, drive. i.e. It will look for
the directories and files referenced in the command line on the disk in the
drive indicated by the screen prompt, e.g.
A> (diskette)
C> (hard disk)
Suppose the current/default drive is C and you are going to perform a lot of
operations on your diskette in drive A. To avoid typing A: in your
command line every time you execute a command you can change the default drive.
To change the default drive from C to A type A: <return>
The prompt will now include A instead of C
To make C the default drive again type C: <return>
Very usefully DOS buffers (i.e. remembers) the last command you typed
in. If you want to run that command again simply press F3 and then
<return> to run it. Alternatively you can press the F1 or F3 Recalls the last command the user entered
F1 or
This is a simplified illustration of the basic format of DOS command lines.
The command-name is of course essential but, depending on what that command is,
the other elements of the command line may or may not be present. Moreover some
command lines will contain additional elements not included in this example. The
components of the command line are explained below.
(Note - it is not necessary to understand this abstract illustration of the
DOS command line as examples are given for each of the commands discussed in
these notes. Indeed you might prefer simply to look at the actual commands.)
The components of the command line are -
command-name = a DOS command
DRIVE: = a letter plus colon indicating the relevant disk (drive) for the
following path and directory/file.
Usually PATH = a hierarchy of directories, each preceded by a \ (back slash),
from the Root directory of the disk (represented by the first \) to the
directory containing the directory or file on which the command is to be
executed.
e.g. \faculty\dep_ment\admin
Note - If you are already in the directory which contains the file or
directory to be manipulated then the drive and path do not need to be specified.
DIRECTORY = the directory on which the command is to be executed.
or FILE = the file on which the command is to be executed.
If a path has been specified then a \ must be placed before this item
to separate it from the path.
e.g. \faculty\dep_ment\admin\minutes.doc
SWITCHES = ways of modifying the operation of the command.
Throughout the notes, a number of possible switches are listed for each
command, however often no switches will be required.
Switches can usually be combined - i.e. you can have more than one switch for
a particular command.
Note - Very often elements of this syntax can be omitted, in which
case DOS will use defaults. e.g. If no DRIVE: is specified in the command line,
then DOS attempts to execute the command on the current drive (i.e. that
indicated by the screen prompt). If no PATH is specified, then DOS attempts to
execute the command in the current directory (i.e. the directory in which you
are currently working).
An example of how the commands are presented in the notes is now given using
the DIR command. The command name and a brief note of what it does is given in
the heading, followed by a little more explanation, its syntax and some
examples.
DIR - Lists files and subdirectories
This command lists information about files and subdirectories and the amount
of free disk space.
Where SWITCHES are
P - page through the screens
W - produce a wide listing
Example: List the contents of the root directory of the hard disk
DIR C:\
If what you type on the command line is not a valid DOS command, e.g. if you
type in rubbish, or misspell a command, you will probably get the following
response.
Bad command or file name
Likewise if you type in the name of a command correctly but add too many
parameters, or an invalid switch to it, DOS will respond with an appropriate
error message.
Version 5 of DOS came with a command which helps the user establish what each
DOS command can do. (DOS 6 provides a similar, more graphical facility.)
Command Syntax: HELP command-name
Example 1: Display a brief description of what all the DOS commands do.
HELP
Example 2: Display more information about a particular command e.g. DIR
HELP DIR
or DIR / ?
This will provide the syntax of the command in a form similar to that used in
the notes.
A disk must be formatted for a particular operating system before it can be
read from or written to by that operating system. DOS formatting creates a new
root directory and file allocation table on the disk, it also destroys
anything already on the disk. Therefore do not format a disk until you are sure
there is nothing on the disk that you want to preserve.
You will not normally need to format a disk a second time (i.e. after your
initial format of a blank disk). If you do reformat a disk, all existing data on
it will be destroyed.
Command Syntax: FORMAT DRIVE /SWITCHES
Where SWITCHES are
S - create a DOS system/boot disk - i.e. Format the disk and automatically
install the DOS system files (IO.SYS, MSDOS.SYS and COMMAND.COM) on it
F:x - where x is the floppy disk size i.e. one of 160, 180, 320, 360, 720,
1.2, 1.44, 2.88
The F switch is most commonly needed if formatting a DD (Double Density) disk
in a HD (High Density) drive. Specifically, formatting a 3.5" 720 KB disk in a
3.5" 1.44 MB drive, e.g.
FORMAT A: /F:720
If you use the FORMAT command without switches on a 3.5" disk in a HD (1.44
MB) drive, DOS will attempt to format that disk to 1.44 MB even if it is a DD
disk. This will result in a disk which is unreadable on DD drive machines. By
using the F:720 switch the disk will be readable on both types of
machine.
Other SWITCHES
T:t - where t is the number of tracks per disk side Together these provide an alternative to the F:x switch for specifying the
size of the disk being formatted, e.g.
FORMAT A: /T:80 /N:9
can be used to perform the same format as using F:720 above.
Remember - Examples using the FORMAT command -
Example 1: Format a HD floppy disk in a HD drive
FORMAT A:
Example 2: Format a disk as a DOS System disk
FORMAT A: /S
Example 3: Format a 3.5" DD 720 KB disk in a 3.5" HD 1.44 MB drive
FORMAT A: /F:720
/T:80 /N:9
If you already have a formatted disk which you want to be able to use as a
System (or Boot) disk, you can install the 3 essential system files to it using
this command.
Example: Make the diskette in drive A a system disk by installing the system
files on the hard disk to it
SYS C: A:
Note - that to make a disk a system disk you must either use the /S switch
with the FORMAT command, or use the SYS command. Simply copying the system from
one disk to another does not create a system disk.
The UNFORMAT command is a limited safe guard introduced in DOS 5 to recover
data from a disk which have been lost as a result of performing a FORMAT.
You should not really need to use this command if you are careful. It is good
practice always to use the DIR command on a disk to see if it has already
been used before trying to format it. If DIR displays information about files
and directories or disk space then the disk is already DOS formatted. (However
this simple test does not let you know if the disk has already been formatted
but for a Macintosh computer.)
Note - Unformatting a disk only works if the UNFORMAT command
is used before putting any new files on it.
Command Syntax: UNFORMAT DRIVE: /SWITCH
Where SWITCH is
TEST - display only, non committal of data. This shows how UNFORMAT would
attempt to recreate the information on the disk, but does not actually unformat
the disk and do so.
Example 1: Test to see how a disk would be recovered from a format
UNFORMAT A: /TEST
Example 2: Actually recover from use of the FORMAT command
UNFORMAT A:
DISKCOPY makes an exact copy of one floppy disk (the source disk) on another
(the destination or target disk). The original contents of the
destination disk are destroyed. If the destination disk is unformatted DISKCOPY
will format it. The disks should be of the same type (e.g. two 1.44 MB HD
disks), however if the destination disk is of a different type from the source
disk DISKCOPY will try to format it to match the source diskette but this may
not be possible.
Note - The XCOPY command (see later) is the best command to use when
copying files between different types of disk (e.g. a 720 KB DD disk and a 1.44
MB HD disk), or when you want to preserves the original contents of the
destination disk.
Example 1: Make a copy of a diskette using two identical drives. (The copy
will be from the diskette in drive A to the diskette in drive B)
DISKCOPY A: B:
If you only have one floppy disk drive, which is normal, you can still make
an exact copy of a diskette. You specify drive A twice in the command line,
start the copy with the source diskette in that drive, and swap it with the
target diskette as directed during the copying operation until the copy is
complete.
Example 2: Make a copy of a diskette using one drive
DISKCOPY A: A:
The MD or MKDIR command is used to create subdirectories in the root
directory or other subdirectories.
Command Syntax: MD DRIVE:\PATH\DIRECTORY
Example 1: Create a subdirectory named DOCS in the root directory of C
MD C:\DOCS
Example 2: Create a subdirectory of the DOCS subdirectory called WORK
MD C:\DOCS\WORK
Example 3: Create a subdirectory of WORK called TEMP
MD C:\DOCS\WORK\TEMP
Example 4: If you were already in the WORK directory (see next section re
changing directory) the following would be sufficient to create the TEMP
subdirectory
MD TEMP
The CD or CHDIR command is used to move from one directory to another; or to
show the current directory path (i.e. the hierarchy of directories from
the root directory to the one you are currently working in). The directory you
are currently in is known as the current or default directory.
When you move to another directory it becomes the current directory. Once your
system has booted your initial current directory will normally be the root.
DOS uses the following 'special' characters to reference particular
directories within the directory structure and these can also be used with the
CD command.
\ - the Root Directory Example 1: Move to the subdirectory TEMP (assuming it exists)
CD C:\DOCS\WORK\TEMP
Example 2: Display the path to the current directory (i.e. Current Directory
Path)
CD
Example 3: Move to the parent directory of the currentdirectory
CD ..
Example 4: Move back to the subdirectory TEMP (this example assumes you are
currently in subdirectory WORK; use example 2 to check before moving)
CD TEMP
Example 5: Move to the root directory. (This will make the root the
current directory)
CD \
It is useful if you can see immediately from the command/screen prompt what
directory you are currently working in (i.e. the current directory) and the path
to that directory. The PROMPT command enables you to do this.
To make the command prompt show the path to the current directory, and not
just the letter representing the default disk drive, type
PROMPT $P$G
Your AUTOEXEC.BAT file may already include this command line, if not it can
be edited to do so. In this way a useful prompt will be set up every time you
start a new session on your computer.
After typing PROMPT $P$G as indicated, move up and down through the directory
structure to see how the prompt changes.
The TREE command enables the user to obtain a graphical view of the structure
of directories and subdirectories on a disk.
Command Syntax: TREE DRIVE:\PATH /SWITCH
Where SWITCH is
F - Display the names of files in each directory
Example 1: Display the structure of the DOCS directory
TREE C:\DOCS
Example 2: Display the directory structure and files of C
TREE C: /F
RMDIR or RD is used to remove a directory. This command will only work if the
directory concerned is empty.
Command Syntax: RD DRIVE:\PATH\DIRECTORY
Example: Remove the empty subdirectory of C:\DOCS\WORK called TEMP
RD C:\DOCS\WORK\TEMP
DOS 6 introduced the DELTREE command which allows you to delete directories
whether or not they are empty. (i.e. it allows you to delete all the files and
subdirectories in a directory plus the directory itself with a single command.)
This command should be used with care.
In DOS 5 there is no single command that allows you to rename a directory.
You have to use a combination of the MD, XCOPY, DEL and RD commands. This has
been addressed in DOS 6 with the introduction of the MOVE command which can be
used to rename directories or move files. (For DOS 5 renaming directories is
simpler with DOSSHELL - see later.)
For many DOS commands (viz. external commands) there is a program file which
has to be executed in order for the command to work. In the examples so far we
have assumed that this is not a problem but in fact DOS has to know where on
disk, i.e. in which directory, the corresponding program file is. If it cannot
find the file then the command will fail.
By default DOS will only look in the current directory for this
program/executable file. If it is not there then DOS has to be know the path
(i.e. the hierarchy of directories from the root) to it.
This can be achieved by prepending the relevant path to the command name
whenever composing a command line. However it would be better if DOS could
simply be told in which directories to look for program files whenever a command
name was entered. This can be achieved by using the PATH command. It
enables you to specify the path to directories DOS should search, after the
current directory for the program file for a command. Once this command has been
issued DOS will remember these directories until the command is used again
either to clear the search path or set a new search path, or until the machine
is switched off.
Command Syntax: PATH DRIVE:\PATH
You can have multiple occurrences of DRIVE:\PATH each separated by ;
Example 1: Set a path to \ (the root directory), and the DOS directory
PATH C:\;C:\DOS
This instructs DOS that after it has searched the current directory for a
program file, it should then search the root directory of C: and then the DOS
subdirectory of the root.
This should be a minimum search path when using DOS because most of the DOS
program files are usually kept in the DOS subdirectory and the root directory.
It allows the DOS commands to be used, as in these notes, without prepending
them with a path.
A search path containing at least these elements is usually set up in the
AUTOEXEC.BAT.
Example 2: Add the directory MEMOS on the diskette to the search path
PATH C:\;C:\DOS;A:\MEMOS
You can also use the PATH command to see what directories are currently in
the search path, and to clear it.
Example 3: Display the current search path
PATH
Example 4: Clear the search path
PATH ;
This command lists the names of files and directories in the current
directory, or one specified in the command line. It can also provide additional
information such as the amount of free space on the disk, the dates directories
were created, and the dates files were last modified and there sizes.
It is also possible use DIR to search for specific files.
Where SWITCHES are
P - page through the listing one screen at a time Example 1: List the contents of the root directory of the floppy disk
DIR A:\
Example 2: Produce a wide listing of the current directory of C one page at a
time
DIR C: /P /W
Example 3: List every occurrence of the file AUTOEXEC.BAT in the current
directory and its subdirectories
DIR AUTOEXEC.BAT /S
Example 4: List the contents of the DOS directory in chronological order
DIR C:\DOS /O:D
Example 5: List only those files in the root of C which are hidden
DIR C:\ /A:H
A Wildcard Character is a character which has special meaning. In DOS
wildcards are the * (the asterisk) and ? (the question mark ).
They are usable with many DOS commands. The question mark represents any single
character, and the asterisk a string of characters. Wildcards enable you to do
more with the basic commands.
As examples, suppose you wanted to use the DIR command to list only the files
that ended with a particular extension, or started with a particular word.
Example 1: Display only those files in the root of C whose name ends with the
.COM extension
DIR C:\ *.COM
Example 2: Display those files in the DOS directory which start with DISK,
are followed by 4 characters, and have any extension.
DIR C:\DOS\DISK????.*
You should get into the habit of using the DIR after you have executed a
command (e.g. the MD or CD commands discussed above, or the COPY, DEL etc.
commands below) to confirm the effects of that command.
To create a text file in DOS you invoke the Screen Editorby
using the EDIT command.
Command Syntax: EDIT DRIVE:\PATH\ FILE
FILE must be an unformatted ASCII text file
Carry out the following steps to create your own file; this will give you a
file on which to practice the other commands.
Type EDIT <return> at the DOS prompt. You should get the following screen
Then type in the bold text below, using your own name where it says
your name. This text will constitute the contents of the
file.
(If you make a mistake while typing use the following keys to make
corrections. - The Delete and BackSpace keys to remove letters; the @echo off Once you have finished press the Alt key which, as indicated at the
bottom of the screen, activates the menus.
You will see the first letters of the Menu Items at the top of the screen
become illuminated. The File item should be highlighted. If not use Type in the file name HELLO.BAT <return>. You have now created a
file called HELLO.BAT, containing the above text. Now leave the Editor by
activating the File Menu, and then selecting Exit.
The file you have just created is a simple Batch file - i.e. a file of
DOS commands which will be executed, one after the other, simply by typing in
the name of the file (withoutthe .BAT extension).
To run this batch file type HELLO <return> at the DOS prompt.
The message Good Day should appear.
The Editor provides an easy method of creating a new text file. It is
particularly useful for creating DOS batch files (which are special text files).
If you want to modify/edit an existing text file then you simply supply the name
of that file as a parameter to the command. Once in EDIT you can use a mouse, or
simply the keyboard, to highlight text, cut (or copy) and paste that text,
select menu items, etc. Most of the commands in EDIT are self explanatory and
easy to use.
Example: Edit the batch file you have just created.
EDIT HELLO.BAT
The COPY command enables you to make copies of files. It may be used to make
a copy within a particular directory, to copy from one directory to another and
to copy from one disk to another. You can use the command to copy one file by
using its filename, or several files by using the DOS wildcard characters
* and/or ?
Command Syntax: COPY DRIVE1:\PATH1\ FILE1(S) DRIVE2:\PATH2\ FILE2(S)
Example 1: Copy one file from drive C to drive A
COPY C:\HELLO.BAT A:
Example 2: Make a copy of a file within the same directory. You have to give
the copy a different name. e.g. GREETING.BAT
COPY A:\HELLO.BAT A:\GREETING.BAT
Example 3: Copy all the files in the root of A to a directory on the hard
drive
COPY A:\*.* C:\DOCS
Now use the DIR command to list the files on drive A again.
The XCOPY command behaves in the same way as the COPY command, however it
allows the copying of all the files in a directory, and also its subdirectories.
Command Syntax:
Where SWITCHES are
S - copy subdirectories which contain files Example 1: Copy the contents of the DOCS directory, and its subdirectories,
including empty ones, to directory TEMP-DIR on A
XCOPY C:\DOCS A:\TEMP-DIR /S /E
DOS will allow you to create the TEMP-DIR if it does not already exist.
Example 2: Copy all the files in the root directory of C modified on or after
1/1/96 to A
XCOPY C:\*.* A: /D:1/1/96
Example 3: Copy all the files in the A drive's TEMP-DIR directory to a
directory with the same name on the C drive
XCOPY A:\TEMP-DIR C:\TEMP-DIR
The DEL or ERASE commands perform the same operation; you can use either.
Command Syntax: DEL DRIVE:\PATH\FILE(S) /P
The P switch causes DOS to prompt the user with the name of the file to be
deleted, to confirm that this is really his intention, before actually carrying
out the deletion. If the P switch is omitted then the deletion is carried out
silently.
Example 1: Prompt the user with the name of each file in the current
directory that has the extension .BAK, and ask him to confirm whether it should
be deleted
DEL *.BAK /P
Example 2: Delete the file HELLO.BAT from the DOCS directory
DEL C:\DOCS\HELLO.BAT
Example 3: Delete all files in the root of A
DEL A:\*.*
Whenever the wildcard character is used in this manner, the user is always
reminded that all files in the directory will be deleted, and asked to confirm
Yes or No.
Warning
NEVER delete the file COMMAND.COM file since it is the file which enables DOS
commands to run.
Be very careful when using wildcard characters with the DEL/ERASE command, as
you will not be asked to confirm the deletion of individualfiles when
using it (unless you use the /P switch) and so may delete a file which you
really need to keep. You should always use DIR to list the contents of the
directory before you start deleting using wildcards, to see exactly what files
will be affected.
The UNDELETE command, which was not available before DOS 5, attempts to undo
the use of DEL. It provides a degree of protection against accidental deletion
of files. UNDELETE relies on the fact that DELeting a file does not physically
remove it but simply marks the area of disk concerned as available for reuse.
Thus once you have deleted a file you will not see it if, for example, you
execute the DIR command but providing it has not been subsequently overwritten
it should be recoverable using UNDELETE.
Command Syntax: UNDELETE DRIVE:\PATH\FILE(S) /SWITCHES
Where SWITCHES are
LIST - list all files deleted which have not been subsequently overwritten
Example 1: Undelete the file called HELLO.BAT which has been deleted from the
A drive
UNDELETE A:\HELLO.BAT
If recoverable the dialogue will be continue something like this -
Directory: A:\ Deletion-tracking file not found.
MS-DOS directory contains 1 deleted files. Using the MS-DOS directory method.
?ELLO BAT 49 1/1/96 16:23 ...A Undelete (Y/N)? Y File successfully undeleted.
Example 2: Undelete all files that are recoverable in the current directory
UNDELETE
DOS 5 does not have a specific command for moving files (DOS 6 does) but this
can be achieved by using the COPY (or XCOPY) and DEL commands. i.e. Making
copies and then deleting the originals.
Example: Move all the document files in the root directory of drive C to
drive A
COPY C:\*.DOC A:
DEL C:\*.DOC
The RENAME or REN command is used to rename a file or a group of files. The
file contents and the location of the renamed files remains the same.
Command Syntax: REN DRIVE:\PATH\ FILE1 FILE2
Example 1: Rename a single file
REN C:\HELLO.BAT MESSAGE.BAT
Example 2: Rename a group of files to have a common file extension
REN A:\TEMP-DIR\*.BAT *.BAK
The DOSKEY command is only available in DOS 5 and 6. Once the command is
issued and the DOSKEY program installed it saves subsequent command lines typed
in at the keyboard in an area, or buffer, of RAM; this in effect means that it
'remembers' previous command lines. The user can recall these lines with a few
simple keysrokes instead of having to type them in again.
To start DOSKEY type
DOSKEY <return>
From this point on the command lines you input will be remembered.
You can then use the You can edit a command line you have recalled by using the Additionally
F7 Displays a numbered list of the commands DOSKEY has stored
F9 Allows you to selects a command by number
Alt+F7 Clears the buffer
The TYPE command is used to display the content of a textfile on
screen. (If the screen displays garbled characters, with regular beeping sounds,
then it is likely that the file is a non text file.) TYPE merely displays a
file; it does not allow you to edit/change it.
Command Syntax: TYPE DRIVE:\PATH\ FILE
Example: Display the contents of a file called MESSAGE.BAT
TYPE MESSAGE.BAT
The PRINT command allows you to obtain a print-out of a text file. Printers
are slow devices and are often shared by more than one computer. Obviously you
do not want to have to wait until your file is physically printed before being
able to continue using your machine. Therefore when you execute the PRINT
command your file is added to a print queue - this is a list, stored in
memory, of files waiting to be printed. This 'queuing' of a file by PRINT is
very quick; much quicker than the actual printing of the file. Once the PRINT
command has been executed DOS is free to execute other commands even though the
relevant file might not yet have been printed. You can continue working and the
file will be printed, in the background, when it reaches the top of the
queue.
Command Syntax: PRINT /SWITCHES DRIVE:\PATH\ FILE
Where SWITCHES are
T - Terminate printing i.e. remove all files from the print queue
C - Cancel printing of the specified file
Example 1: Print two text files
PRINT A:\TEMP-DIR\HELLO.BAK MESSAGE.BAT
Example 2: List the files in the Print Queue
PRINT
Example 3: Cancel the printing of MESSAGE.BAT
PRINT /C MESSAGE.BAT
Example 4: Empty the print queue
PRINT /T
The COPY command can be used as a quick method of creating a small text file.
The command line you use instructs DOS to copy all subsequent screen output
(represented by CON:) to the file you specify, until you terminate this action
and close the file by pressing Ctrl+Z (i.e. pressing the Ctrl key and
before releasing it pressing the Z key) or the F6 function key.
This method of creating a file is very crude. Unlike EDIT or other editors it
does not allow you to correct your mistakes as you are creating the file.
Command Syntax: COPY CON: DRIVE:\PATH\ FILE
The best way to demonstrate this use of COPY is with an example.
Type in the following. Every thing you type after the COPY line will be
stored in LONG-MSG.BAT until you press Ctrl+Z or F6. If you make a mistake while
typing you can abort what you have done and return to the DOS prompt by pressing
Ctrl+C (i.e. pressing the Ctrl and C keys in the manner indicated for Ctrl+Z
above). Use your own name where it says your name.
COPY CON: LONG-MSG.BAT Then type Ctrl+Z or F6
Now run this batch file which you have just created.
ATTRIB enables you to assign files the properties, or attributes, of being
Read Only (R), Hidden (H) and System (S) files. Each of these attributes (R, H,
and S) is assigned with + and cleared with -
Where attribute may be
R - read only file attribute (file cannot be deleted or edited but can be
listed with DIR and viewed and copied)
S - system file attribute (file cannot be deleted or copied, nor is it
visible with the DIR command but it can be edited)
H - hidden file attribute (same properties as S)
A file may have more than one attribute
SWITCH is
S - apply the command in all subdirectories of the path specified
Example 1: Protect the MESSAGE.BAT file from being deleted or changed - i.e.
making it Read Only
ATTRIB +R MESSAGE.BAT
Try deleting or editing the file once you have added this attribute.
Example 2: Remove the Read Only attribute from a file
ATTRIB -R MESSAGE.BAT
Example 3: Hide all the batch files in the current directory
ATTRIB +H *.BAT
Use DIR to check the files have been hidden.
Example 4: Make the files visible to DIR again
ATTRIB +H *.BAT
Note, that although System and Hidden files cannot be seen using DIR, it is
possible to find out what files have these attributes (and their names if you
have forgotten them) by using ATTRIB on its own to view the attributes of all
files in your directory.
This command can be useful for displaying the differences between two text
files e.g. The current version of a file and an older version.
Command Syntax: FC /SWITCH DRIVE1:\PATH1\FILE1 DRIVE2:\PATH2\FILE2
SWITCH is
N - number the lines of the files
Example:
FC /N MESSAGE.BAT LONG-MSG.BAT
DOS assumes that the input to a command comes from the keyboard, and output
goes to the monitor. However this flow can be redirected. Input can be read from
a file rather than the keyboard, and output can be sent to a file or a printer
instead of the monitor.
To read information from a file the < (less-than sign) must be used
in the command line. To send information to a file or printer the >
(greater-than sign) must be used.
Example 1: Save the directory listing of C to a file
DIR C: > DIR-LIST
If DIR-LIST already exist then its contents will be over written. Otherwise
it is created containing the output of DIR.
The >> (double greater-than sign) is used to
appendinformation to an existing file rather than overwriting it.
Example 2: Append a wide listing of the root of A and its subdirectories to
DIR-LIST
DIR A: \ /W /S >> DIR-LIST
To display the contents of DIR-LIST you could use TYPE. However there may too
much information to fit onto one screen. Instead you can use the <
redirector to read the contents of DIR-LIST into a DOS command which will
display the information one page/screen at a time.
The command is MORE
Example 3: Display the contents of DIR-LIST one screen at a time
MORE < DIR-LIST
A filter processes in some way the information input to it.
The MORE command is a filter that displays data input to it one screen at a
time. As demonstrated in the last example it is often used with the <
redirector.
Command Syntax: MORE < DRIVE:\PATH\ FILE
It is also commonly used with another redirector, the command line pipe (see
next section).
Another filter is the SORT command which sorts a text file input to it into
alphabetical order.
Example:
SORT < DIR-LIST
The pipe makes the output of one command become the inputto
another, allowing you to combine commands within a command line. To pipe
commands place the | (broken vertical bar key on the keyboard) between
the commands concerned. This causes all output generated on the left hand side
of the bar to be sent to the right hand side for processing.
Command Syntax: command-name | command-name
Example 1: Display the output of the DIR command one screen at a time
DIR | MORE
Pipes can also be used with the other redirection operators.
Example 2: Pipe a listing of the files in the root of C to the SORT command
and store the output of SORT in a file called ORDERED.LST
DIR C:\ | SORT > ORDERED.LST
Additionally you can have more then one pipe within a command line.
Example 3:
DIR C: | SORT | MORE
PC viruses can infect the computer's memory, as well as the partition table,
boot sector and files (particularly executable files) on floppy and hard disks.
Different viruses attack different parts of a machine.
You should ensure that you always you have the latest copy of a
reputable Anti-Virus software product (e.g. from McAfee or Dr. Solomon) running
on your machine to warn of the presence of viral programs, to guard against them
infecting your hard disk and to provide tools to allow you to attempt to
disinfect an infected disk.
DOS shell, which first appeared with DOS 4 is a program that attempts to
provide an easier interface to DOS. DOS shell provides a graphical front end to
DOS commands allowing most of them to be executed using the mouse, with minimal
keyboard input. Note that DOS shell was not provided with MS-DOS version 6.
To run the DOS shell program type DOSSHELL <return>
Once DOSSHELL is launched the first screen displays a menu bar to the top,
directly beneath it a list of drives which can be accessed, and then three small
windows. The windows are the Directory Tree window (in which you select a
directory on the currently highlighted drive), the Files window (displaying the
contents of the selected directory), and a Main window giving access to the DOS
command prompt, editor, DOS Q-Basic and some disk utilities.
The screen should look similar to the figure below.
You can get help on using the DOS shell environment in the following ways -
By using the Mouse - clicking on the Help option in the menu bar
By using the keyboard - by pressing Alt+H
In both cases a pull down menu appears and you select from the menu by moving
the selection bar to one of the options with either the mouse or the Another way of obtaining help is by simply highlighting the item you need
help on using the mouse, and then pressing the F1 key. This has the effect of
displaying a dialogue box whose content relates directly the item which was
highlighted.
Alt Activates the Menu Bar Tab Moves between Drives, Directories, Files and Main windows
There are several ways of quitting from the DOS shell environment
Press Alt+F4
Copyright: The University of Strathclyde Computer Centre, Glasgow, Scotland.
Permission to copy will normally be granted provided that these credits
remain intact.
We'd appreciate a request before you use these notes, partly to justify
distributing them, but also so we can distribute news of any updates.
These notes were written by Alastair Morrison of the University of
Strathclyde Computer Centre. They form the basis of the Computer Centre's
Introduction to DOS course. Alastair can be reached at
Alastair.Morrison@strath.ac.uk.
Contact the Computer Centre if you're interested in finding out about or
attending any of our courses.
Introduction
Tapes, Disks and Main Memory
1 Kilobyte (KB) is equivalent to 1,024
bytes and so stores 1,024 characters.
1 Megabyte (MB) is equivalent to
c.1,000,000 (1,024 x 1,024) bytes/characters.
Speed
of Accessing (Retrieving) stored information - a Disk is much faster than a
Tape.
Introduction to DOS - Disk Operating System
Version Year Features
1.0 1981 Original Disk Operating System
1.1 1982 Support for double-sided disks
2.0 1983 Support for sub directories
2.01 1983 Support for international symbols
2.25 1983 Bug fixes
3.0 1984 Extended character set, large hard disks
3.1 1984 Support for PC networks, bug fixes
3.2 1986 Support for 3.5-inch disks
3.3 1987 Support for PS/2 computers
4.0 1988 Support for large partitions
4.01 1989 Bug fixes
5.0 1990 New shell, new editor, smaller kernel, memory management
6.0 1993 Disk Compression, better Memory Management, and
AntiVirus software now included in the operating software.
had to be bought separately, as Utilities. 6.0 Contained
a number of bugs.
6.2 1993 Microsoft claims it was not a bug fix for 6.0, but most
observers saw it as that.
Essential Components of DOS
The BIOS
Disk Drives and Floppy Disks (Diskettes)
5.25
" Double-sided Double-Density 320KB/360KB 40 Tracks 8/9 Sectors
5.25 "
Double-sided High-Density 1.2MB 80 Tracks 15 Sectors
3.5 " Double-sided
Double-Density 720KB 80 Tracks 9 Sectors *
3.5 " Double-sided High-Density
1.44MB 80 Tracks 18 Sectors *
3.5 " Double-sided High-Capacity 2.88MB 80
Tracks 36 Sectors
Write Protecting Floppy Disks
Inserting a Floppy Disk
New Floppy Disks and Disk Formatting
DISK Structure
Directory Structure
Files and Filename
Maximum length allowed for a filename
is 8 characters.
Maximum length allowed for the extension to a file name is
3 characters.
The file name and extension are separated by a .
(period).
Characters not permitted in naming files are
. " / \ [
] : | < > + = ; , ? ^ * And Spaces
These characters have special
meaning when used in or with a file name.
BAS Basic program
BAT Batch file; it contains a group
of DOS commands the user wants to run
COM Command file
DOC Document
EXE Executable file, Similar to COM file
PRN Print file
SYS System
file
$$$ Temporary file
Directory Names
Running DOS Commands
Changing the default disk drive
Repeating commands
key repeatedly
until your command reappears, and then <return>.
Recalls the
last command the user entered a character at a time
Command Line Syntax
command-name DRIVE:\PATH\DIRECTORY /SWITCHES
FILE
C: for the hard disk drive.
A: for the floppy disk drive.
B: if there is a second floppy disk drive.
F: for a network disk.
Command Syntax: DIR DRIVE:\PATH\DIRECTORY /SWITCHES
FILE
Error Messages
DOS Help
DOS COMMANDS
Disk Manipulation
FORMAT - formats a disk
N:s - where s is the
number of sectors per track
a machine with a HD drive can read and format
both HD and DD disks.
a machine with a DD drive can read and format
only DD disks.
SYS - makes a disk a System disk
UNFORMAT - unformats a disk
DISKCOPY - makes a copy of a diskette
Command Syntax: DISKCOPY DRIVE1: DRIVE2:
(source disk) (destination disk)
Directory Manipulation
MD or MKDIR - creates a directory
CD or CHDIR - changes directory
Command Syntax: CD DRIVE:\PATH
or CD
. - the Current Directory
.. - the Parent Directory of the current directory
PROMPT - changes the command prompt
TREE - displays the directory structure
RD or RMDIR - removes a directory
Renaming directories
PATH - creates a search path
File Manipulation
DIR - Lists files and subdirectories
Command Syntax: DIR DRIVE:\PATH\DIRECTORY /SWITCHES
FILE
W - produce a wide
listing
S - execute the command in subdirectories of the
subject
directory as well as the directory itself
A:x - list only files with
attribute x where x = h (hidden), r (read only), s (system)
O:y - order the
listing according to y where y = n (name), e (extension), s (size), d (date and
time - earliest first)
B - blank out heading and summary information
Wildcard Characters ? *
EDIT - creates a new file or modifies an existing file
Once in the editor
press the ESC key.
(Arrow) keys
to position the Cursor without removing letters; and the Insert key to switch
between Insert and Over Write mode.)
echo.
echo GOOD DAY your name
echo.
and
to highlight
it. Press the Return or Enter key to activate the File Menu. Use
to move the menu
Bar down to Save As, and press <return< to select this option.
COPY - copies a file or a group of files
XCOPY - copies all files in a directory (and its subdirectories)
XCOPY DRIVE1:\PATH1\DIRECTORY DRIVE2:\PATH2 /SWITCHES
FILES
E - also copy empty
subdirectories (/E is used with /S)
D:date - only copy files changed after a
certain date
DEL or ERASE - deletes a file or a group of files
UNDELETE - undeletes files
ALL - undelete all deleted files without prompting the user
File Specifications: HELLO.BAT
Of those, 1 files may be
recovered.
Please type the
first character for ?ELLO .BAT: H
COPY (or XCOPY) plus DEL - moves files
RENAME or REN - renames files
DOSKEY - recalls commands
and
(or F8 )
keys to view the command lines and <return> to execute your choice.
and
keys to
position yourself within the line and using the Insert key to switch between
OverWriting and Inserting text before typing in your changes. You can also clear
the current command line by pressing the ESC key.
TYPE - displays text files
PRINT - prints a text file
COPY - used to create a file
@echo off
echo.
echo GOOD DAY your name
echo.
pause
echo YOU ARE USING
ver
ATTRIB - sets file properties
Command Syntax: ATTRIB + attribute DRIVE:\PATH\FILE(S) /SWITCH
- attribute
FC - compares two files
Redirection, Filters, Pipes
Redirecting input and output ( <, >, >> )
Filters e.g. MORE, SORT
The Command Line Pipe ( | )
Computer Viruses
DOS Shell
Opening Screen Display
Help from within DOS Shell
and
arrow keys and
then clicking on your chosen option or pressing <enter> to activate it.
Once you have done this a dialogue box will appears corresponding to the
selection made.
Basic Keys for using the Menus
Selects a menu
<return> Activates selected menu
Basic Keys for using the windows
Arrow Keys
Selects option within window
<return> Activates option
Quitting DOS Shell
Press F3
From the menu select File and choose Exit
Copyright notice and Credits
HOME