Professional Documents
Culture Documents
System Programming
System Programming
System Programming
FOREWORD................................................................................................................................................................4
INTRODUCTION................................................................................................................................................................4
MS-DOS.....................................................................................................................................................................4
ROLE OF THE OPERATING SYSTEM....................................................................................................................................5
USING DOS FROM WITHIN WINDOWS 95/98 AND WINDOWS NT/2000/XP/VISTA.............................................................5
Running MS-DOS in a Window.......................................................................................................................6
EXITING DOS................................................................................................................................................................8
DOS Window....................................................................................................................................................8
TUTORIAL SECTION 1 - DOS FOR THE TECHNICALLY CHALLENGED...........................................9
DIR...............................................................................................................................................................................10
LISTING THE FILES IN A DIRECTORY.................................................................................................................................10
SYNOPSIS.......................................................................................................................................................................10
TYPE.................................................................................................................................................................................10
SYNTAX..........................................................................................................................................................................10
DIR [d:][path][file name] [/P][/W].................................................................................................................................10
OPTIONS..........................................................................................................................................................................10
Examples...........................................................................................................................................................................10
DIR E:\WORD\*.DOC....................................................................................................................................................10
DIR TUTORIAL............................................................................................................................................................11
DIR SELF-TEST 1 - RUNNING DIR WITH /P .................................................................................................................11
DIR SELF-TEST 2 - USING WILDCARDS WITH DIR........................................................................................................12
DIR SELF-TEST 3 - MORE WILDCARDS ........................................................................................................................13
DIR SELF-TEST 4 COMBINING WILDCARDS WITH SWITCHES ............................................................................................13
Example............................................................................................................................................................................13
Command Description..................................................................................................................................................13
CHDIR (CD)...............................................................................................................................................................14
CHANGING THE CURRENT DIRECTORY...............................................................................................................................14
SYNOPSIS.......................................................................................................................................................................14
TYPE.................................................................................................................................................................................14
SYNTAX..........................................................................................................................................................................14
CD [d:][path] ...................................................................................................................................................................14
OPTIONS.........................................................................................................................................................................14
path Specifies the desired directory path name to make current. The path name can be no more ..............................14
than 63 characters beginning with the root directory designation (\)................................................................14
Examples...........................................................................................................................................................................14
CD ....................................................................................................................................................................................14
CD TUTORIAL..............................................................................................................................................................15
CD SELF-TEST 1 - FILES CONTAINED IN THE ROOT DIRECTORY.......................................................................................15
CD SELF-TEST 2 - FILES CONTAINED IN THE WINDOWS DIRECTORY................................................................................16
CD SELF-TEST 3 NAVIGATING THE FILE-SYSTEM..........................................................................................................16
PATHS..........................................................................................................................................................................17
Absolute Paths...............................................................................................................................................17
Relative Paths................................................................................................................................................17
MKDIR (MD).............................................................................................................................................................18
CREATING DIRECTORIES .................................................................................................................................................18
SYNOPSIS.......................................................................................................................................................................18
TYPE.................................................................................................................................................................................18
SYNTAX..........................................................................................................................................................................18
MD [d:][path] ..................................................................................................................................................................18
OPTIONS.........................................................................................................................................................................18
path Specifies the path of directory names, including the name of the subdirectory to be created. ............................18
The entire path name must not exceed 63 characters, including backslashes...................................................18
Examples...........................................................................................................................................................................18
MD TUTORIAL.............................................................................................................................................................19
MD SELF-TEST 1 CREATING DIRECTORIES ON A DIFFERENT DRIVE.................................................................................21
MD SELF-TEST 2 CREATING A DIRECTORY STRUCTURE..................................................................................................22
Introduction to MS-DOS
RMDIR (RD)..............................................................................................................................................................23
REMOVING DIRECTORIES ................................................................................................................................................23
SYNOPSIS.......................................................................................................................................................................23
TYPE................................................................................................................................................................................23
SYNTAX..........................................................................................................................................................................23
RD [d:][path] ...................................................................................................................................................................23
OPTIONS.........................................................................................................................................................................23
path Specifies the path of directory names, including the name of the subdirectory to be deleted. ............................23
The entire path name must not exceed 63 characters, including backslashes...................................................23
Examples...........................................................................................................................................................................23
RD TUTORIAL..............................................................................................................................................................24
RD SELF-TEST 1 REMOVING DIRECTORIES ON A DIFFERENT DRIVE.................................................................................25
RD SELF-TEST 2 REMOVING AN ENTIRE DIRECTORY STRUCTURE.....................................................................................26
COPY............................................................................................................................................................................27
COPYING FILES.............................................................................................................................................................27
SYNOPSIS.......................................................................................................................................................................27
TYPE................................................................................................................................................................................27
SYNTAX..........................................................................................................................................................................27
COPY [d:][path][source file name] [d:][path][destination file name]...........................................................................27
OPTIONS.........................................................................................................................................................................27
Examples...........................................................................................................................................................................27
COPY TUTORIAL...........................................................................................................................................................28
COPY SELF-TEST 1 COPYING SPECIFIED FILES..................................................................................................................28
COPY SELF-TEST 2 COPYING FILES WITH PARTICULAR EXTENSIONS ...................................................................................28
COPY SELF-TEST 3 COPYING SYSTEM FILES ....................................................................................................................29
COPY SELF-TEST 4 COPYING TO SUBDIRECTORIES ..........................................................................................................29
DEL..............................................................................................................................................................................30
DELETING FILES ...........................................................................................................................................................30
SYNOPSIS.......................................................................................................................................................................30
TYPE.................................................................................................................................................................................30
SYNTAX..........................................................................................................................................................................30
Examples...........................................................................................................................................................................30
DEL TUTORIAL...........................................................................................................................................................31
DEL SELF-TEST 1 DELETING A SPECIFIC FILE FROM A SPECIFIC DIRECTORY.......................................................................31
DEL SELF-TEST 2 DELETING SPECIFIC FILES FROM SPECIFIC DIRECTORIES ........................................................................31
DEL SELF-TEST 3 DELETION OF FILES USING WILDCARDS ...............................................................................................32
DEL SELF-TEST 4 DELETION OF FILES USING NAMES AND WILDCARDS .............................................................................32
EXTENDED KNOWLEDGE................................................................................................................................................32
TIME............................................................................................................................................................................33
ENTERING/DISPLAYING THE CURRENT TIME......................................................................................................................33
SYNOPSIS.......................................................................................................................................................................33
TYPE.................................................................................................................................................................................33
SYNTAX..........................................................................................................................................................................33
OPTIONS.........................................................................................................................................................................33
hh Hours............................................................................................................................................................33
Examples........................................................................................................................................................33
TIME 18:30....................................................................................................................................................33
TIME.................................................................................................................................................................................33
Returns the current time as stored by the system clock and prompts for a new time to be entered. If the
time does not require modification simply press <return> and the current setting will be maintained......33
Page 2 of 48
Introduction to MS-DOS
Returns the current date as stored by the system and prompts for a new date to be entered. If the date
does not require modification simply press <return> and the current setting will be maintained...............35
TREE TUTORIAL.........................................................................................................................................................39
TREE SELF-TEST 1 VIEWING THE ROOT FILE-SYSTEM ....................................................................................................39
TREE SELF-TEST 2 VIEWING THE WINDOWS SUBDIRECTORIES ..................................................................................39
ATTRIB.......................................................................................................................................................................40
CHANGING FILE ATTRIBUTES ...........................................................................................................................................40
SYNOPSIS.......................................................................................................................................................................40
TYPE.................................................................................................................................................................................40
SYNTAX..........................................................................................................................................................................40
Examples.........................................................................................................................................................40
ATTRIB -S IO.SYS ....................................................................................................................................40
ATTRIB............................................................................................................................................................................40
Displays the attributes of all the files in the current working directory........................................................40
The ATTRIB command shows the file attributes in the left-hand column followed by any MS-DOS eight
and three name in the next column and finally the actual long file name in the right-hand column as
shown in Figure 16 on the next page.............................................................................................................40
FORMAT TUTORIAL..................................................................................................................................................45
FORMAT SELF-TEST 1 FORMATTING A FLOPPY DISK ....................................................................................................45
FORMAT SELF-TEST 2 CREATING A BOOT DISK USING FORMAT...............................................................................45
FORMAT SELF-TEST 3 DOING A QUICK FORMAT....................................................................................................46
LABEL.........................................................................................................................................................................47
CREATE A LOGICAL VOLUME LABEL FOR A DISK ...............................................................................................................47
SYNOPSIS.......................................................................................................................................................................47
TYPE.................................................................................................................................................................................47
LABEL A:DISK1......................................................................................................................................47
LABEL TUTORIAL......................................................................................................................................................48
LABEL SELF-TEST 1 LABELLING A FLOPPY DISK ...........................................................................................................48
LABEL SELF-TEST 2 LABELLING A HARD DRIVE...........................................................................................................48
LABEL SELF-TEST 3 DELETING A VOLUME LABEL........................................................................................................48
Page 3 of 48
Introduction to MS-DOS
Foreword
This guide is intended as both an introduction to, and tutorial on, the MS-DOS utilities retained by
Microsoft Windows operating systems'. Read the introduction and subsequent sections, which
introduce the concepts of operating systems and their uses (in particular the MS-DOS commands).
The next part of the guide takes you step-by-step through using MS-DOS commands to carry out some
simple activities. It is to be used by students of Ethical Hacking 1 and Internet Systems Security to
ensure that they have adequate DOS CLI skills.
Introduction
An operating system is a set of (often-unrelated) programs, which control the operation of the
hardware on a computer and manage its resources. When the IBM PC was originally introduced, the
only operating system available for many years was Microsofts MS-DOS (Microsoft Disc Operating
System). Contrary to common belief, MS-DOS1 is by no means dead - it is still in widespread use.
Many software applications still function perfectly well under DOS and their users maintain the
attitude, If it's not broken - dont fix it.
Many new users have never used DOS and are familiar with only the graphical elements offered by
operating systems such as Vista, or some version of Windows NT/2000/XP, (or perhaps even
Windows 95/98). Most operating systems such as Vista etc offer easy to use Graphical User
Interfaces (GUI) and are common throughout industry. Periodically there will be tasks which require
knowledge of DOS, which is a CLI (Command Line Interface), in order to carry out certain
administrative tasks. It may be impossible to carry out these tasks from the graphical interface and the
user must revert to the power and flexibility of the command line interface. (There are some security
risks associated with MS-DOS due to the inherent lack of authentication or authorisation capabilities
and many organisations will prevent access to the command-line capabilities.)
MS-DOS
MS-DOS is made up of a number of commands. These commands are either known as intrinsic
commands (internal commands), or extrinsic commands (external commands). This concept of
intrinsic and extrinsic commands will be expanded in the advanced tutorial. In the meantime, consider
MS-DOS as a collection of commands, which can be used to manipulate resources in a controlled
fashion. Resources include anything from the CPU (Central Processing Unit) to a hard disk. It is also
worthwhile to note that there are some tasks that can only be completed from the command line.
Most of the commands are stored as either executable (.EXE files) or command files (.COM files)
within the MS-DOS directory on the hard disk. The number of files stored in the MS-DOS directory is
dependent on either the version of MS-DOS being used or the Windows platform. As with any
software, each time a new version was released, new facilities may be made available (and some may
be removed). MS-DOS 6.2 comprises of almost 150 files. These files would normally be located in a
directory called C:\DOS or C:\MS_DOS ('C' may be replaced with any other valid drive letter).
NOTE: When using Windows in MS-DOS mode, the files used for MS-DOS commands are located in
a directory called C:\WINDOWS\COMMAND or C:\WINDOWS\SYSTEM. It should also be noted
that Windows 2000/XP/Vista do not support the full set of MS-DOS commands available in for
example, MS-DOS 6.2.
The terms MS-DOS and DOS will be used interchangeably throughout this document.
Page 4 of 48
Introduction to MS-DOS
Page 5 of 48
Introduction to MS-DOS
The display should now look like that of figure 2, with DOS running in a window.
A DOS window is now available and is ready to accept commands at the prompt.
Page 6 of 48
Introduction to MS-DOS
Page 7 of 48
Introduction to MS-DOS
Exiting DOS
DOS Window
To exit a DOS Window:
Type EXIT and press <return>. This should exit the DOS Window and return the
system to Windows, as shown in Figure 11.
1.
2.
Page 8 of 48
Introduction to MS-DOS
The commands we will look at in section 1 are detailed in the table below.
Command
DIR
CHDIR (CD)
MKDIR (MD)
RMDIR (RD)
COPY
DEL
ATTRIB
TIME
DATE
Use
Display files and directories
Change current working directory
Create a directory
Remove a directory
Copy a files or directories
Delete files
Display or modify file attributes
Display or set system time
Display or set system clock
The following section gives the name of the command followed by a brief description (synopsis) and
finally a small tutorial section on each. There are self-test sections that should be completed.
Page 9 of 48
Introduction to MS-DOS
DIR
Listing the files in a directory
SYNOPSIS
This command lists the files in either the current directory or a specified directory. DIR also
displays other directory entries.
TYPE
Intrinsic Part of MS-DOS.SYS and IO.SYS
SYNTAX
DIR [d:][path][file name] [/P][/W]
OPTIONS
d: path file name
Specify the drive letter (i.e. C: for C:\DRIVE or A: for A:\DRIVE), path
name (such as C:\WINDOWS) or file name (i.e., REPAY.XLS) when you
wish to obtain a directory listing of files that are not in the current directory.
/P
Tells DOS to pause when the screen has been filled. To see the next screen of file names,
press any key.
/W
Displays a directory showing only file names in a wide format five names across each line.
DIR is used to display the contents of a directory as well as the file size in bytes, the date and time of
the last modification, the number of bytes available on the disk and any sub-directories within the
current directory. Think of when you explore the contents of your USB disk using My Computer or
Windows Explorer, DIR is the command line alternative to display the file and folder2 information.
Examples
DIR C:
Displays the contents of the current working directory on drive C.
DIR E:\WORD\*.DOC
Displays all the files on drive E: contained in the WORD directory with the .DOC extension.
DIR E:\
Displays all the files in the root directory of drive E:, including any subdirectory information.
Introduction to MS-DOS
DIR Tutorial
1. Enter DOS mode, either restart the system in DOS mode or run DOS in a window.
2.
3.
4.
This should give a wide listing of the files contained in the WINDOWS directory, as shown in
Figure 6. The command was issued in a DOS window.
Repeat the DIR command, substituting /P for /W and note the results in the box provided for
Self-Test 1.
C:\WINDOWS>DIR /P
Note:
Make a reasonable attempt at answering the questions, they will help add understanding and
depth to your knowledge.
The /W and /P options that have been illustrated are known as switches. Some documentation may
refer to them as flags or options. Essentially a switch is used to give additional information to a
command. Think of it as having a radio button or check box selected whilst using Windows.
Page 11 of 48
Introduction to MS-DOS
6.
To list all the executable files in the windows directory, type DIR *.EXE <return>. Make a
note of the results in the box provided - several entries will suffice.
7.
Using the '*' character to denote any file name which ends in .EXE is known as using a wildcard.
Wildcards are particularly useful, think of a couple of reasons you may want to use them and list
them in the box provided for self-test 2.
C:\WINDOWS>DIR *.EXE
There is another wildcard available the '?' character. However, the '?' character can only be used to
represent one single character. For example, the format would be DIR ????????'.EXE.
However, there is a minor problem with this method. Each ? represents a single character, therefore
prior knowledge of the file name size is required. For example a file name with up to and including 4
characters ending in .DOC would be displayed by typing DIR ????.DOC.
Page 12 of 48
Introduction to MS-DOS
8.
Try using wildcards to search for different file names within the WINDOWS directory. Enter the
wildcard patterns that you use in the box provided for Self-Test 3 and note the results of the
command several entries will suffice.
9.
To conclude the tutorial section on DIR, the use of multiple switches and wildcards is considered.
Let us assume that we wish to display all the files in a particular directory which start with the
character f and end in .DLL (a DLL file is a windows Dynamic Link Library) in wide format and
paused.
10. Enter the command/s in the box provided for self-test 4 and a description of the command.
Description
C:\WINDOWS>DIR A*.* /W
C:\WINDOWS>DIR ???O*.* /W
11. You have in your possession your first tool from the 'DOS toolkit'. Master it and it will serve
you well on your journey through DOS. The DIR tutorial is complete.
Page 13 of 48
Introduction to MS-DOS
CHDIR (CD)
Changing the current directory
SYNOPSIS
This command changes the working directory to the specified directory.
TYPE
Intrinsic Part of MS-DOS.SYS and IO.SYS
SYNTAX
CD [d:][path]
OPTIONS
d:
Specify the drive letter (i.e. C: for C:\DRIVE or A: for A:\DRIVE) of the disk you wish
to make the current drive.
path Specifies the desired directory path name to make current. The path name can be no more
than 63 characters beginning with the root directory designation (\).
Examples
CD
Changes to the current working directory. Essentially changes you into where you currently are.
CD ..
Moves up one branch in the directory tree (if not already in the root directory C:\ or A:\ - i.e. top
of the tree).
CD \
Changes the current working directory to the root directory, i.e. C:\.
CD TEMP
Changes the current working directory to a directory called TEMP within the current sub tree. For
example, if the current directory was C:\WINDOWS and this command was issued (provided a
TEMP directory exists within WINDOWS) the working directory would change to
C:\WINDOWS\TEMP.
CHDIR (CD) is essentially the navigational tool for the MS-DOS user. It is in effect the only facility
for the user to make another directory the current working directory. This may not seem important
now, but it will become more apparent throughout this tutorial.
Page 14 of 48
Introduction to MS-DOS
CD Tutorial
1.
From the DOS prompt (ensuring you are on the Drive C:) issue the following command, 'CD \
<enter>'.
2.
This should change the current working directory to the root directory of the C Drive. As shown
in Figure 7.
Whilst in this directory use the DIR command to obtain a wide listing of the files. Make a note of
at least four of the files listed in the box provided for self-test 1.
4.
You should have listed files such as AUTOEXEC.BAT and CONFIG.SYS etc. If these files were
not in this directory, check you carried out the command in the root directory of drive C. [They are
really only here for historical purposes if they are present they are likely displaying a file size of
0kb.]
5.
Change back into the WINDOWS directory using 'CD WINDOWS'. List the contents of this
directory showing only the files that end in .DLL, using the pause switch. Make a note of at least
four of the files listed, in the box provided for self-test 2 (overleaf).
Page 15 of 48
Introduction to MS-DOS
6.
During navigation of the file-system, it is often useful to be able to move one directory back from
where you currently are. DOS uses 'CD ..' to denote that we wish to change the current working
directory back up one in the directory structure.
My Documents
Windows
Temp
Word
Program
Files
Microsoft
Office
Adobe
Excel
Access
Drivers
CAB
Sophos
Page 16 of 48
Introduction to MS-DOS
Paths
There are several ways to navigate the file-system. They are:
Absolute path - Give the path (including the drive) from the root directory (top of the
tree).
Relative path - Give the path relative to your current working directory (from where
you are).
Absolute Paths
The absolute path to any file is given from the top of the tree, which is known as the root directory.
For example, if we wish to change from the 'C:\Program Files\Microsoft Office\Word' directory to the
'C:\TEMP' directory, the command would be 'CD \TEMP'. This command changes to the TEMP
directory regardless of the current working directory. This type of command does require that you
know the exact path to the directory required. The semantics of the above command are:
'move to the root of the current drive\move into TEMP directory'.
Relative Paths
The relative path to any file is expressed from the current working directory. For example, if we wish
to change from the 'C:\Program Files\Microsoft Office\Word' directory to the
'C:\TEMP' directory, the command would be 'CD ..\..\..\TEMP'. This may look rather peculiar
to begin with, but all that is happening is a convolution of the 'CD ..' command. The '\' characters
are simply being used to denote directory separators. The semantics of the above command are:
'move up one dir\move up one dir\move up one dir\move into TEMP
dir'.
8. If you found CD Self-Test 3 'Navigating the File-System' difficult, please attempt it again.
Complete this self-test before continuing, it is imperative that you can navigate the file system
freely.
9.
You now have another DOS utility in your toolkit. The CD tutorial section is complete. However,
feel free to extend your knowledge by navigating the File-System using the 'CD' command, listing
the files in the directories' that you enter using the 'DIR' command.
Page 17 of 48
Introduction to MS-DOS
MKDIR (MD)
Creating directories
SYNOPSIS
This command creates a directory with specified directory name, providing the directory does not
already exist.
TYPE
Intrinsic Part of MS-DOS.SYS and IO.SYS
SYNTAX
MD [d:][path]
OPTIONS
d:
Specifies the drive letter (i.e. C: for C:\DRIVE or A: for A:\DRIVE) of the disk you wish
to create the subdirectory in.
path Specifies the path of directory names, including the name of the subdirectory to be created.
The entire path name must not exceed 63 characters, including backslashes.
Examples
MD TEMP
The above command creates a directory called TEMP within the current directory, if the specified
directory does not already exist.
MD A:\APPS\WORD
The above command creates a directory called WORD on drive A:, within the APPS directory, if the
specified directory (WORD) does not already exist. The directory APPS must already exist, or the
command will fail.
MKDIR (MD) is essentially used to create subdirectories within the MS-DOS file-system. Without
MD it would not be possible (for the user) to place any structure on the file-system. As an analogy,
think of a filing cabinet with only one large drawer. You may be able to store lots of information, but
to find anything may mean searching through the whole drawer. Alternatively, if you have facilities to
create numerous small drawers, and each drawer can be used to store sets of related information, the
data is much more manageable.
Page 18 of 48
Introduction to MS-DOS
MD Tutorial
1.
From the DOS prompt, issue the following command, 'CD \'.
2.
This should change the current working directory to the root directory as shown in Figure 9.
Place a USB disk in one of the USB slots: and type X: <return> (where X will be your USB
drive letter specification). The display should change to that of Figure 10, in this case illustrating
E: as being the active drive.
Page 19 of 48
Introduction to MS-DOS
4.
Use the DIR command to display the files contained in the USB drive, as shown in Figure 11.
Type MD DOCUMENT <return> to create a directory called DOCUMENT. Once you have
completed this command type DIR DOCUMENT to ensure that this directory has been
successfully created, as shown in Figure 12. The directory has been created with two specific
parts . is the current (or child) directory and .. is a link to the parent directory. All
directories are descendants of the root directory X:\ (where X is the drive letter).
Figure 12. Directory listing of the DOCUMENT directory (or folder) on E:\.
Page 20 of 48
Introduction to MS-DOS
6.
Return to the C: drive using the method shown earlier. From the C: drive, create a directory on
drive E: called 'E:\DOCUMENT\WORD'. Make a note of the command used in the box provided
for Self-Test 1.
7.
Change the active drive to E: and use the MD command to create the directory structure as
illustrated in Figure 13.
E:
\
Backup
Windows
Temp
Apps
Office
Word
Excel
CD_ROM
Drawplus
SB16
PP20
Access
Enter the commands required to create the directory structure of Figure 13 in the box provided for
self-test 2. It is possible to display a full directory tree using the DIR command. Return to the
root directory of the disk and type DIR /S *.*. This should display the entire directory
structure. MS-DOS supports another command called TREE, which displays the tree structure of
either a specified drive or directory. Typing TREE /F will display similar information to using
the DIR /S command.
9.
In some instances the output from the TREE command or DIR /S can scroll over more than one
screen. It is possible to use the MORE command as shown below. The command TREE /F |
more will display the output one screen at a time.
Page 21 of 48
Introduction to MS-DOS
10. You now have another DOS utility in your toolkit. The MD tutorial section is complete.
However, feel free to extend your knowledge by creating an alternative file system using the 'MD'
command. Once you have created the directory structure, list the directories' that you have created
using the 'DIR /S' command, as shown in task 8 above.
Page 22 of 48
Introduction to MS-DOS
RMDIR (RD)
Removing directories
SYNOPSIS
This command deletes an empty directory with specified directory name, providing the directory
already exists (and is empty).
TYPE
Intrinsic Part of MS-DOS.SYS and IO.SYS
SYNTAX
RD [d:][path]
OPTIONS
d:
Specifies the drive letter (i.e. C: for C:\DRIVE or A: for A:\DRIVE) of the disk you wish
to delete the subdirectory from.
path Specifies the path of directory names, including the name of the subdirectory to be deleted.
The entire path name must not exceed 63 characters, including backslashes.
Examples
RD TEMP
Deletes a directory called TEMP on the current drive within the current directory, if the specified
directory already exists.
RD A:\APPS\WORD
Deletes (or removes) a directory called WORD on drive A:, within the APPS directory, if the
specified directory (WORD) already exists and is empty. The directory APPS\WORD must already
exist, or the command will fail.
RMDIR (RD) is essentially used to delete subdirectories within the MS-DOS file-system. Without
RD it would not be possible (for the user) to remove any directories from the file-system. The
analogy, this time would be a filing cabinet that only ever got bigger. You may be able to store lots of
information, but to find anything may mean searching through all of the drawers. Alternatively, if you
have facilities to create and remove drawers, and each drawer can be used to store sets of related
information, the data is much more manageable.
Page 23 of 48
Introduction to MS-DOS
RD Tutorial
1.
From the DOS prompt (ensuring you are on the C Drive) issue the following command, 'CD \'.
2. Place the USB disk that you created the directory structure on in a USB slot and move to the root
directory of drive E:.
3.
Use either DIR /S or TREE /F to ensure that the directory structure has been correctly created
as shown in Figure 19.
4.
Using the RD command, remove the folder called Temp by typing 'RD TEMP' (notice that MSDOS is not case sensitive).
5.
Ensure that the directory has been successfully removed by typing 'DIR' or TREE /F. The
directory Temp should no longer exist as shown in Figure 14.
Page 24 of 48
Introduction to MS-DOS
6.
Change directories so that you are in the Apps directory. Type RD Office <return> to
delete the directory called Office. Something strange will happen. Can you work out why?
7.
The directory was not empty as the subdirectories Word, Excel and Access reside within the Office
directory. You should therefore have encountered an error message such as that of figure 15.
8.
There are two ways around this, you could have simply changed into the Office directory and used
the RD command to remove the three directories (providing they were empty) and subsequently
navigated back up one directory to remove the Office directory. Alternatively, MS-DOS provides
the ability to delete directories and their contents (regardless of whether the contents are further
sub-directories that are not empty). This option is available with the DEL command, which is also
used to delete files. You will investigate the DEL command later in this section.
Change the active drive to C: and use the RD command to delete the directories CD_ROM and
SB16 from the drive and directory structure as illustrated in Figure 19. You must remember that
you are not deleting directories that exist on the current drive and therefore it may be advisable to
look back at page 23 to check the syntax for accessing a different drive.
10. Enter the commands required to delete the entire directory structure of Figure 13 in the box
provided for self-test 2.
Page 25 of 48
Introduction to MS-DOS
11. You now have another DOS utility in your toolkit. The RD tutorial section is complete. However,
feel free to extend your knowledge by creating and deleting an alternative file system using the
'MD' and 'RD' commands.
12. If you wish to look ahead to the DEL command to learn how to remove entire directory
Page 26 of 48
Introduction to MS-DOS
COPY
Copying Files
SYNOPSIS
This command copies the files in either the current directory or a specified directory.
TYPE
Intrinsic Part of MS-DOS.SYS and IO.SYS
SYNTAX
COPY [d:][path][source file name] [d:][path][destination file name]
OPTIONS
d: path source file name Specify the drive letter (i.e. C: for C:\DRIVE or A: for A:\DRIVE),
path name (such as C:\WINDOWS) and source file name (i.e.,
REPAY.XLS) when you wish to copy a file from a specified drive and
source directory to a specified drive and destination directory.
Examples
A:\WORK\COPY TEMP.DOC TEMP2.DOC
Copies a file called TEMP.DOC to a file called TEMP2.DOC within the same subdirectory on drive
A:.
COPY A:\TEMP\FOO.DOC C:\WINDOWS\FURFUN
Copies a file called FOO.DOC from drive A:, from within the TEMP subdirectory to the
subdirectory WINDOWS\FURFUN on the C: drive. The destination file name remains unchanged
and therefore is not specified. However, the destination file name may be specified if renaming of
the file is required, as shown:
COPY A:\TEMP\FOO.DOC C:\WINDOWS\FURFUN\NEWFOO.DOC
This command creates a copy of the file FOO.DOC and places it in NEWFOO.DOC in the
FURFUN subdirectory of WINDOWS.
COPY C:\APPS\WORD\*.DOC LETTERS
This command copies all the files that end with the extension .DOC in the APPS\WORD
subdirectory, to the LETTERS subdirectory, if the specified files do not already exist in the
LETTERS subdirectory. The directory LETTERS must also already exist, or the command will fail.
For a similar command, see XCOPY in any MS-DOS reference manual. XCOPY will allow the
creation of files and sub-directory structures (with the right combination of flags even if they are
empty). XCOPY is very useful, but if used incorrectly you may overwrite files or directories that
you had not intended to overwrite. The command summary for XCOPY is available by typing
XCOPY /?
XCOPY has a significant number of options and parameters. Before you use XCOPY make sure
you know what you are doing.
Page 27 of 48
Introduction to MS-DOS
COPY as the name implies is essentially the method of copying files from one location or file name to
another. It is an essential part of your repertoire and should be mastered completely before continuing.
Copy Tutorial
1.
From the DOS prompt, (ensuring that you are on the Drive C) return to the root directory by
issuing the following command, CD \ <return>.
2.
Now make your USB drive E: active by typing E: <return> (E: will be whatever your drive
becomes when inserted in the USB slot).
3.
There are several files in the C:\M11CDE subdirectory on drive C, which you must copy to drive
E:. Using the MKDIR (MD) command, create five subdirectories on your disk called DOC,
EXCEL, PROGRAMS, SYSTEM and DATABASE.
4. Make a note of the commands used in the box provided for Self-Test 1.
5.
Copy the file MEMO.DOC from C:\M11CDE to the DOC subdirectory that you have created on
drive A:.
6.
7. Make a note of the commands used to carry out these operations in the box provided for Self-Test
2.
8.
Copy all the files that end in .XLS from C:\M11CDE to the EXCEL subdirectory.
9.
Copy all the files that end in .MDB from C:\M11CDE to the DATABASE subdirectory.
10. Copy system files (*.BAT, *.SYS) from C:\M11CDE to the SYSTEM subdirectory.
11. Copy all the files that end in .EXE from C:\M11CDE to the PROGRAMS subdirectory.
Page 28 of 48
Introduction to MS-DOS
12. Copy all the files that end in .PAS from C:\M11CDE to the PROGRAMS subdirectory.
13. Make a note of the commands used to carry out these operations in the box provided for Self-Test
3.
14. Create two subdirectories within the system subdirectory called OLDSYS and NEWSYS.
15. Make the OLDSYS directory your current working directory and make a copy of the files from the
E:\SYSTEM subdirectory to the current working directory. You may use relative or absolute
paths.
16. Repeat the above operations making the NEWSYS directory the current working directory.
17. Make a note of the commands used in the box provided for Self-Test 4.
You now have yet another DOS utility in your toolkit. The COPY tutorial section is complete.
However, feel free to extend your knowledge by copying other files to and from your USB disk
using the COPY command, making a note of the files that you have copied using the DIR command
(remember DIR /S and TREE /F display all files and associated subdirectory information).
Please note that all the files you have been copying have no real content and are simply dummy files
for the purposes of the activities.
Page 29 of 48
Introduction to MS-DOS
DEL
Deleting Files
SYNOPSIS
This command deletes the files in either the current directory or a specified directory.
TYPE
Intrinsic Part of MS-DOS.SYS and IO.SYS
SYNTAX
DEL [d:][path][source file name]
OPTIONS
d: path source file name Specify the drive letter (i.e. C: for C:\DRIVE or E: for E:\DRIVE),
path name (such as C:\WINDOWS) and file name (i.e., REPAY.XLS)
when you wish to delete a file from a specified drive and directory.
Examples
A:\WORK\DEL TEMP.DOC
Deletes a file called TEMP.DOC from same subdirectory on drive A:.
DEL E:\TEMP\FOO.DOC
Deletes a file called FOO.DOC from drive E:, from within the TEMP subdirectory.
DEL C:\APPS\WORD\*.*
Deletes all the files that end with the extension .DOC in the APPS\WORD subdirectory.
DEL /S C:\TEMP
Would delete everything inside the TEMP directory including any subdirectories and files contained
in those subdirectories.
DEL as the name implies is essentially the method of deleting files from a specified (or default)
location.
Page 30 of 48
Introduction to MS-DOS
DEL Tutorial
1.
From the DOS prompt, (ensuring that you are on Drive C) return to the root directory by issuing
the following command, CD \ <return>.
2.
3.
There are several files that you must now delete from drive E:. Using the DEL command, delete
the file JEDI.DOC in the DOC subdirectory on drive E:. Make a note of the command used in
the box provided for Self-Test 1.
4.
5.
6. Make a note of the commands used to carry out these operations in the box provided for Self-Test
2.
7.
Using the DEL command, delete the all the files in the OLDSYS and NEWSYS subdirectories on
drive E:.
8. Make a note of the commands used to carry out these operations in the box provided for Self-Test
3.
Page 31 of 48
Introduction to MS-DOS
9.
Delete all the files that end in .XLS from the EXCEL subdirectory.
10. Delete all the files that end in .MDB from the DATABASE subdirectory.
11. Delete the file PROGRAM1.PAS from the PROGRAMS subdirectory.
12. Make a note of the commands used to carry out these operations in the box provided for Self-Test
4.
13. Yet another DOS utility in your toolkit. The DEL tutorial section is complete. However, feel free
to extend your knowledge by copying other files to and from your USB disk using the 'DEL'
command, making a note of the files that you have deleted. The extended knowledge box below
can be used to record your extended delete activities.
Extended Knowledge
Page 32 of 48
Introduction to MS-DOS
TIME
Entering/Displaying the current time
SYNOPSIS
This command displays the current time and allows the time to be reset.
TYPE
Intrinsic Part of MS-DOS.SYS and IO.SYS
SYNTAX
TIME [hh:mm[:ss[.xx]]]
OPTIONS
hh
mm
ss
.xx
Hours
Minutes
Seconds
Hundredths of seconds
Examples
TIME 18:30
Sets the time to 18:30:00:00 (6:30pm)
TIME
Returns the current time as stored by the system clock and prompts for a new time to be entered. If
the time does not require modification simply press <return> and the current setting will be
maintained.
If an invalid time is entered, an Invalid time error message will be displayed. The time must
be entered using the correct syntax, i.e. TIME 20/30 would not set the current time to 8:30pm.
TIME is used to display the current time as stored by the system clock. The command is useful for
finding out the current time and using it to ascertain when a file or subdirectory was created or
modified. Keeping the time set to the correct time may also allow you to identify any irregularities
that occur during the systems operation.
Page 33 of 48
Introduction to MS-DOS
TIME Tutorial
1.
From the DOS prompt, (ensuring that you are on Drive C) return to the root directory by issuing
the following command, CD \ <return>.
2.
Using the TIME command check the current time without making any changes to it.
3. Change the time to 6.00pm. Make a note of the command used to change the time in the box
provided for self-test 1.
Page 34 of 48
Introduction to MS-DOS
DATE
Entering/Displaying the current date
SYNOPSIS
This command displays the current date and allows a new date to entered.
TYPE
Intrinsic Part of MS-DOS.SYS and IO.SYS
SYNTAX
DATE [mm-dd-yy]
or
DATE [mm/dd/yy]
or
DATE [yy-mm-dd]
Examples
DATE 6-5-08
Sets the system date to Monday 5-06-2008. You may separate day, month, and year with hyphens
(-), slashes (/), or periods (.). You do not need to type leading zeroes.
DATE
Returns the current date as stored by the system and prompts for a new date to be entered. If the date
does not require modification simply press <return> and the current setting will be maintained.
If an invalid date is entered, an Invalid date error message will be displayed. The date must be
entered using the correct syntax, i.e. DATE 13/5/08 would not set the date as there is no thirteenth
month.
DATE is used to display the current date as stored by the system. The command is useful for finding
out the current date and using it to ascertain when a file or subdirectory was created or modified.
Keeping the date set correctly may also allow you to identify any irregularities that may occur during
the systems operation.
Page 35 of 48
Introduction to MS-DOS
DATE Tutorial
1.
From the DOS prompt, (ensuring that you are on Drive C) return to the root directory by issuing
the following command, CD \ <return>.
2.
Using the DATE command check the current date. Do not change the date.
3.
Now change the date to 6th June 2009. Make a note of the command used to change the date in the
box provided for self-test 1.
Well done, tutorial 1 is now complete. You are now ready for Tutorial 2 - 'The More you DOS, the
more you like it'.
Page 36 of 48
Introduction to MS-DOS
Tutorial Section 2 The More you DOS, the more you like it.
This section of the guide takes you step-by-step through using some more advanced DOS commands
to carry out some relatively difficult activities. By now, you should be competent at using DOS. The
next step is to start using DOS for more advanced tasks. This second tutorial focuses on skills such
as:
The commands we will look at in section 1 are detailed in the table below.
Command
TREE
ATTRIB
FORMAT
LABEL
Use
Display a directory tree
Display or modify file attributes
Format a disk
Give a disk a volume label (logical name)
The following section gives the name of the command followed by a brief description (synopsis) and
finally a small tutorial section on each. Self-test sections should be completed.
Page 37 of 48
Introduction to MS-DOS
Specifies the drive letter and path that contain the TREE command.
Specified the drive whose directory paths you want to display. The default is the
current drive.
Display all the file names within each subdirectory
TREE C:
Lists the directories on drive C, each with its full path and its subdirectories.
TREE /F
Allows you to see the names of individual files within the subdirectories that it finds on the current
drive.
The TREE command is used to quickly view the structure of a hierarchically organised disk. The
directories that you create on your disk can quickly grow, much like the branches of a tree. Like the
branches of a tree, your directories can quickly become very large and complicated. To help you keep
track of the directories on your disk the TREE command is invaluable. As its name suggests, the
TREE command displays a tree-like representation of your directory structure.
The TREE command is particularly useful if you just want to refresh your memory of a particular part
of your directory structure.
Please Note
In Windows 95/98 and NT the TREE command is often unavailable. However, it is possible to
simulate it using DIR /S command, which will provide similar output.
Page 38 of 48
Introduction to MS-DOS
TREE Tutorial
1.
From the DOS prompt, (ensuring that you are on Drive C) return to the root directory by issuing
the following command, CD \ <return>.
2.
Issue the following command TREE <return> . In the box provided for self test 1, write a
short description of the result of issuing this command.
3.
Let us assume that you find yourself in the situation where you need to know the structure of the
C:\WINDOWS subdirectory and subsequently any subdirectories within it. In the box provided for
self test 2 write the command that would allow you to view these subdirectories graphically.
Page 39 of 48
Introduction to MS-DOS
ATTRIB
Changing file attributes
SYNOPSIS
Allows you to specify a file as archive, read-only, system or hidden or to display the current attributes
of a file or files.
TYPE
Extrinsic A utility program normally stored in the MS-DOS directory (C:\DOS or
C:\WINDOWS\COMMAND) as the file ATTRIB.EXE.
SYNTAX
ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [[drive:][path]file name] [/S]
OPTIONS
+ Sets an attribute.
- Resets (Clears) an attribute.
R Read-only file attribute.
A Archive file attribute.
S System file attribute.
H Hidden file attribute.
/S Processes files in all directories in the specified path.
Examples
ATTRIB -S IO.SYS
Resets the system attribute of the file IO.SYS.
ATTRIB
Displays the attributes of all the files in the current working directory.
The ATTRIB command shows the file attributes in the left-hand column followed by any MS-DOS
eight and three name in the next column and finally the actual long file name in the right-hand
column as shown in Figure 16 on the next page.
Page 40 of 48
Introduction to MS-DOS
Page 41 of 48
Introduction to MS-DOS
ATTRIB Tutorial
1.
From the DOS prompt, (ensuring that you are on Drive C) return to the root directory by issuing
the following command, CD \ <return>.
2.
Using the ATTRIB, command check the attributes of the files in the root directory. Do not
change the attributes of any of these files. Write the attributes of the files AUTOEXEC.BAT,
CONFIG.SYS and COMMAND.COM in the box provided for Self Test 1.
1.
2.
3.
3. Change drive so that you are on the USB disk E:. Copy all of the files from the root directory of
drive C: into the root directory of the USB drive E:.
4.
Using the ATTRIB command, change the attributes of COMMAND.COM (on your USB disk) to
read A SHR. Write the command used to carry out this task in the box provided for Self-Test 2.
Page 42 of 48
Introduction to MS-DOS
5.
It is possible to remove attributes. Consider how you might remove the system attribute of the file
COMMAND.COM. Write the command you could use to carry out this task in the box provided for
Self Test 3.
6.
It is possible to add and remove attributes at the same time. For example ATTRIB +H R
COMMAND.COM would both add the hidden attribute and reset the read-only attribute of the file
COMMAND.COM.
7.
In the box provided for self test 4, write the command that would grant the system attribute and
remove both the archive and read-only attributes of the file CONFIG.SYS stored on your USB
disk.
Page 43 of 48
Introduction to MS-DOS
Format
Preparing a disk for use with MS-DOS
SYNOPSIS
Allows you to prepare a disk by rearranging random magnetic impulses into a series of tracks and
sectors in order that MS-DOS can address and therefore use the disk.
TYPE
Extrinsic A utility program normally stored in the MS-DOS directory (C:\DOS or
C:\WINDOWS\COMMAND) as the file FORMAT.COM.
SYNTAX
[d:][path] FORMAT drive:[/S][/1][/8][/V/][Q][/B][/C][/4][/N:xx][/T:yy]
OPTIONS
d:path
drive
Specifies the drive letter and path that contain the TREE command.
Specifies the disk to be formatted
Examples
FORMAT A:
Formats drive A.
FORMAT A: /S
Formats drive A and copies the system files on to the boot sector of the disk along with the command
interpreter COMMAND.COM.
The FORMAT command is used to organise the surface of disk into a format that MS-DOS understands
and can use. FORMAT is a destructive command as in order to arrange the surface of the disk into
tracks and sectors it must overwrite any existing information stored on the disk. Be careful when
using the FORMAT command as you will have permanently overwritten any data stored on a disk that
Page 44 of 48
Introduction to MS-DOS
you subsequently format. The command has a number of options, although the most commonly used
options tend to be /S, and /Q. More often than not floppy disks now come pre-formatted to the
capacity that you require.
You will find that, as with many of the commands introduced in this Section, it is often necessary to
combine options for a command to work as expected.
Please Note
In Windows 95/98 and NT/2000/XP/Vista it may not make sense to use some of the older MS-DOS
options along with the FORMAT command. This section has been retained for historical purposes.
You will all be using USB disks of some description and for the most part they are formatted for use
with the appropriate filesystem before use. However, it is worth noting that USB drives can be
formatted and labelled and even be used as boot devices, with primary partitions etc.
FORMAT Tutorial
1.
From the DOS prompt, (ensuring that you are on Drive C) return to the root directory by issuing
the following command, CD \ <return>.
2.
Put a floppy disk in drive A: (that does not contain any files that you need) and issue the following
command FORMAT A: <return> . In the box provided for self test 1,write a short
description of the result of issuing this command.
3. Let us assume that you find yourself in the situation where you need to create a boot (or system)
disk. In the box provided for self test 2 write the command that would allow you to create a
formatted floppy disk that also contained the MS-DOS system files on it.
4. You are in a hurry to delete all of the files on a floppy disk (from which you do not need the files).
In the box provided for self test 3, write the command that would allow you perform a quick
format of this disk.
Page 45 of 48
Introduction to MS-DOS
Page 46 of 48
Introduction to MS-DOS
Label
Create a logical volume label for a disk
SYNOPSIS
Allows you to display modify, add or delete a volume label.
TYPE
Extrinsic A utility program normally stored in the MS-DOS directory (C:\DOS or
C:\WINDOWS\COMMAND) as the file LABEL.COM.
SYNTAX
[d:][path] LABEL[ld:] [volumelabel]
OPTIONS
d:path
Specifies the drive letter and path that contain the LABEL command.
ld
Specifies the drive letter of the disk you wish to label
volumelabel Specifies the label to be used to identify the disk. The volume label can contain up to
11 characters
Examples
LABEL C:MY_CDRIVE
Labels drive C: as MY_CDRIVE
LABEL A:DISK1
Labels drive A: as DISK1
LABEL A:
Displays the current volume label and prompts the user for a new replacement volume label. If no
volume label is entered, the current volume label is deleted. It is possible to simply specify the same
volume label.
The LABEL command is used to give a logical name to a disk. It should be noted that LABEL cannot
change the volume label of a network drive. If you do not enter a volume label when prompted by the
LABEL command it will delete the existing volume label, leaving the disk without a volume label.
This is not a disaster as often a volume label is not required.
Page 47 of 48
Introduction to MS-DOS
LABEL Tutorial
1.
From the DOS prompt, (ensuring that you are on Drive C) return to the root directory by issuing
the following command, CD \ <return>.
2.
Put a floppy disk in drive A: (that does not contain any files that you need) and issue the following
command LABEL A: <return>. When prompted enter the volume label DISK1 and press
<return>. In the box provided for self test 1,write a short description of the result of issuing
this command.
3.
Let us assume that you find yourself in the situation where you need to create a volume label for
drive C: . In the box provided for self test 2 write the command that would allow you to create a
volume label of MS_DOS for drive C: of your system..
4. You wish to delete the volume label on a floppy disk (from which you do not need the files). In
the box provided for self test 3, write the command that would allow you delete the volume label
from this disk.
Page 48 of 48