MSM1 - Introduction to DOS

Materials:
Working complete PC
Blank Diskette
Student Diskette, "New Boot A Ver 2.0+"
Objectives:
The student should become familiar with the DOS operating system including:
The File System (FAT),
Necessary system files, and the boot sequence,
Command.com’s internal commands,
Know all associated terminology including the meaning of acronyms.
Competency:
The student will begin to learn the DOS operating system and learn the basic skills of navigating the file system the PC and will be able to create and use a rudimentary boot disk.

Procedures

  1. The instructor will issue each student a system unit, monitor, keyboard, and mouse that boots to DOS.

  2. Boot the PC to the DOS prompt. It should look like this:

    C:\>_
    

    The DOS prompt indicates the current position or viewpoint within the file system. The BIOS assigns drives access numbers for low-level system function access. COMMAND.COM converts these into letters for human users to use when referring to the drives. The first floppy drive (beyond the twist) is drive "0" which DOS calls "A:" "B:" is reserved for the second floppy drive (in front of the twist) and "C:" is reserved for the first hard drive partition encountered. We will discuss these in the next lab.

  3. The partition is a section of the hard drive where DOS can build a file system. When it does it creates a root directory. All files must go into the root or a subdirectory of the root. The name of the root directory is "\" and ">" is simply a text arrow pointing to the cursor. The blinking underscore is where the next letter typed will appear.

  4. The only things that can be typed at the command prompt are valid recognized commands of the language. The syntax of the language is as follows:

    (prompt)>command parameter1 parameter2 (...) /switch1 /switch2 (...)
    

    But these are the stuffy computer terms. This is an actual language with very limited scope. For example the only being you ever speak to is DOS, so the subject of every sentence is: "DOS, you..." The commands are the verbs of the language. So cls can be read as: "DOS, you clear the screen". One of the tasks of the student is to learn the verbs that DOS will recognize and be sure to type them correctly.

  5. The parameters are the direct objects of the sentence, that is the targets or recipients of the command. Just like in English some verbs are transitive and require a recipient of the action to form a complete sentence. If I yell at you: "Hey, you open!" The sentence makes no sense because the command "open" implies "open what?" Some verbs are intransitive and do not require a recipient: "Hey, you run!" But English has few purely intransitive verbs. Most are either/or. And many are only transitive. DOS however has several verbs that are purely intransitive only because the direct object is built in to the verb. Cls does not mean just clear, it means clear the screen verb and object all in one. The format command is a transitive verb in the DOS language: "DOS, you format..." implies "format what?" DOS says this like this: "Required parameter missing."

  6. Switches are the adverbs of the language. The great downfall of the DOS language is the fact that these are different for each command. That is, the parameter "a:" always means the floppy drive A: for every command. But the switch "/a" means something different for each command. This is where the designers failed to plan the language. What do I mean by adverb of the language? I could yell "Hey, you hit the dog!" Here we have the verb "hit" and the parameter "dog" (recipient of the action). And now we can add a switch (adverb) as in: "Hey, you hit the dog lightly" or "Hey, you hit the dog brutally" and we can see how the meaning of the sentence changes dramatically. Switches affect how we want DOS to carry out the command.

  7. There are many commands that are built in to COMMAND.COM and can be executed at any time. This is the complete list for MS-DOS Version 6.22:

    BREAK, CHCP, CD, CLS, COPY, CTTY, DATE, DEL, DIR, EXIT, MD, PATH,
    PROMPT, RD, REN, SET, TIME, TYPE, VER, VERIFY,VOL, CALL, REM, PAUSE,
    ECHO, GOTO, SHIFT, IF, FOR, LOADHIGH
    
  8. Several of these are intended for use within batch files and don’t do much straight from the prompt. Others have such specialized uses that you may never actually execute them. So the vital list to start learning is:

    CD, CLS, COPY, DATE, DEL, DIR, MD, PATH, PROMPT, RD, REN, SET, TIME,
    TYPE, VER, VOL, ECHO
    
  9. Let's begin by executing ver:

    C:\>ver
    MS-DOS Version 6.22
    C:\>_
    

    Do not forget to hit the [ENTER] key after every command. This is the only universal rule in all of the DOS language. This command reports which version of DOS is currently running in RAM. Do not confuse this with reporting which version of DOS is stored in files on a disk. There is no command that can do this.

  10. Now let’s look at the contents of the current directory which is the root directory of the C: drive as indicated by the prompt:

    C:\>dir
     Volume in drive C is DOS        
     Volume Serial Number is 3130-8E12
     Directory of C:\
    DOS                   09-16-04   5:48p
    COMMAND  COM        54,645 05-31-94   6:22a
    WINA20   386         9,349 05-31-94   6:22a
    CONFIG   SYS            71 09-16-04   5:54p
    AUTOEXEC BAT            78 09-16-04   5:54p
            5 file(s)         64,143 bytes
                       2,021,423,488 bytes free
    
  11. The dir command requests a listing of all files and subdirectories within the specified directory. But we did not specify one, so DOS assumes you mean the current one, which is indicated by the prompt. Notice that there is a subdirectory named "DOS" in the root which dir indicates with "<DIR>". Let's look at the contents of that directory by specifying it. We are passing a parameter to the command:

    C:\>dir dos
    
  12. There are over one hundred files in there; the entire DOS operating system, and they went scrolling out of view. Now let's use two switches. One to pause the screen when it is full and wait for the user to press a key to continue: "/p" and the other to sort the filenames and then display them in alphabetical order: "/o" :

    C:\>dir dos /o /p
    
  13. Press any key to display the next screen full until the file FORMAT.COM is displayed on screen. By displaying the listing in alphabetical order it is easy to find the file. Now press and hold the [Ctrl] key and type the letter [C] then release the [Ctrl] key. These keey combination instructions will be represented like this: [Ctrl]+[C] from now on. The [Ctrl]+[C] generates an ASCII code 3 which does not represent a display character but is instead a control code meaning to interrupt the current process. Because it is a non-printable character DOS represents it on screen as "^C" and control is immediately returned to COMMAND.COM which displays the prompt again.

  14. Now clear the screen by issuing the command CLS. This command takes no parameters and no switches. DIR works with either no parameter or accepts a single parameter and may take none, one or many switches.

  15. Let's look at the COPY command. The easiest way to remember how it works is that you must tell it: COPY what (to) where. Now here is the axiom for the optional destination parameter: "You do not have to say where if you are already there". Let's copy the file FORMAT.COM from the DOS directory (that is somewhere else because we are standing in the root directory and not the DOS directory) to the root of the C: drive. This is an example of copying a file FORMAT.COM (the what) to the root (the where) and "You do not have to say where if you are already there" and you are:

    C:\>copy c:\dos\format.com
         1 file(s) copied.
    C:\>
    

  16. Notice that you must tell DOS precisely where to go find the file when it is not in the current directory, however. Now delete the file:

    C:\>del format.com
    C:\>
    

    Did you notice that nothing happened? Something did happen. The file was deleted. There was no output to the screen about it. Check and see if the file is gone. Del is obviously dangerous for this reason and you must be absolutely certain you want the file erased because there is no "Recycle Bin" in DOS.

  17. Now that we can view files, copy files and delete files, we need to know how to navigate within the file system structure. We need to know how to move into a subdirectory. This is done with cd Read the help for it (cd /?) and then move into the DOS directory:

    C:\>cd dos
    C:\DOS>
    
  18. Notice that the prompt tells you that you are on the C: drive in the root ("\" remember) and in the DOS directory in the root. Now view the files here, but in alphabetical order. If you are looking for some file that starts with an "f" a search goes much faster when you are viewing in alphabetical order:

    C:\DOS>dir /o /p
    
  19. We need to discuss all of these file names since there are many rules surrounding them. First, a file name may never exceed 8 characters in length. The file name extension may never exceed 3 characters. The name and extension are separated by a period. The legal file name (and extension) characters are: A-Z, 0-9, -, _, ~, !, @, #, $, %, ^, (, ), {, }, and ¢. The illegal characters are: &, *, +, =, [, ], \, |(pipe), :, ;, ", /, ?, commas, and spaces. All of the illegal characters are recognized syntax to COMMAND.COM which is why you can’t use them in a file name. You are allowed a single period as long as it is in the right place (no more than eight characters in front of it and no more than 3 characters behind it).

  20. The file extensions are related directly to the file’s function. Only a few actually mean something to DOS so let’s look at these first. These extensions mean executable: .COM, .EXE, .BAT. To execute an executable program from the DOS prompt simply type its name without the extension and hit [ENTER]. DOS searches the current directory looking for a file by that name. When it finds the match it is really trying to find a file named "whatever.COM". If this is found, it loads that program into RAM and passes control of the processor to it and it begins to run. If the file "whatever.COM" was not found, DOS checks again to see if there one named "whatever.EXE". If so DOS will read the header, and load the program into RAM where it recommends and give it the amount of RAM it wants and then pass control to it. That is the difference between the two. .COM files must be small and are always loaded into the same place in RAM. .EXE files are larger and the amount of RAM they want and where they want to go into RAM is specified in the EXE header at the beginning of the file. If there is still no match, DOS checks one last time to see if there is a file named "whatever.BAT". If there is, then DOS will open the file and begin reading it as text, line by line. Each line must contain a valid DOS command and it will execute them one by one until done, then close the file. The extension .BAT means "batch file" because it contains a batch of commands for DOS to execute. So a .BAT is executable in the way it behaves but it is a text file that must contain valid DOS commands. If DOS still has not found the match it will then check the environmental variables for the PATH variable. We will come back to this in a while.

  21. Now we will execute an external command. These are not built in to COMMAND.COM but reside as independent executable files somewhere on the PCs storage devices. On a system where DOS is installed they occupy the DOS directory. All of the .EXE and .COM files that you have seen in that directory are DOS’s external commands. All of the commands that are built in to COMMAND.COM are internal commands and therefore cannot be located as independent files. Insert a blank diskette into drive A:. Now format the diskette. Formatting performs the following functions:

    1. Asks you to insert a blank diskette and press [ENTER] when ready,
    2. Check the drive’s current file system. If it is missing or invalid an error will result and you will have to try again and specify the “/U” switch for unconditional.
    3. Attempt to save the DOS Boot Record or DBR which resides in the first physical sector of the diskette, as well as the File Allocation Table or FAT which follows the DBR as well as the Root Directory which follows the FAT into a temporary hidden file in case you decide to "UNFORMAT" the diskette,
    4. Begin marking each sector with boundaries and sector numbers across the surface of the diskette (this is the formatting process),
    5. Create a new DBR,
    6. Create a new empty FAT,
    7. Create a new empty Root Directory,
    8. Prompt you for a Volume Label for the diskette (if you hit [ENTER] for none it makes it "NO NAME" by the way),
    9. Writes the Volume Label into the DBR and the Root Directory,
    10. Displays a summary of the format process of the diskette,
    11. Asks if you would like to format another diskette,
    12. If you say yes it starts all over, otherwise format ends and returns control to COMMAND.COM which displays the prompt again.
  22. Format it like this:

    C:\DOS>format a: /s
    Insert new disk for drive A:
    and press ENTER when ready...
    Verifying 1.44M
    11 percent completed.
    
  23. So we see it perform step 1, then after [ENTER] we see it perform step 2 (“Checking existing format” message) and step 3 ("Saving UNFORMAT information" message) and we are in the middle of step 4 ("Verifying 1.44MB" and "xx percent completed" messages).

  24. When the formatting process is complete the screen will fall to this point:

    C:\DOS>format a: /s
    Insert new disk for drive A:
    and press ENTER when ready...
    Verifying 1.44M
    Format complete.
    System Transferred.
    Enter Volume label (11 characters, ENTER for none):_
    
  25. We see that Step 4 completed but the what does “System Transferred” mean from the above steps? This means that the DOS operating system files (also called the DOS Kernel) have been copied onto the floppy. They are: IO.SYS, MSDOS.SYS and COMMAND.COM. System Transferred also means that the boot strap loader code in the DBR has been modified to look for and load IO.SYS at boot up time. All of this was added to the format command’s steps by adding the “/s” switch which means “and make it into a boot diskette”. We can see that this was done between steps 7 and 8. Now the command is asking for a volume label. These never actually mean anything to the system so hit [ENTER] for none. And now we see this:

    C:\DOS>format a: /s
    Insert new disk for drive A:
    and press ENTER when ready...
    Verifying 1.44M
    Format complete.
    System Transferred.
    Enter Volume label (11 characters, ENTER for none):_
    Format complete.
        1,457,664 bytes total disk space.
        1,457,664 bytes available on disk.
              512 bytes in each allocation unit.
            2,847 allocation units available on disk.
    Volume Serial Number is E807-6F3D
    Format another (Y/N)?_
    
  26. The summary is displayed. If the summary ever reports another line under the “x bytes available on disk” which reads "x bytes in bad sectors" then throw the diskette away. Diskettes are already small and if part of the surface has already failed the rest will fail soon enough. Even end retailers have 100 count boxes of floppies for about $20 = 0.20¢ each. Type in "n" then [ENTER] and format returns control to COMMAND.COM which displays the prompt again.

  27. Now that we have a bootable diskette let’s change drives. This is a peculiar command in DOS in that the noun (the drive letter followed by a colon we have seen is a parameter which is a direct object which is a noun) is also the verb meaning to change to it. English has these too. Football players run the ball. And "That was a nice run." Let's change to the floppy we just formatted:

    C:\DOS>a:
    A:\>_
    
  28. Now if you ask to view files (dir) what container will DOS assume you want to see the contents or "directory listing" of? Answer: the root directory of the A: drive. Which it assumes because we did not specify any parameter and it assumes the current location which is displayed by the current prompt which is "A:\>" meaning Drive A: and "\" meaning the root directory of the drive.

  29. Notice that you see COMMAND.COM but where is IO.SYS and MSDOS.SYS? They must be here for the diskette to be bootable. They are "hidden". Not only are they hidden, they are also "read-only" and "system" files as well. These are called file attributes. This information or attributes of a file is stored along with its name, extension, creation time and date, and so on in the root directory entry for the file. If a file is marked "hidden" then you the user are not allowed to "see" the file. In fact DOS will pretend that it does not exist at all. Let's try to delete IO.SYS:

    A:\>del io.sys
    File not found.
    A:\>_
    
  30. Now in order to actually display the hidden files in the root of the floppy diskette or in the current directory wherever that might be, use the following switch with DIR:

    A:\>dir /ah
     Volume in drive A has no label
     Volume Serial Number is 2D4C-12F4
     Directory of A:\
    IO       SYS        40,774 05-31-94   6:22a
    MSDOS    SYS        38,138 05-31-94   6:22a
    DRVSPACE BIN        66,294 05-31-94   6:22a
            3 file(s)        145,206 bytes
                           1,256,960 bytes free
    A:\>_
    

    This switch means display all files by Attribute of Hidden. DOS happily displays IO.SYS and MSDOS.SYS lurking about. IO.SYS is in fact the DOS operating system. COMMAND.COM is the user interface to interact with DOS. IO.SYS contains all of the high level and low level functions for accessing the hardware. MSDOS.SYS contains the file system drivers. When a disk read or write is needed by a command, MSDOS.SYS is the one that reads the MBR, FAT, and directory entries and coordinates the location of the file amidst the sectors of the disk. DRVSPACE.BIN is a low level disk compression utility driver that IO.SYS will automatically load into memory if it encounters it on the drive regardless of whether there exists a CONFIG.SYS instruction concerning it or not. Since the native MS-DOS disk compression is not the best quality and effectively scrambles the contents of the entire disk if the compression utility DRVSPACE.EXE is not available and the Microsoft disk compression utilities are not compatible between different versions, compressing a diskette using them is an extremely poor idea. In later exercises this file will be deleted to prevent the drive from automatically loading and taking up boot up time and worse conventional memory when it is not going to be used.

  31. Now let's scandisk the diskette. Type scandisk and press [ENTER]. This is formally referred to as a utility because it completely leaves the DOS screen and enters in to its own special display screen and does whatever it does in here. A utility does not have to invoke a beautifully colored screen however to be one. Format is also formally a utility, but the definitions are so vague that it doesn’t matter if you call format a command or a utility, but you should never call dir a utility. A command can also be thought of as: anything that once you typed the command out at the prompt and hit [ENTER]; that is all you have to say. It will be completed and return to the prompt before you have to type again. Allow scandisk to perform the surface scan. It will then display a new screen representing physical sector blocks of the floppy disk and it will check them one by one to make sure that they can actually store data accurately. When done be sure it reports “no problems” then hit the "X" key to exit scandisk and return to DOS.

  32. Scandisk is an external command. And we know that if a command is not built in to COMMAND.COM that it will go and check the current directory for a file by that name that ends in .COM, .EXE, or .BAT. We just formatted the floppy and looked at the root directory. We know that scandisk is not on the floppy. So where did COMMAND.COM find it and more importantly, how?

  33. COMMAND.COM will check the path environmental variable if the search of the current directory fails to find the command that you want to execute. This variable is set when DOS first boots up with an instruction in the AUTOEXEC.BAT file. This is a special batch file that COMMAND.COM always looks for by name in the root directory of the boot drive. If found COMMAND.COM will then execute each command within it. One of those sets the path environmental variable. And COMMAND.COM also has an internal command with which you can view this variable, erase it, or change it. That command is path. Let's view the path variable:

    A:\>path
    PATH=C:\DOS
    A:\>_
    
  34. So issuing the command with no parameters or switches display the current value of the path variable. COMMAND.COM will read this and see that there is another location to search to find an executable that you tried to execute. In this case it is C:\DOS. So COMMAND.COM will go to the DOS directory on the C: drive (within the root directory as always) and search for the executable name that you typed and again it is checking for SCANDISK.COM first followed by SCANDISK.EXE next and then finally SCANDISK.BAT SCANDISK.EXE is stored in the DOS directory and so when you executed it while "standing" on the floppy drive A: this is how DOS found it. Now let's erase it:

    A:\>path ;
    A:\>_
    
  35. That is path followed by a space followed by a semicolon, then [ENTER]. Here is another command that did not appear to do anything, but it did. Check the path by typing in the path command and you will see the report that there is now no path either as “No Path” or “PATH=”. Now run scandisk on the floppy again:

    A:\>scandisk
    Bad command or file name.
    A:\>_
    
  36. Get used to this one. This is DOS's favorite error by far. All it means is that it could not locate the file SCANDISK.COM nor SCANDISK.EXE, nor SCANDISK.BAT either in the current directory or the path. We know that it is not on the diskette and we also know that we just erased the path variable. So the fact that COMMAND.COM could not find the file should come as no surprise. Now let's repair the path. First we have to find the executable(s) we want to issue.

  37. We know where they are on this PC, but you won't know where they are on someone else's. Move back to the C: drive and notice that DOS remembered that it was in the DOS folder last and so it comes back to the C: drive in that folder. Move back to the root of the C: drive using the CD command the name of the directory you want to change to is the root whose name is "\":

    A:\>c:
    C:\DOS>cd \
    C:\>_
    

    Note that you can also use the command "CD .." in this case which is the command to change directory to the parent directory of the current directory. Since the DOS directory is a subdirectory of the root, then the root directory is its parent and "CD .." will change you up one level to the root. If the directory you are in is for example: C:\DOS\TEMP then "CD .." would move you up from TEMP and into DOS.

    Now that you are back in the root of the C: drive search the drive for the file SCANDISK.EXE (or maybe it is SCANDISK.COM?). Here is how to look for any file on the hard drive named SCANDISK with any file extension. This command will look through all subdirectories also:

    C:\>dir scandisk.* /s
    
  38. That asterisk is very important. If you omit the period asterisk then you are looking for a file with no extension at all which is not correct. It does have an extension, the problem is that quite often we don’t remember if it is .COM, .EXE or .BAT all of which execute. So we put "dot star" there to mean "the file's extension is any character and any number of characters" This is the first of the wildcard characters which are used to replace characters so that we can refer to more than one similarly named files. The result of this:

    C:\>dir scandisk.* /s
     Volume in drive C has no label.
     Volume Serial Number is 3978-1AF4
     Directory of C:\DOS
    SCANDISK EXE     		124,262 	 5-11-94	6:22a
    SCANDISK INI			  6,920	 5-11-94  6:22a 
                 2 File(s)   131,182 bytes
         Total Files Listed:
                   2 File(s)        131,182 bytes
                   0 Dir(s)     216,145,920 bytes free
    C:\>_
    
  39. So DOS substituted any characters and any number of them for the "star" resulting in two "hits" in our search. Another word about the command is that "/s" which means “and check all subdirectories of the starting directory. So if you want to find a file on a drive, go to the root and look for it with dir followed by the file's name (.* if you are not sure of the extension) and "/s". When found dir tells you where it found it. Right above the "hit" listings you will see the line "Directory of C:\DOS". This is where the "hits" are located on the drive. Now that we know where it is we can fix the path variable:

    C:\>a:
    A:\>path=C:\DOS
    A:\>_
    
  40. Now when you try to scandisk it will work again because DOS knows where to search for the executable file(s). Check the path variable with the path command and see if it is fixed.

  41. The other wildcard is the "?". Let's look for all files that have three letter names on the C: drive in the DOS directory:

    A:\>dir c:\dos\???.*
    Volume in drive C has no label.
     Volume Serial Number is 3978-1AF4
     Directory of C:\DOS
    MEM      EXE        32,502      5-11-94    6:22a
    SYS      COM         9,432      5-11-94    6:22a 
    EGA      CPI        58,870      5-11-94    6:22a
    ISO      CPI        49,754      5-11-94    6:22a
    MSD      EXE       165,864      5-11-94    6:22a
    FC       EXE        18,650      5-11-94    6:22a
                 6 File(s)   335,072 bytes
         Total Files Listed:
                   6 File(s)        335,072 bytes
                   0 Dir(s)     216,145,920 bytes free
    A:\>_
    
  42. Notice that the last file only has two characters in its name. So the request for names "???" will return 3 characters or less. Something to remember. Now you can replace any character(s) one by one with the "?" wildcard which means any single character as opposed to the "*" which means any character and any number of them.

  43. Change back to the C: drive, Notice that you are still in the DOS directory. To move back to the root of the drive use: "cd \" You can also use "cd .." But this one means move up in the directory tree one level. Since you are only one level away from the root it has the same effect only because of where you happen to be. Remove the floppy and turn off the PC. See the DOS Home Page for an alphabetical listing of commands, error messages, and general DOS usage concepts.

  44. Write the command to display the version of DOS that booted up and is currently running in memory:


  45. Write the command to display the version of the DOS files located in the root of the C: drive (Caution: Trick question!):


  46. While at the "C:\>" prompt write the command that will display the files (and directories) in the root of the C: drive:


  47. While at the "C:\>" prompt write the command that will display the hidden files in the root of the C: drive:


  48. While at the "C:\>" prompt write the command that will display all files in the DOS subdirectory of the root of the C: drive in alphabetical order and pausing after each screen full:


  49. While at the "C:\>" prompt write the command that will display all files and directories on the floppy disk in the A: drive:


  50. While at the "C:\>" prompt write the command that will change into the DOS subdirectory of the root of the C: drive:


  51. While at the "C:\>" prompt write the command that will change to the diskette in the A: drive:


  52. While at the "C:\>" prompt write the command that will display the fast help for the DIR command:


  53. Using the DIR fast help screen determine how to display all files and directories in the DOS directory listing them smallest in size first:


  54. While at the "C:\>" prompt write the command that will check the PATH enviromental variable:


  55. While at the "C:\>" prompt write the command that will clear the PATH environmental variable:


  56. Does the location displayed in the prompt matter when dealing with the PATH variable? (Yes or No) ______ Explain why:


  57. While at the "C:\>" prompt write the command that will set the environmental variable to point to the DOS subdirectory of the root of the C: drive:


  58. While at the "C:\>" prompt write the command that will search the entire C: drive for the FORMAT command:


  59. While at the "C:\>" prompt write the command that will change to the subdirectory named "NOWHERE":


  60. While at the "C:\NOWHERE>" prompt write the command that will create a bootable floppy diskette in the A: drive (assume the FORMAT command is in the current directory):


  61. While at the "C:\>" prompt write the commands that will copy the 2 essential DOS disk handling commands to the floppy diskette in the A: drive:


Copyright©2000-2004 Brian Robinson ALL RIGHTS RESERVED