DOS Lesson 1

Operating Systems

 What is an Operating System?

 

The short definition is that the operating system is software that sits between the hardware and the applications.

The earliest computers did not have operating systems. In theory, we do not need operating systems today, though computing would be much less efficient without them.

1.      The operating system loads the printer drivers and makes the printer available to any application. So the first principle we can discern about operating systems is that they can make applications easier to create and run by relieving them of certain tasks.

2.      The next characteristic of operating systems is that they control access to and allocation of resources. Imagine if your printer received print instructions from two different programs and began printing from both of them simultaneously. The resulting document would not be useful.<g> On a more fundamental level, the normal desktop computer has a single CPU that handles all operations the computer does. The operating system determines which programs will have access to the CPU and under what conditions. Similarly, the operating system controls which program can write data to a disk, or draw something on the screen.

3.      The third characteristic of operating systems is the they create a user interface through which the user interacts with the computer. In the earliest computers, the interface consisted of things like punched cards and paper tape, created by specialized keyboard devices.

DOS as an Operating System

Microsoft's DOS is an example one kind of operating system, a fairly simple one, which first appeared in 1981 on the IBM PC.

·         The interface was what we call a command line interface, meaning that there was no mouse, no menus, or any graphical components.

·         Text commands were entered from the keyboard, and the computer's response appeared as text on the monitor.

·         DOS controlled some aspects of the computer hardware, particularly disk access and basic CPU operations, but it was still common to need to configure the video display, sound card, printer, etc. for each application that would use them.

·         DOS was a single-tasking operating system, which meant that only one program could be run at a time.

 

DOS Lesson 2

Booting

Bootstrap

The term boot is short for bootstrap, and the metaphor is to imagine a person wearing boots who reaches down, pulls on their bootstraps, and lifts themselves into the air. Of course, this only is possible in cartoons, but it is a vivid image. With the power off, a computer is a dead hunk of silicon, steel, and wires. During the boot process, it has to wake up, find all of its peripherals, and configure itself to run software. It takes some doing to make all of this happen.

 

BIOS

The process begins with the BIOS (Basic Input Output System), which is a series of instructions that are contained on a ROM (read-only memory) chip. In addition to the ROM BIOS there are settings that are held on a battery-powered chip. This chip is frequently made of a special material called CMOS (complementary metal oxide semiconductor). These settings are configurable by the user, and can be accessed at the beginning of the boot process by pressing a special key, such as F1 or Delete. The settings held in the CMOS tell the computer which disk drives are present, and the order in which these disks should be checked for boot information.

POST

The very first thing that happens in the boot sequence is the POST (Power On Self Test). This is run from the BIOS, and allows the computer to check for memory (you see it clicking through the available memory on your screen), check for a keyboard, and check for disk drives. If it does not find these things, it gives an error, sometimes on the screen, but more often by emitting a series of beeps through the pc built-in speaker. There are different varieties of BIOS, and each has its own BEEP codes, which are used to diagnose problems during the boot process. On the screen you may see errors like "keyboard failure", "Failure accessing floppy disk", etc.

MBR

Assuming that the keyboard is working, the memory is there, and it can find the proper disk drive, the BIOS then looks to the appropriate disk for further instructions. Whether a floppy or a hard disk drive, the very first sector of a bootabledisk ( the boot sector) contains the Master Boot Record (MBR). The Master Boot Record contains information on where to go next in the boot process. If the Master Boot Record is found, the boot process goes forward. If it is not found, or is damaged in some way, you may receive an error that says that the disk is not bootable, or is "not a system disk".

The DOS Boot Process

For DOS systems, the MBR will point the computer to two hidden start-up files. The first of these files is IO.SYS. This must be the very first file (physically) on your boot disk or your disk will not boot. The second file is called MSDOS.SYS. This must be the second file (physically) on the boot disk or it will not boot. This is why you cannot create a boot disk by simply copying these files to blank floppy disk. They would be on the disk, but they would not be in the proper position for the boot process to find them. To create a "system disk", you need to use a particular command that tells the computer to place these files in the precise position needed for booting to occur.

 

The DOS Boot Sequence

IO.SYS contains the interface between MS-DOS (or PC-DOS) and the I/O subsystem. This allows the OS to communicate with the basic peripherals and perform input and output tasks.

MSDOS.SYS is the Kernel1 of the OS. It interacts with the hardware and helps process the various DOS functions.

Both IO.SYS and MSDOS.SYS are hidden files, which means that ordinarily you would not be aware of them, and they would not appear in a directory listing. This is to protect the OS from someone mistakenly deleting these key files and rendering the computer unable to boot.

The third file to be loaded is CONFIG.SYS. As the name implies, this file contains information that helps to configure your system. This is where you would install devices and drivers, for instance. In DOS it is common to have your mouse, sound card, and CD-ROM drive installed here, as well as certain memory management and other functions. If there is no CONFIG.SYS file present, a default version contained within MSDOS.SYS is loaded.

The fourth file to be loaded, which is automatically added to the disk when you make a system disk, is COMMAND.COM. This file does not need to be in any particular physical location on the disk, but does need to be in the root directory. This file is a command interpreter, which means that it can interpret the commands you issue. Every OS has some type of command interpreter, though they may use a different name. In Unix (and Linux), for instance, the command interpreter is generally called a shell2. COMMAND.COM interprets all of the Internal Commands. The fifth, and last file to be loaded is AUTOEXEC.BAT. This is a batch file, which means that it contains a series of commands that are executed whenever the file is run. This file is "automatically executed" when you boot, hence the name. If there is no AUTOEXEC.BAT file present, a default version is run. You can usually tell because if the default version is run you will be asked to enter the date and the time.

After all of this, if it all works correctly, you will finally see the prompt, which will most likely look like one of these:

A:\>

C:\>

Summary of the DOS Boot Sequence

  1. POST
  2. MBR
  3. IO.SYS
  4. MSDOS.SYS
  5. CONFIG.SYS
  6. COMMAND.COM
  7. AUTOEXEC.BAT
  8. Command prompt

DOS Lesson 3

Internal Commands

Commands

Once your computer has completed the boot process (if you haven't done so yet, please review Lesson 2 for a discussion of the boot process), the computer is sitting there waiting for you to do something. The way you do anything in DOS is through commands that the computer understands. A command may cause the computer to take some action, or to execute some file. We'll leave most of the file execution discussion for another lesson, and for now focus on the topic of internal commands.

Internal vs. External Commands

As you will recall from Lesson 2, DOS comes with a built-in command interpreter called COMMAND.COM. This file is loaded during the boot process, which means that COMMAND.COM is resident in memory at all times, and the commands that it understands are available to the user at all times. Not all DOS commands are understood by COMMAND.COM. There are commands called external commands that reside in separate files on your hard drive, and must be called specifically for you to use them. Why is this?

One of the biggest reasons has to do with the limitations of how DOS handles memory. A full discussion of this topic will come in a later lesson, but for now it is enough to know that DOS could only address a very limited amount of memory (1MB total), and that programs were very quickly bumping up against the constraint of available memory. Since COMMAND.COM is loaded into memory at the beginning of the boot process, and stays resident in memory at all times, it would not make sense to load commands that you would only use infrequently, or to load commands that only certain users would ever need. So these commands were placed in external files where they could be accessed if needed. If you look in your DOS directory on your hard drive (usually C:\DOS), you will see these external commands represented by files that are either *.EXE or *.COM files. You won't see the internal commands here, though, because these commands are all contained within COMMAND.COM.

If you have created a DOS boot disk, which I recommend highly to anyone who will be working with computers, it will contain three files, as we discussed in Lesson 2: IO.SYS, MSDOS.SYS, and COMMAND.COM. The first two files are hidden, so you won't see them in a DOS dir command normally. But if you examine a boot disk in Windows 95's Windows Explorer, and set it to display all files (in Windows Explorer, select View, Options, and select Show All Files), you will see them there. These files are located in specific places on the disk. The third file, COMMAND.COM, must be in the root directory. Since it is on the boot disk (you cannot boot without it), that means that the commands it contains are available to you when you boot from this disk. The reason any well-prepared computer person has a DOS boot disk handy at all times is that a problem on the hard drive may render the computer unbootable. Booting from a DOS boot disk and using the commands available to you in COMMAND.COM may enable you to diagnose and fix the problem.

The other major reason why someone might want to create a DOS boot disk these days is to run legacy DOS software that has problems running with more current operating systems like Windows 95, 98, and NT.

One last note regarding internal commands - The internal commands contained within COMMAND.COM are the commands that are used in writing batch files. The batch file will not run properly if it cannot find COMMAND.COM. Normally this ought to be handled by the path command, but if you ever have problems getting a batch file to run, try putting a copy of COMMAND.COM in the same directory as the batch file. This often gets the batch file to run perfectly.

List of Internal Commands

Here are all of the 62 Internal Commands contained within the COMMAND.COM command interpreter:

break

buffers

call

cd

chcp

chdir

choice

cls

copy

country

ctty

date

del

device

devicehigh

dir

dos

drivparm

echo

erase

errorlevel

exist

exit

fcbs

files

for

goto

if

include

install

lastdrive

lh

loadfix

loadhigh

md

menucolor

menudefault

menuitem

mkdir

move

not

numlock

path

pause

prompt

rd

rem

ren

rename

rmdir

set

shell

shift

stacks

submenu

switches

time

truename

type

ver

verify

vol

 

 

Some of these internal commands (e.g. dir, cd) are meant to be executed from the command line, or within a batch file, which is what you usually think of as a command. Others (e.g. files, switches) are generally used within a configuration file like CONFIG.SYS to help configure your system. Because both CONFIG.SYS and AUTOEXEC.BAT use commands that are found in COMMAND.COM, they must load later in the boot process. So if you were wondering why things happen in that specific order in the boot process (discussed last week), now you know.

 

DOS Lesson 4

External Commands; Emergency Boot Disk

Last week we looked at the internal commands of DOS. These commands are contained within COMMAND.COM and are loaded during the boot sequence. Because of this, a certain amount of the limited DOS memory is committed to holding internal commands. Obviously, some commands do not need to be loaded into memory every time you boot, because they are used infrequently, or possibly because they are large and take up a lot of space. These commands are stored as separate files in your C:\DOS directory. (Usually; C:\DOS is the normal default, but during the installation it is possible to specify a different directory.) Let's look at these external commands:

append

assign

attrib

backup

chkdsk

command

comp

dblspace

debug

defrag

deloldos

deltree

diskcomp

diskcopy

doskey

dosshell

edit

emm386

exe2bin

expand

fasthelp

fastopen

fc

fdisk

find

format

graftabl

graphics

help

himem

interlnk

intersvr

join

keyb

label

mem

memmaker

mirror

mode

more

msav

msbackup

mscdex

msd

nlsfunc

power

print

replace

restore

scandisk

select

setver

share

sort

subst

sys

tree

undelete

unformat

vsafe

xcopy

 

 

 

Please note that you might not find all of these files on every computer. This will depend on things like which version of DOS you have installed. In some cases Microsoft replaced one file with a different file in later versions.

Extensions, Help, and associated files

External commands are files, and as such have file extensions. Generally these will be either *.EXE or *.COM. An *.EXE file is what is called an executable file. This is a file that is compiled to run as a program. To this day, any Windows program is run from an *.EXE file. The other type. *.COM, is the original "Dot Com". This refers to a command file. A few of these files will be *.SYS, which are system files, such as the IO.SYS and MSDOS.SYS files we discussed in Lesson 2. Another file type is the *.OVL file, which means overlay. This file type is found with backup programs, particularly.

Often these external files will come with Help files as well. Help files have the extension *.HLP. If you have a dual-boot system with both DOS and Windows, you can open these *.HLP files using Windows' built-in Help File viewer.

Emergency Boot Disk

One of the things that anyone learning about DOS or about computers in general ought to have in their arsenal is a DOS Emergency Boot Disk. Let's assume you have DOS installed already on your C: drive, and you can boot into DOS. How do you create this emergency boot disk? You place a blank floppy disk in your A: drive, and at the C:\> command prompt use the command:

format a: /s

This command has three parts. First, it uses the external command FORMAT. Second, it applies this command to the a:, or floppy drive. The last part is called a switch in DOS terminology. Many DOS commands have switches available to modify the command in some way. In this case, the /s switch tells it to place the system files on the disk. Recall from Lesson 2 that this means that the hidden system files IO.SYS and MSDOS.SYS will be placed very specifically in the very first sectors of the disk. Also, COMMAND.COM will be placed in the root directory of the disk. This is enough to boot the computer. You may wish to add a CONFIG.SYS and AUTOEXEC.BAT on the disk as well. You can copy these from your hard drive if you wish, using the commands:

copy c:\config.sys a:

copy c:\autoexec.bat a:

You can modify these files later using the EDIT command to invoke the DOS file editor.

At this point, you should test your boot disk by turning off the computer (if you are in DOS), placing the boot disk in the A: drive, and then turning on the power. If all goes well you should boot into DOS, though you will probably be asked to enter the date and time when you boot. If you boot to the C:\> prompt, this means that the computer never even looked at the boot disk, and this is set in the BIOS. Go into your BIOS, look for the setting for "boot order" or "seek order", and change it from something like "C,A" to "A,C". Reboot, with your floppy disk in the A: drive, and see if your boot disk works properly.

Once you know you have a good boot disk, you should add a few things. All of the Internal commands are available because you have COMMAND.COM on your disk. But you should also add some critical External commands:

If you have used disk compression there are additional issues involved, which are beyond the scope of this particular introductory discussion. The external commands listed above are critical for solving possible software problems with your computer. I recommend that anyone following this series create such a boot disk right away. This is a tool that any computer expert would have handy. I have several emergency boot disks that I carry in my organizer so that I will have them with me at all times.

 

DOS Lesson 5

The Path

 

The Command Line

Everything you do in DOS is done from the command line. The command line begins with a prompt, which is the computer's way of saying "I'm ready. Give me something to do." The prompt usually looks something like this:

C:\>

But note that you can configure how your prompt appears, so you should not assume it will always appear exactly like the example.

From the command line you can do two things: you can run an internal command (one that is contained in COMMAND.COM), or you can run a program. External commands are programs, which are found in separate files in your DOS directory, so running programs includes running external commands, but it also means running the applications software you use to do things with your computer. You can also run a batch file, but in that case all you are doing is running a series of commands or programs that are listed in the batch file. If you enter a name that is not recognized by DOS as either an internal command or a program, you get the error message "Bad command or file name" as a consequence. The NT command interpreter gives an even more informative message: "The name specified is not recognized as an internal or external command, operable program or batch file." If you receive an error message like this, it means one of several things:

    1. The name you gave is incorrect for some reason. Possibly you misspelled the name. Or maybe you are using the wrong name. Check the name and the spelling and try again.
    2. Maybe the program you are trying to run is not installed on the computer. Verify that it is installed.
    3. The file is there, but the computer does not know where to find it.

Executable application files

For DOS to run an application file , it has to be one of three kinds:

    1. COM - A file in machine language, must be less than 64K in size.
    2. EXE - A file in machine language, can be larger than 64K. EXE files also have information at the beginning of the file that tells DOS what type of file it is and how to load and run it.
    3. BAT - A batch file that is written with a text editor and is in ASCII text format, it contains DOS commands that are executed in batch mode, which means that each command is executed in sequence until the file ends.

The Path

We mentioned above that sometimes DOS cannot find a valid file. That brings us to the idea of a path. When you enter the name of an executable application file, DOS has to find it. DOS looks for the file in a specific hierarchy of locations:

    1. The active directory of the current drive (called the working directory). If you are in the directory C:\DOS, and you type in the name FOOBAR.EXE, DOS will logically enough look in C:\DOS for such a file. In fact, you do not need to type in the entire name. If you simply type in FOOBAR, DOS will look for any executable file with that name, whether it is FOOBAR.EXE, FOOBAR.COM, or FOOBAR.BAT. If DOS finds this file, it will run it.
    2. If DOS does not find this file, it will consult something called the PATH. This is a list of directories that DOS has been instructed to check whenever it cannot find a file in the current active directory.

You can see what the path is for your computer at any time by using the PATH command. Just type "path" at the DOS prompt, and you will get back your path. Here is what I got on one of my machines:

C:\>path

PATH=C:\WIN31;C:\DOS

The first line is the prompt, and the command I typed, and the second line is what the computer returned. You can see that the first place that DOS will check is the Windows 3.1 directory, and the second place is the DOS directory. If I wanted to change this, I could enter a path command and put in a new path:

C:\>path=c:\temp\;c:\dos;c:\win31

Now, when I check my path, I get this:

C:\>path

PATH=C:\TEMP;C:\DOS;C:\WIN31

BTW, I'm sure you noticed that some of these characters are lower case, and some upper case. It really doesn't matter, because DOS is not case sensitive. Internally DOS uses all upper case letters, which is why you see the output from your commands in upper case. But if you type them in as lower case, a converter automatically converts them to upper case and then they are executed.

Now, try setting a path on your DOS test computer. Notice that whenever you enter a PATH command it replaces whatever path was in the computer previously. This is useful to know.

The next question you might have is where that first path came from. Well, that is set in the AUTOEXEC.BAT. This is a batch file that automatically executes (hence the name) when you boot your computer. You can edit this file with the DOS program EDIT. To see or edit the contents of this file you need to enter the following command:

C:\>edit autoexec.bat

After you have looked at this file, you can exit from the program by hitting the following keys in order:

    1. Alt
    2. F
    3. x

Now, what would happen if you removed C:\DOS from the path? You would suddenly find that you could not use any external DOS commands unless C:\DOS is the working directory! So having C:\DOS (or whatever your DOS directory is) in the path is extremely important.

Path alterations and confusion

When you install software in DOS, it is common to find that the software you installed has modified the AUTOEXEC.BAT and changed the PATH command it contains. This is not necessarily a bad thing. Often the program needs this to function. And it does make life convenient. As an example, one of the most popular DOS programs was WordPerfect, the word processing program. This program would typically install itself in the directory C:\WP, and then add this directory to the path. The executable file to launch this program was WP.EXE, which would be found in the C:\WP directory. By having this directory in the path, all you needed to do to launch and run this program is type "wp" at any command prompt. This is very convenient. But there are a couple of considerations in using the path. First, the path has a limit of 256 characters total, so you cannot simply add every directory on your hard drive. Second, DOS will search through every directory in the path looking for an executable file. The more directories you put in there, you the more searching that goes on. So you want to keep your path statement limited to the essentials. This usually means your DOS directory, a couple of frequently used apps, and the directories for drivers for peripherals like the mouse and the sound card. For other programs, you can create simple batch file, or even a menu, that will let let you switch the working directory and launch the program in one step. We will cover this technique later.

One thing you need to watch out for is having two PATH commands in the AUTOEXEC.BAT. This is not good because the second one will replace the first one. So you want to make sure you only have one PATH command in your AUTOEXEC.BAT. But watch out for something like this:

SET PATH=C:\DOS;C:\MOUSE

PATH=%PATH%;C:\LOTUS

This looks like two PATH commands, but it isn't. The first line is creating a variable called "PATH", and the second line, which is a PATH command, is including the contents of the PATH variable. This is a legitimate technique, and all three directories will be in the resulting path.

One last note on paths: DOS will go through each directory in the PATH statement in order looking for the executable file you tried to run. You can improve your DOS performance, therefore, by placing directories in the proper order. I would always put the DOS directory first on a purely DOS system. (If you have Windows 3.1 installed you might to put that directory first, followed by the DOS directory.) I would follow this with the device drivers, like the mouse and sound card, and place an application directories at the end. And I would only include those applications that I use on a daily basis in the path.

 

 

DOS Lesson 6

Syntax and Switches; Help System

Syntax

Every command in DOS must be entered in a precise manner, which is referred to as syntax. Failure to follow the syntax precisely will most often result in an error message, but in some cases can be disastrous. So it pays to learn how the syntax works.

  1. First of all is the command name. In previous lessons we listed the various internal and external commands that are available to you. In a few cases there are shortcut command names, particularly for directory operations. To create a directory you could use the command MKDIR, or you could use the shortcut MD. Where there are shortcut command names, they are listed in the tables in the previous lessons. You must spell the command correctly. Note that while I have adopted the convention of typing all command names in capital letters, you do not need to do that. In fact, anything you type is converted to all capital letters before it is processed, so you do not need to worry about case at all. Type everything in lower case letters if you wish, it makes no difference.
  2. After the command name you must leave a space! This tells the OS that you are finished with the command name and are ready to enter the next part of the command. DOS separates the parts of a command with a blank space. That is why you could never use blank spaces in file names in DOS and Windows 3.x. The OS interpreted the space as a separator between parts of the command. Unix still works that way, which is why you must never use spaces in Unix file names. You often see the underscore used instead to represent a space in a file name.
  3. Next is the drive designation. Drives are represented by letters in DOS, though other operating systems have different conventions. In DOS, the first two letters, A and B, are reserved for Floppy Disk Drives. Early DOS computers (e.g. PC-XT) did not have hard drives, but used two floppy drives instead. The first hard drive became the C drive, and so on. That is why most computers these days use C for the hard drive even though there is at most only one floppy disk drive. Note that drive designations must always be followed by a colon.

    Example: Suppose you are booted and the C: drive is your working directory. Your prompt will then look something like

    C:\>

    If you then typed the FORMAT command, you could theoretically wipe out your hard drive by formatting it! (Actually, the OS would stop you in this case, but you cannot rely on the OS catching all of your errors, so be careful.) Now, if you wanted to format a floppy disk, you would insert a disk into your floppy disk drive (most likely the A: drive), and you would then type:

    C:\>format a:

    The first part is the command name (FORMAT), followed by a space that tells the computer you are finished with the command name, then the drive designator a: that tells the OS to apply the command to the A: drive. If you haven't done this before, get a blank floppy disk and try it.
  4. Sometimes you want to operate the command on a directory within a drive. You can do this by adding the path you want it to follow. For instance, suppose you want to get a directory listing on a directory on your hard drive called C:\WP\DOCUMENTS\. You can do this with the following command:

    C:\>dir c:\wp\documents


    You may not have this exact directory on your hard drive, but pick one you do have and try doing a directory command on it.
  5. Sometimes you can modify a command by using what are called switches. These modify how the command behaves in some way, and are always shown by a preceding forward slash. Switches are the key to making DOS work for you. Master the switches and you can do almost anything! For instance, try doing a directory command on a large directory, like C:\DOS. You should see everything scroll by on the screen very quickly, until it stops with the last screen of the directory listing. You will find this hard to use, because it went by too fast for you to see most of the listing. But you can change this behavior with a simple switch:

    C:\>dir /p c:\dos

    Note that there is a space between the command name and the switch, and between the switch and the path. DOS always expects a space between parts of a command. This switch tells the OS to display the results one screen page at a time. (The P stands for page here.) The OS will display one page of the listing, with a note at the bottom telling you to strike a key to get the next page.
  6. Sometimes you want to apply a command to a particular file. You would then place the filename in the position of the drive designator/path, or at the end, as appropriate. If you just enter a filename without other information, the OS will look for that file in the current working directory, then in the directories given in the PATH statement. If it does not find it in either place, it gives an error statement. But you can give the full path to the file and it will be fond if the file is there. For example, if the current working directory is C:\DOCUMENTS, and it contained a text file named MYFILE.TXT, you could display the contents of that file on your screen with the command:

    C:\DOCUMENTS\>type myfile.txt

    If your working directory was the root directory C:\, however, and if the directory C:\DOCUMENTS was not in the PATH statement, you would get a "File not found" error. You could get around this by using the full path:

    C:\>type c:\documents\myfile.txt
  7. So where do you find out the syntax and switches for a DOS command? Oddly enough, in the HELP system. DOS comes with a built-in HELP system, which you activate by entering the command HELP. If you use the command HELP all by itself, you get a list of all the commands available, and can then pick the one you want more information about. But you can also go directly to the command you want by using the command HELP followed by the command name:

    C:\>help mkdir

    This would give you detailed explanations of how to use the MKDIR command, what switches are available, etc. This is a pretty simple command, actually. What the HELP system says is:

    **************************************************************

    MKDIR (MD)

    Creates a directory.

    You can use the MKDIR or MD command to create a multilevel directory structure.

    Syntax

    MKDIR [drive:]path

    MD [drive:]path

    Parameters

    drive:

    Specifies the drive on which you want to create the new directory.

    path

    Specifies the name and location of the new directory. The maximum length of any single path from the root directory to the new directory is 63 characters, including backslashes (\).

    Related Commands

    For information about deleting a directory, see the <RMDIR> command. For information about changing directories, see the <CHDIR> command.

    **********************************************************************
  8. Some HELP system conventions: Note that in the above example, the parameter drive was placed within square brackets. This always denotes an optional parameter. The command will work perfectly well if this parameter is left out. Other conventions include ellipses (...), which mean an item can be repeated as often as desired. And items separated by a vertical bar (|) are either/or choices. Some examples:

    TREE [drive:][path] [/F] [/A]

    This means that for the TREE command both the drive and the path are optional, and in addition there are two switches, also optional.

    NUMLOCK=[ON|OFF]

    This command can only be used in your CONFIG.SYS file to set whether the numlock is turned on or turned off when you boot. Your choices are either ON or OFF, obviously.

    PATH [[drive:]path[;...]]

    Remember, the command PATH by itself display the current path, so any drive/path specification is optional. If you enter a drive/path, you are changing the PATH statement. So the outer set of square brackets makes the whole shebang optional. If you do wish to set a path, the drive itself is optional (though I have always seen it used. You can add additional directories to the path as well, so there is yet another set of square brackets for that. Within those brackets are a semicolon, which must be used as a separator between directories in a path statement, and then ellipses, which tell you that you can add additional directories as needed.

 

 

With all of this information, you should now be ready to start using DOS a little more intelligently. Remember to take a look at the help system, look for the syntax and switches available, and you too can be a DOS expert.

 

DOS Lesson 7

DOS Filenames; ASCII

DOS Filenames

DOS filenames follow what is called the 8.3 convention. This means that all DOS filenames have two parts, with up to 8 and 3 characters respectively. The first part is also often referred to as the filename, which can be a little confusing, but there you have it. This part can have anywhere from 1 to 8 characters in it. This is followed by the extension, which can have from 0 to 3 characters. Separating these two parts is a period, but in computer language we never call it a period, we call it a dot.

Filenames can use any letter of the alphabet or any numeral. Many of the other characters found on a keyboard are also allowed, but not all of them. That is because many of these other characters have been assigned a special use in DOS. Among the characters that can appear in a DOS filename are:

~ ! @ # $ % ^ & ( ) _ - { } `

In addition, there are characters in the extended ASCII set that can be used, such as ß. We will discuss ASCII below.

Characters which have a special meaning in DOS, and which cannot therefor be used in filenames, include:

*/ + | \ = ? [ ] ; : " . < > ,

Also, you cannot use a SPACE in a DOS filename. (Though you can simulate one using the appropriate ASCII character, as discussed below). The reason is that DOS uses spaces to separate items in the command line (see Lesson 6).

Finally, it does not matter whether you use upper case or lower case letters. DOS converts all letters to uppercase before it deals with them, so your files will all wind up with uppercase letters in the name no matter what you do.

File Extensions

A file in DOS does not need to have an extension. You can test this quite easily by creating a file called FOO and saving it in your DOS test directory. Do a directory listing using the DIR command, and you will see it listed. But the file extension does have its uses in DOS. Certain file extensions have built-in meanings in DOS, such as:

EXE = An executable file

COM = A command file

SYS = A system file

BAT = A batch file

Other extensions are created by a particular software program, or by you when you create a file. One thing that is very different in DOS, when compared to Windows, is that DOS does not have the "associations" that Windows has. In Windows, for instance, a *.DOC file will typically be "associated" with Microsoft Word, and if you attempt to open this file it will automatically call Word, open it, and load the file. DOS does not have any of this. You may have used a DOS shell2 program, such as Norton Desktop, which gave you some of these capabilities. Or, if you want to look at it that way, the ultimate DOS shell program was Windows, at least up the 3.11 level.

In any case, DOS does not have file associations, so if you used a DOS word processor it didn't particularly matter what extension you used for your files. You could get creative, and use extensions as part of your filing system if you wanted. For instance, you could name your memos using *.JAN, *.FEB, *.MAR, etc. to help keep track of them.

However, if you are using a DOS window on a Windows machine, you need to keep the needs of Windows in mind, and be more careful with your file extensions.

ASCII

ASCII is an acronym for American Standard Code for Information Interchange. ASCII is a 7-bit coding system for creating the letters, numbers, and punctuation characters needed to create basic text files. A simple calculation shows that 7 bits allows 128 possible characters (2^7=128). The same seven bits can be thought of as a number, however, which means that we can think of letters and punctuation marks as being numbers in this particular coding scheme. Bearing in mind that computer numbering schemes always begin with a zero, the possible numbers run from 0 to 127. To see how this works, boot into DOS, make sure the NumLock is set on, hold down the ALT key, and type a number from 0 to 127 using the number pad. After typing the number, release the ALT key and look at the result. You should see a character of some kind appear. You must use the number pad for this exercise, not the numbers at the top of the keyboard, BTW. Also, this works just as well in Windows as in DOS. I'm using this right now to generate the characters not normally available in my HTML editor

You may note that the name of this includes the word American. What about people in other countries who want to use characters not usually found in American words? The answer was to add one more bit, creating an 8-bit system called extended ASCII. This system has twice as many possible characters (256) running from 0 to 255. The first half is the same as ASCII, but in the second half characters like ß and à were added. This made the extended ASCII code more universal. But it still has limitations, which is why even more comprehensive code sets, such as Unicode, are being introduced.

Now, the trick for simulating a space in a file name is this: In the file name, add the character ALT + 255. This will look exactly like a space, but to the computer it is something completely different. Note that if you want to use any DOS commands involving this file you will have to use the character ALT + 255 in the appropriate place or the file will not be recognized and you will get a "file not found" error. You could use this in a DOS environment as a kind of primitive security. No one could delete this file unless they knew to add the appropriate ALT + 255.

Test file tip!

For those who want to test out these ideas we discuss each week, I suggest creating a directory on your hard drive, like C:\DOSTEMP, or C:\DOSTEST, to play around in without messing up anything else on your computer. You can then create files and subdirectories in here to test out all these procedures. Since creating files to test things is something you do a lot of, here is a genuine geeky trick to amaze your friends with. You can create a file directly form DOS without using any other program, even DOS EDIT. Here is how.

C:\DOSTEMP>copy con foo.bar

This is a test file.

^Z

If you do exactly what I have typed above, you should get back a response from the computer that says:

1 file(s) copied

Here is what is going on:

First, you are copying a file. You know about the copy command, it copies a file from one place and puts it in another place. Where is the file being copied from? It is being copied from con, which is DOS shorthand for console. The console in this case is your screen. The file is going to be copied to foo.bar, which will be created in the C:\DOSTEMP directory.

Once you enter this command, the computer is just waiting for you to type in the contents of this file. You will notice that after you hit the ENTER key you do not get a command prompt. That is because the computer is waiting for you to enter the contents of this file called FOO.BAR. So you type something like "This is a test file." Again, you hit the ENTER key, but still no command prompt. The computer thinks you may still want to enter stuff. To tell the computer you are done, you need to enter an End Of File (EOF) marker. You do that by holding down the Control key, and while it is down, hitting the "Z" key. The result should look like "^Z" on your screen. If you hit the ENTER key this time, the computer will copy the line "This is a test file." into a file called FOO.BAR, and give you the response "1 file(s) copied". Pretty neat, huh?

 

                       DOS Lesson 8

Format; Copy; Diskcopy; Xcopy

We will now begin looking at some of the commands you need to master to be proficient at DOS. The starting point has to be the commands that are probably used the most in DOS, to prepare a disk and copy files. Please note that in this discussion we will not cover every possible use of these commands, or every possible switch or argument pertaining ot them. For a complete look at these commands, you should look them up in the DOS Help System.

Format

Formatting a disk prepares it to receive data. An unformatted disk cannot be used until it has been formatted. Part of this formatting process is installing a file system. For DOS disks, that is FAT-12.

Disks come in various sizes and densities. The original IBM PC used 5 1/4 inch floppy disks that were really floppy. You could bend them, though they probably would not work afterwards. These first DOS disks could be formatted to hold 160K of data on one side of the disk. A later innovation called double-density allowed both sides of the disk to be formatted, which helped to bump up the total to 360K. The final refinement of the 5 1/4 inch disk, called high-density, pushed this all the way to a whopping 1.2MB. This was to be the final appearance of the 5 1/4 inch disk though, since a smaller type of floppy had appeared, the 3 1/2 inch disk.

3 1/2 inch disks are encased in a hard plastic shell, which occasionally confuses people who wonder about the "floppy" part of the name. But inside this plastic shell there is a thin, and very floppy, mylar disk. The equivalent double-density and high-density values are 720K and 1.44 MB respectively for these disks. BTW, for trivia buffs, Toshiba introduced a 2.88MB floppy drive in the late 1980s, but it never caught on.

Unless you have a real antique, you will only encounter 3 1/2 inch disks in either the double-density (720K) and high-density (1.44MB) variety. Looking at the disk from the top, you will see a small rectangular cut-out on high-density disks that is not there on double-density disks. While there are ways of forcing a double-density disk to format as a high-density disk, the failure rate goes up dramatically. since floppy disks are already fairly unreliable, this does not seem like a risk worth taking when brand-new high-density disks can be had for 50 cents apiece (American).

The FORMAT command has the drive to be formatted as an argument, and has several switches. Note that you cannot format a hard drive if you have booted into it. If you need to reformat your hard drive, you will need a boot floppy disk with the FORMAT command on it to accomplish your task. Also, you must remember that FORMATTING DESTROYS ALL THE FILES ON THE DRIVE! You should only use this command if you are absolutely certain that you know what you are doing and do not need anything stored on that drive.

So, to format a floppy, you can issue the command:

C:\>format a:

This will format the floppy disk in the A: drive.

You can also make certain that the disk is formatted to a certain size using the /F: switch.

C:\>format a: /f:720

This will format the floppy disk in the A: drive as a double-density 720K disk, even if it is a high-density disk capable of being formatted for 1.44MB. This can be handy if you want to make a backup copy of a double-density disk using DISKCOPY, but only have high-density blank disks available.

Finally, you can make a boot disk by formatting the disk using the /S switch to copy the system files to the disk.

C:\>format a: /s

 

Formatting a hard drive

The FORMAT command can also be used to prepare a blank hard drive to have files written to it, including installing an Operating System. Note that you cannot FORMAT the boot hard drive if you have booted into it. For this purpose, a boot floppy disk with the FORMAT command copied to it is required.

A:\>format c:

This will format the C: drive.

A:\>format c: /s

This will format the C: drive and copy the system files to it. This is almost never required, since if you are installing DOS you might just as well let the installation program handle the formatting as well.

Copy

The COPY command will, as the name implies, copy files from one place to another. Arguments are the file to be copied, and the file and path it will be copied to. Switches include /Y to prevent a prompt when a file is being overwritten, /-Y to require a prompt when a file is being overwritten, and /V to verify the contents of the copy.

C:\>copy myfile.txt a:\myfile.txt

This will copy the file myfile.txt from the working directory on C: to the root directory of the floppy disk in the A: drive.

C:\>copy myfile.txt c:\docs\myfile.txt /v

This will copy the file myfile.txt from the working directory on C: to the C:\docs\ directory and verify the contents of the file.

You can also use the COPY command to combine and append files.

C:\>copy myfile1.txt+myfile2.txt myfile3.txt

This will combine the two files myfile1.txt and myfile2.txt, and place them in a new file called myfile3.txt.

Diskcopy

This command is used to make an exact copy of a diskette. It cannot be used to clone a hard drive. Arguments are the disk drives being used, switches include /V to verify the contents of the copy. This command was most often used to make backup copies of software on diskettes back in the days when software actually came on diskettes, but it can also be used to make duplicates of other disks.

C:\diskcopy a: b:

This would copy the contents of the diskette in the A: drive to the diskette in the B: drive. If the diskette in the B: drive had any data on it, that data is erased in the copying process. If the diskette in the A: drive was a bootable diskette with system files, the diskette in the B: drive will be as well.

If no second drive is specified, the same drive will be used for both disks, and you will be prompted to switch diskettes. Place the source diskette in the drive first, issue the DISKCOPY command, and all the disk's contents will be copied into memory. You will then be prompted to insert the target diskette in the drive, and the contents held in memory will be copied to it.

C:\>diskcopy b: /v

This would use the B: floppy drive for both the source and the target diskette, and would verify the contents of the target disk after the copying.

Xcopy

The XCOPY command is designed to copy entire directories, along with all of their sub-directories, and all of the files contained in those sub-directories. Arguments are the files/path to be copied andthe place to copy them to. Switches include:

This is a very powerful command, and very useful, particularly for backing up directories on your hard drive, or even the entire hard drive. You can use the archive attribute to specify which files will or will not be copied based on file type, or you can use the file date to only copy files that have been altered after a certain date (for instance, since your last backup).

XCOPY is also useful in copying all of the files from one floppy disk to another in cases where the DISKCOPY command can not be used, such as when the disks are different types or different sizes. But note that in this case if the source diskette is bootable, the target diskette will not be.

C:\> xcopy c:\docs d:\backup\docs\ /s

This command will copy the entire contents of the directory C:\docs, including all subdirectories and their contents, except for any empty subdirectories, and place them on drive D: in the directory D:\backup\docs\. If you wanted to copy empty subdirectories as well you would use:

C:\> xcopy c:\docs d:\backup\docs\ /s /e

 

DOS Lesson 9

The File System

Once you begin creating files, both you and the Operating system need some way to keep track of them. How is this done? In DOS, the answer lies with something called the File Allocation Table3 (FAT). To understand how this important component of DOS functions, let us first look at how disks are organized to store data.

Each disk is divided into sectors4 which are 512 bytes in size. These sectors lie along tracks4, which are concentric rings on the disk. On a hard drive, these are created as part of the low-level formatting process, and have been done at the factory. In the old days users performed the low-level format themselves, but this has not been necessary in some years. On an old floppy drive, you could conceivably use sectors as the basic unit for storing file data, since the total number of sectors would not be that large. On a 360K floppy disk, you would have 720 sectors to deal with. But on a large hard drive (like 100MB!!), you would need to keep track of 200,000 of these sectors, with all of the overhead of of assigning addresses to each sector and storing information about them in a table. Also, 512 bytes is pretty small as files go. Most files would require multiple sectors to store their information, possibly hundreds of them. So the sectors were collected into larger units, called clusters5. The cluster is sometimes referred to as the allocation unit, because it is the minimum amount of space that can be allocated to a file.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

DOS Lesson 10

Directory Commands

As we saw in the last lesson, DOS uses directories to organize the files on your disks. That means we need to use directory commands to create a structure to store our files, and to find the files we have stored there. The commands we need are relatively few:

Command

Purpose

MD
(or MKDIR)

Create a new directory or subdirectory

RD
(or RMDIR)

Remove (or delete) a directory or subdirectory

CD
(or CHDIR)

Change from the current working directory to another directory

DELTREE

Erases a directory, including any files or subdirectories it may contain.

DIR

List the contents of the current working directory

Because working with directories is central to what DOS does, all of these (except DELTREE) are Internal commands, contained within COMMAND.COM, and therefore loaded into RAM and ready for your use whenever you boot, including from a boot disk. You will note that the first three commands have two versions, a two-letter shorter name and a longer name. There is no real difference in use, so I will use the short form consistently in the presentation.

MD

This command creates a new directory or subdirectory. (Actually, since the root is the main directory, all directories are subdirectories. So I will refer to subdirectories in all of the following.) Optional argument is the PATH, but if no PATH is included, the subdirectory will be created in the current working subdirectory

Example:

C:\>md letters

This would create the subdirectory C:\letters

With a path included, you can create a subdirectory anywhere.

C:\>md c:\letters\love

If you are in a different working subdirectory:

C:\letters\>md love

This would have the same effect as the previous example. Since we were already in the C:\letters subdirectory as our current working subdirectory, we can leave out the path information since this is where we want the subdirectory created.

Limitations: The length of a PATH specification cannot exceed 63 characters, including backslashes.

RD

This command removes a subdirectory. The subdirectory must be empty. If it contains files and/or subdirectories, you will get an error message. This also has an optional PATH argument, and has the same syntax as MD. Note that you cannot remove the current working subdirectory. To do this, CD to the parent subdirectory first, then remove the undesired subdirectory.

The RD command can sometimes be a little confusing because of the safeguards that DOS builds into the command. The idea that you cannot delete a subdirectory that has contents, for instance, is a safety measure. (DELTREE gets around this, but is a dangerous command for precisely that reason.) How can you tell if a subdirectory is empty? By using the DIR command to display its contents.

 

CD

This command changes the current working subdirectory to another subdirectory. Imagine a computer with the following directory structure:

c:\
   \letters\
              \love\
              \business\
   \memos\
              \school\
              \Internet\

Right now you are in the working subdirectory C:\letters\love\. If you want to change to c:\letters\business\, you need to specify the path:

c:\letters\love\>cd c:\letters\business

If, however, you were in the working directory C:\letters\, you would not need to use the path since the default is to go "downwards":

c:\letters\> cd business

You can also use shortcuts:

cd \ will take you back to the root directory from wherever you are.

cd .. will take you the parent subdirectory of the current working subdirectory. So in the first example, you could also go in a two-step process:

c:\letters\love\>cd ..

c:\letters\> cd business

cd . will not do anything, but it is a valid command. The single dot means the current working subdirectory, which is where you already are.<g>

DELTREE

This command was added later as an external command. It will delete an entire subdirectory "tree", i.e. a subdirectory, plus all of the files it contains, plus all of the subdirectories it contains, and all of the files they contain, etc., all in one easy command. This makes it a dangerous command, because it can wipe out so much stuff so easily. It even ignores file attributes, so you can wipe out hidden, read-only, and system files without knowing it. You can even wipe out multiple trees by specifying them in the command:

C:\>deltree c:\letters c:\memos

This would wipe out both of these subdirectories in one command.

This is one of those commands where you really ought to think twice before you use it. It has its place, definitely. I can reme,ber how tedious it was to first go into each subdirectory, delete the individual files, check each subdirectory for contents, delete each subdirectory one at a time, then jump up one level and repeat the process. DELTREE is a great timesaver when you need it. But I would never use it for ordinary maintenance because one false move can do so much damage.

DIR

This command display the contents of a subdirectory, but it also can function like a search command, which many people do not realize. This is one of the most used commands in all of DOS, and learning to use it properly is a great time saver.

DIR will display the contents of the current working subdirectory, or with an optional PATH argument it will display the contents of some other subdirectory. The real power of the DIR command comes with all of the optional switches available to you. You can display files in a variety of formats, for instance:

 

 

 

 

 

 

 

 

 

 

 

Switch

Purpose

/p

Will pause the screen when a full screen's worth of information has been displayed. You will see "Press any key to continue...", and press of a key will display one more screen. Great for searching those long lists.

/w

Will display the file names and subdirectory names in several columns (i.e. wide), but without any other details.

/b

Bare format, displays file names only, without any other information.

In a future lesson, we will explore the intricacies of using the DIR command with all of the options available.

 

DOS Lesson 11

DOS Wildcards; File Attributes

For this lesson we are going to fill in a couple of concepts that we will need before we go further with directories.

Wildcards

Wildcards are characters that can be used to stand-in for unknown characters in file names. In card games, a wildcard is a card that can match up with any other cards. In DOS, wildcard characters can match up with any character that is allowable in a file name. There are two wildcards in DOS:

* = matches up with any combination of allowable characters

? = matches up with any single allowable character

Of course, since these two characters are used for wildcards, they are not allowable in filenames themselves. A filename like myfile?.txt would not be allowed. If you tried to create a file with this name you would get an error message "Bad file name." But wildcards are very useful in any DOS command which uses a filename as an argument (which is most DOS commands, come to think of it.)

The apostrophe character, *, can stand in for any number of characters. Some examples of this command:

c:\>del *.doc

This command would delete every file with the doc extension from the root directory of C: . So files like myfile.doc, testfile.doc, and 123.doc would all be deleted.

C:\>copy ab*.txt a:

This command would copy every file that began with ab, and had an extension of txt, to the floppy drive A: . So files like abstract.txt, abalone.txt, and abba.txt would all be copied.

C:\temp\>del *.*

This is the fastest way to clean out a directory. This command will delete every file in the directory C:\temp\. The first apostrophe covers every filename, and the second one covers every extension.

The question mark wildcard, ?, stands in for any single character. Some examples of this command:

C:\>del ?.doc

This command would only delete files that had a single character filename and a doc extension from the root directory. So a file like a.doc or 1.doc is history, but a file like io.doc is perfectly safe, since it has two characters.

C:\>copy ab?.txt a:

This command would copy any file with a three-letter name, of which the first two letters were ab, and with a txt extension, to the floppy drive A: . So files like abz.txt and ab2.txt would be copied.

You can combine these wildcards in any command as well.

C:\temp\>del *ab?.do?

This command would be very selective. It would look in the temp directory for files that had anywhere from 1 to 5 beginning characters, followed by ab followed by one character, and which had an extension of do followed by any one character. It would then delete any such files as matched. Examples of matching files would be itab3.dox, mearabt.doq, and 123abc.doc. But the file allabon.doc would not be deleted because it does not match. It has two characters following the letters ab in the filename, and the command specified one character in that position.

Attributes

Every file in DOS has four attributes. These are:

As we saw in lesson 9, each file has an entry in the directory, and in that entry there are four bits, one each for the four attributes. These attributes are turned on if the bit is set to 1, and turned off if it is set to 0.

The Read-only attribute, if it is set to on, will let you read the contents of a file, but you cannot modify it in any way. If you turn the read-only attribute off, you can modify, delte, or move the file.

The Archive bit is set on when a file is first created, and then set off when the file has been backed-up by a good backup software program. If the file is ever modified, the archive bit is turned back on. That way, the software that does the backup can look at the archive bit on each file to determine if it needs to be backed up.

The System attribute is used to mark a file as a system file. In earlier versions of DOS, files marked "system" were completely off-limits without specialized utilities, but now the attribute serves mostly as a warning.

The Hidden attribute is used to prevent a file from being seen by other commands. If you try to clean out a subdirectory (such as by using the DEL *.* command), then try and remove the subdirectory, and then get an error that the subdirectory is not empty, you have a hidden file in there that was not deleted, even with the wildcards.

You can view the attributes for any file by using the DOS command ATTRIB. If you run the command without any arguments, you will get a listing of all the attributes that are turned on for every file in the subdirectory:

C:\temp\>attrib

This will give you a list of the files in the C:\temp\ subdirectory, for every attribute that is turned on you will see a letter (A for archive, S for system, H for hidden, and R for read-only) at the beginning of the line.

You can also look at the attributes for any one file by including that filename (with an optional path) as an argument in the command:

C:\temp\>attrib myfile.txt

C:\temp\>attrib c:\docs\123.doc

And you can change the attributes for any file by making the following arguments in the command:

C:\temp\> attrib -h hidfile.txt

The file hidfile.txt will now be visible to other DOS commands.

You can chain these together if you wish:

C:\temp\>attrib -h -r myfile.txt

This will both reveal the file myfile.txt and make it editable and deletable.

With the two concepts of wildcards and attributes, we are ready for the next lesson, which will make us experts in using the DIR command.

 

DOS Lesson 12

Expert DIR Use

In previous lessons we looked at some of the commands used to manipulate directories, and at the DOS Wildcards and File Attributes. In this lesson we put some of these pieces together and learn how to use the DIR command like an expert.

DIR with Wildcards

The DIR command is generally used to get a listing of all of the files in given subdirectory. But it can do more. If the DIR command is given without any arguments, it returns a list of all files in the subdirectory. But with a few arguments it becomes a search tool that works much like the Windows Find tool. For instance, you can use wildcards to search for a file that matches certain characters:

C:\>dir *.doc

This command would return a list of all the files in the root directory with the DOC extension.

C:\>dir memo?.*

This command would return a list of all files in the root directory with names that begin with MEMO, have one additional character following in the name, and have any extension at all.

You can use all of the DOS Wildcards we discussed in the last lesson to find specific files. This can be very handy in a large directory to check for files, or to make sure before using a DEL command with wildcards that you know exactly what you are deleting. Remember that DOS does not have a Recycle Bin, so when you delete a file it may very well be unrecoverable. (There are DOS utilities to "undelete" a file, but they are uncertain. Better to not make a mistake in the first place.)

DIR with Attributes

You can also use the DIR command with an Attribute argument to find files that match the attribute selected. The syntax for this is the DIR command, followed by a space, then /A:, which signals an attribute argument, followed by the specific attribute(s) you want to search for. You can enter as many attributes as you like in order, without leaving a space between them. There are 10 attributes you can specify:

·          h = hidden

·         -h = not hidden

·          s  = system

·         -s  = not system

·          a  = archivable files

·         -a  = already archived files

·           r  = read-only files

·         - r  = not read-only (i.e. editable and deletable) files

·           d  = directories only, no files

·         - d  = files only, no directories

So, if you wanted to find all the files you not yet backed up, you would use a command like this:

C:\>dir /a:a

Every file in the root directory with the archive bit set "on" would be returned by this command.

C:\docs\>dir /a:-ar

This would return every file in the C:\DOCS subdirectory that was read-only and already backed up. If you know about Boolean operators, what happens when you use multiple attributes is that the command is interpreted as a logical "AND" command, which means that every file returned has to satisfy all of the attribute specifications.

C:\temp\>dir /a:h

This would return every file in the C:\TEMP subdirectory that was marked hidden. Interestingly, if you used a simple DIR command, no hidden files would be displayed. But if you use the command shown above, they are displayed for you quite plainly. Marking a file as hidden in DOS is not a lot of security, in other words. Don't rely on it that way.

Sometimes, particularly in the root directory, you may need to look for the subdirectories you have established. If you use a simple DIR command, you will be presented with several screens of files and subdirectories all mixed up. But you can do this:

C:\>dir /a:d

This command will return only the subdirectories from the root directory, without displaying any of the files in the root directory.

DIR in Order

You can also display the results of your DIR command in order. The syntax for this is very similar to using attributes. You leave a space after the DIR command, or a space after any other switches, and enter "/O:", followed by a selection, to put things in order. Here you have 12 possible options

So, if you wanted to see your directory results grouped by file extension, you might want to try:

C:\>dir /o:e

This will return a list of files put in alphabetical order of file extension. So all the *.DOC files will come before all of the *.EXE files, and they will come before all of the *.TXT files.

But if you are looking for that file you were working on yesterday:

C:\>dir /o:-d

This will return a list of files with the most recent ones at the top of the list.

If you need to clean up your hard drive because you are running out of space:

C:\>dir /o:-s

This will return a list of files with the largest ones at the top of the list.

 

 

DIR with Multiple Arguments

You can use multiple arguments in a DIR command to achieve fairly complex results. Remember that each argument has to be separated from its neighbors by a blank space on each side.

C:\>dir /a:a /o:d /p

This command would select only those files that have not yet been backed up (/a:a), display them in order by date, beginning with the oldest (/o:d), and display the results on your monitor one page at a time (/p).

So you can really do some slick stuff with the DIR command once you master the use of these arguments and switches. In case you were wondering, anything that modifies a command is an argument. If it has a slash in front, it is a switch. So all switches are also arguments, but some arguments (e.g. path) are not switches.

Try out some of these. The best way to get comfortable with these commands is to practice using them.

 

DOS Lesson 13

The EDIT Applet

The EDIT program that comes with DOS looks like another external DOS command, but in this case it is more appropriate to call it an Applet. An applet is the name given to a small, limited application. In this case, EDIT is an ASCII text editor. It is a handy application, composed of EDIT.COM (the application itself), and EDIT.HLP, which contains all of the Help files. Also, EDIT is a BASIC program, so you need to have QBASIC.EXE available as well if you want to run it. This is not a problem if you are running EDIT from a hard drive where you have installed DOS, but if you want to run it from a floppy disk, such as an emergency utilities disk, you need to remember to place QBASIC.EXE on the same floppy as EDIT.COM.

Why use EDIT?

EDIT is a very basic text editor. You would not use it for writing a novel, or for desktop publishing. But it is a very handy little program for two major uses in DOS. The first is for editing DOS configuration files. The two files most commonly edited this way are CONFIG.SYS and AUTOEXEC.BAT. The second common use for EDIT is to create or edit batch files. Batch files are files that contain DOS commands which are executed in order whenever the batch file is run. We will cover both of these topics in future installments, but first it is useful to learn a little about the tool we will be using.

How to use EDIT

From the command prompt, simply type the command EDIT.

c:\>edit

This will open EDIT, and you will see a screen that says "Welcome to the MS-DOS Editor." Under this is an option that says <Press Enter to see the Survival Guide>. This brings up a one screen summary of how to get around in EDIT. It turns out that this involves some keyboard commands that carry over to Windows as well, so learning this can pay dividends in the future. Someday you may actually need to know how to navigate Windows without a mouse, and knowing these keyboard equivalents will pay off.

On top of your screen is the Menu Bar. This has the following Menus, which should be familiar to anyone who has used Windows, since the menus are very similar. You have File, Edit, Search, Options, and Help. Pressing the ALT key activates the Menu Bar. The first letter of each menu is now shown in White to indicate the "hot" letter you can use to activate that menu. The FILE menu is already highlighted in a black box. If you hit "enter", that menu will open down. If any menu choice is highlighted, you can hit enter to select that menu choice. You can use the arrow buttons. The down and up arrows move up and down within a menu, and the right and left arrows move from one menu to the next. Note that each menu has many options that also have "hot" letters, or some other keyboard shortcut. "Hot" letters work by holding down the ALT key while pressing that letter. So, if you are working on a file, and want to check the HELP system, you just hold down the ALT key and press "H", and that menu will open. In Windows, it works just the same, except there the "hot" letters are underlined.

If you look at the bottom of the screen you see some other keyboard shortcuts. The first one is also for the Help system, which you can get to by pressing F1. That is not two keys, but refers instead to the "function keys" at the top of the keyboard. Pressing F1 for help is another semi-standard in the Windows world. Not all programs follow this practice, but most do. So if you are ever at a loss in any program, press F1 and see what happens.

At this point, you know at least three ways to get to the Help system, and two ways to get to any menu option. With a little practice you can get around quite easily in EDIT.

If you open the EDIT application as we did above, you will see that you are working on an "Untitled" document. The moment you save the document (ALT+F, S), you will see the title change to the name of your document. The SAVE dialog window allows you to create the name. (Be sure that it is no more than 8 characters, and no more than 3 letters for the extension. This is DOS!) You can also choose whixch directory or drive you want to save it to, and once you have everything right you need to select OK (or if you change your mind, select Cancel). To navigate from one element to the next on this screen, you use the TAB key.

You can also include a file name as an argument in the EDIT command. If the file already exists, EDIT will open that file. If it does not already exist, EDIT assumes you are creating a new file with this name, and opens a blank screen ready for you to start typing.

EDIT's capabilities

EDIT is a fairly primitive application, but it does have some good basic capabilities. From the Edit menu, you can do Cut, Copy, and Paste in your files. And from the Search menu you can Find a text string, and even Change it to something else when you find it. In the Options menu you will find that you can the default color scheme, in case white text on a blue background disagrees with you.

EDIT with a mouse

It is possible to use a mouse with EDIT. Remember, though, that is DOS, and in DOS you have to load the mouse driver yourself before you can use a mouse. In many of the cases where you will want to use EDIT you will not have a mouse driver installed, and I have therefore focused on using a keyboard. In the long run, you will be happier mastering keyboard navigation, and using the ALT key, the arrow keys, and the TAB key will become second nature. And if you ever do find yourself trying to navigate in Windows with a mouse, these skills come in handy. Many times I have seen people completely stymied by a situation where a program window has somehow moved to the point where all of the control buttons are "off" the screen. So there is nothing for the mouse to click on. I sit at the keyboard, hit a few keys , and everyone says "How did you do that?" Definitely cool.

 

 

DOS Lesson 15

Introduction to Batch Files

A batch file is a file that contains a number of DOS commands, each of which could be run individually from the command prompt. By putting them into a batch file, they can be run as a group by simply running the batch file. Note that the commands execute in the order they appear in the batch file, and that anything that causes a command to halt will also halt the batch file.

You create a batch file by using an ASCII text editor, such as DOS EDIT, or Windows Notepad. When you have created the batch file, you save it with a file name, and give it the extension *.bat. Note that you must not use a name that is the same as any DOS commands or any other program or utility you are likely to run. If you use a DOS command name, trying to run your batch file will not work because the DOS command will execute first. If your name matches some other program or utility, you may never be able to run that program again because your batch file will run before the program runs. So pick something that is not likely to match any command name or program file name.

Virtually all internal and external commands can be used in a batch file. The few exceptions are the commands that are intended only for configuration which are used in the CONFIG.SYS file. Examples of these include BUFFERS, COUNTRY, DEVICE, etc.

When you create a batch file, you are beginning to write a program, essentially. DOS batch files may not have the power of a structured programming language, but they can be very handy for handling quick tasks. Because this is a form of programming, let us begin with learning some good habits. The number one good habit for any programmer to learn is to put comments in the program that explain what the program is doing. This is a very good thing to do, but you need to be careful not to fool the operating system into trying to "execute" your comments. The way to avoid this is to place REM (short for Remark) at the beginning of a comment line. The OS will then ignore that line entirely when it executes the program, but anyone who looks at the "source code" in the batch file can read your comments and understand what it is doing. This is also a way to temporarily disable a command without deleting it. Just open your batch file for editing, and place the REM at the beginning of the line you want to disable. When you want to re-enable that command, just open the file for editing and remove the REM and the command will resume functioning. This technique is sometimes referred to "remarking out" or "commenting out" a command.

Batch files to save time

About 7 or 8 years ago, I was at a technology conference for college professors, and at the end of the conference we needed to quickly make about 40 floppy disks, each with an identical set of about 15 files. There are various ways of doing this, such as using DISKCOPY or COPY commands, but I wanted to do this as quickly and efficiently as possible. So I sat down at the computer, which was running DOS, and quickly copied the 15 files into a temporary directory on the hard drive. I could have then opened EDIT, but to be even faster I entered it directly from the console as follows:

C:>\copy con 1.bat

copy c:\temp\*.* a:

^Z

          1 file(s) copied

Let's go through this to see what I did. The first line says to "copy" from the "console" and store it in a file called "1.bat". The console in this case means the keyboard, sort of. It is just taking whatever I type and entering it into a file.

The second line is the single command in my batch file. It copies all of the files in the directory C:\Temp to the floppy disk in the A: drive.

The third line is holding the Control key while typing "Z", called a Control-Z. This is the End-of-file marker, and tells the OS I am through entering text into this file.

The fourth line is not anything I typed. It is the OS responding to me that it had copied my file.

I could then view this file, either using the TYPE command or by opening it in EDIT, and I would see the single line "copy c:\temp\*.* a:". If I opened it in EDIT I could then add more commands or whatever I wanted to do with it. But in this case I didn't want to do anything else.

Once I had created this file, all I had to do was feed in a floppy, hit the "1" key, then the ENTER key, and the batch file would copy everything. As soon as one disk had received its contents, pop it out, put in a fresh disk, hit the "1" key, then ENTER, etc. I had the 40 floppy disks done in not much more than 10 minutes. In this case, I used the batch file to automate a repetitive process and save me some keystrokes.

 

 

Batch files to automate tasks

Another use for a batch file is to clear out your temporary directories. This trick works great in Windows, which uses batch files just like DOS. Create a batch file like this:

del C:\Temp\*.*

del C:\Windows\Temp\*.*

With these two commands, you can clean out two directories that might otherwise gradually accumulate a lot of temporary files. Create the batch file, and stick a shortcut to it in your Startup folder, and these directories will be cleaned out automatically every time you boot Windows. If you want to be a little more conservative, and you worry that you might delete something important, alter your commands like this:

del C:\Temp\*.tmp

del C:\Windows\Temp\*.tmp

Now you will only delete files with the *.tmp extension, and by definition those files are safe to delete.

DOS Lesson 16

Practicing Batch Files with ECHO

In the last lesson, we introduced the idea of batch files. But to really learn about them, you should practice creating some batch files. Please note that you can generally get similar results using the command prompt window in your version of Windows, but I am using DOS 6.22 commands here, and I test and run all of my batch files on a computer running DOS 6.22. It is possible that some small difference in versions may affect your results, and I have not tested these on every platform in existence.

Temporary directory

I suggest that you create a temporary directory on your machine just for playing around with these batch files. It is a bad habit to save these things in the root directory. First, you may not remember which files are your test files and which are vital system files, and later delete something important by mistake. Second, the root directory, like all directories, can only hold a limited number of files, so you don't want to use up slots with this stuff. Third, if you need to find one of them, it is a lot easier if they are all in their own area. I call mine c:\dostemp\, which I will assume for this lesson

 

 

ECHO

The echo command controls what gets shown on the screen when you run a batch file. You can use the echo command to stop the display, or to make something display, as you wish. For instance, here is a simple one line batch file:

echo Hello people, how is life in the carbon world?

If you create this file and run it, you will see the sentence displayed on the screen. Try creating this file as test1.bat in your temporary directory.

This can be useful when you want to display some piece of text. For instance, in many DOS installation programs, you would see something on the screen that told you to wait while the installation program was doing something. Or, in a networked environment you could display a login message.

Another use of the ECHO command has to do with the way that batch files normally execute. A batch file just executes DOS files in order, much the same as if you were at the keyboard typing in each command. Well, if you were at the keyboard, you would see each of the commands you typed. Try creating the following file, which is called test2.bat:

copy test1.bat test1a.bat

When you execute this file, you should see, first, your command itself, running in your current working directory, followed by the computer reply that a file was copied.

C:\DOSTEMP\>copy test1.bat test1a.bat

1 file(s) copied

Now, seeing this displayed on the screen may not bother you, but there are times when you don't want to see it, or you don't want others to see what is in the file (such as in a login script). You can use the ECHO command to stop that. So edit your test2.bat file to add the following line, which should be the very first line in your file:

echo off

Now, run test2.bat again, you will see that the command is no longer displayed on the screen. However, the first line, ECHO OFF, is displayed. You can stop this by using the @ symbol at the beginning of the first line:

@echo off

The @ symbol can be used at the beginning of any line to stop the display of that line in the batch file. This may sound similar to the REM command, but there is a big difference. The REM command stops the line from being executed, but the @ symbol still executes the line, it just stops the display.

In most batch files, it makes more sense to turn off the display of all commands, so you usually see the @ symbol used only in the very first line to turn off the display of the ECHO command.

What if you wanted to display a blank line? You might think that the ECHO command all by itself, with nothing after it, would do the trick, but you would be wrong in that case. The ECHO command by itself asks the computer to respond whether ECHO is on or off, so you will get "ECHO is off" displayed on the screen. The way to get a blank line is to use a + sign immediately after the ECHO: ECHO+

Stupid DOS Tricks

While the ECHO command is intended primarily for use within batch files, it can be used within DOS. A practical joke you could pull on someone in the DOS days was to get to their computer while they were at the old water cooler, and type the command "echo off" at the DOS prompt. It would have the effect of turning off the display of the DOS prompt. Since only the very geekiest of geeks had ever seen anything like this, it drove most people crazy.

 

Meanings

  1. Kernel:

It is the part of the operating system that loads first, and it remains in main memory. Because it stays in memory, it is important for the kernel to be as small as possible while still providing all the essential services required by other parts of the operating system and applications. Typically, the kernel is responsible for memory management, process and task management, and disk management.

  1. Shell

The outermost layer of a program. Shell is another term for user interface. Operating systems and applications sometimes provide an alternative shell to make interaction with the program easier. For example, if the application is usually command driven, the shell might be a menu-driven system that translates the user's selections into the appropriate commands.

  1. File Allocation Table(FAT)

A table that the operating system uses to locate files on a disk. Due to fragmentation, a file may be divided into many sections that are scattered around the disk. The FAT keeps track of all these pieces.

In DOS systems, FATs are stored just after the boot sector.

The FAT system for older versions of Windows 95 is called FAT16, and the one for new versions of Windows 95 and Windows 98 is called FAT32.

4.       Tracks and Sectors

 The smallest unit that can be accessed on a disk. When a disk undergoes a low-level format, it is divided into tracks and sectors. The tracks are concentric circles around the disk and the sectors are segments within each circle. For example, a formatted disk might have 40 tracks, with each track divided into 10 sectors. The operating system and disk drive keep tabs on where information is stored on the disk by noting its track and sector number.

5.       Clusters 

A group of disk sectors. The operating system assigns a unique number to each cluster and then keeps track of files according to which clusters they use.

 

Hosted by www.Geocities.ws

1