Understanding and Getting Around in DOS

(Disk Operating System)

Course Description

This course is intended for novice computer users or computer users who have succeeded somehow in avoiding the Disk Operating System. The primary goal is to familiarize the learner with the operating system concepts and functions so that the learner can more efficiently learn and work on their own DOS machines.

Introduction

Before we take a look at the DOS operating system in particular, let's consider what computing is all about. A computer is a tool to accomplish a particular task, such as producing a letter or report, calculating a formula, or communicating with a colleague.

Consider the office in which you work. There is likely to be a workspace (desk), storage space (filing cabinets, drawers, etc.), and tools (pencils, pens, rulers, calculators, etc.). The layout of the room and the laws of physics (thank you, Newton) dictate how we can accomplish tasks within this office. If we want to work on a file, we must go to a drawer, pull on the drawer to open it, open the folder where the document is, grab the document, go to the desk...you get the idea.

On a computer, how you work is defined not by the laws of physics, but by the rules dictated by your computer's hardware and software. The software aspect of those rules is what we call an operating system. So in effect, the programmer (actually a series of teams of many programmers and designers) has created a new environment for working. In order to to do something in that environment, you must follow the rules of this new environment. In the physical world, we must follow Newton's laws in order to accomplish any task. Likewise on a computer, we must follow the programmer's laws; the only difference is that Newton did not decide what these rules would be!

The basic functions of an operating system are as follows:

Many of you may be familiar with a particular application (e.g., WordPerfect 5.1). The description of an operating system may seem similar to what WordPerfect or any application provides: You have to follow its rules in order to do anything in that application. That is definitely true; but when the programmers of WordPerfect developed WordPerfect, they had to conform to the rules of DOS. To extend our analogy, WordPerfect is much like a sport. The rules of baseball are laid out and must be followed in order to succeed in the game, but those constructing the rules of baseball had very much in mind the laws of physics (whether they were conscious of it or not). Likewise WordPerfect must follow the rules of DOS in order to function.


Table of Contents


The Environment

The environment provided by DOS is not a pretty one. Its purpose is to give the user quick and direct access to the basic utility of the computer and little else, a carry-over from the days when the abilities/limitations of the computer dictated how the user interfaced with it. All tasks are accomplished by typing in commands at a command prompt (at the cursor). This is not to say, however, that the command prompt interface doesn't have its advantages.

Usually, users or network adminstrators alter their system so that the user does not have to deal with this command line interface. An example of this is the menu system provided by CCSO at all of its computer lab sites. But it is this kind of menu system that can prevent the user from becoming comfortable with DOS itself.

In DOS and other command-prompt interfaces, it is easy to become disoriented. Unlike your office, in which you know where you are because of the physical things you see and feel, the computer environment is organized around your work, your files. Therefore, any sense of "where you are" is going to be a sense of where you are with respect to the files on your disk.

The Command Prompt

So if we take a look at the computer screen, we are likely to see a blank screen with the exception of a few lines, at least one of which begins with a capital letter followed by a colon and a backslash and ends with a greater-than symbol (>):
C:\>
Any line in DOS that begins like this is (or was) a command prompt. (The actual character that symbolizes the prompt is the greater-than symbol: ">".) This line prompt is the main way users know where they are in DOS. Here is how:

  • The C: tells the user that he/she is working within the filespace (disk storage) on the hard drive given the designation C. C is usually reserved for the internal hard disk of a PC.

  • The backslash (\) represents a level in the hierarchy of the file structure. There is always at least one because it represents the root directory, the very first level of your hard disk.
n a graphical representation of the file structure below, you can see how a file can be stored in different levels on a hard disk. In DOS, the same file, SAMPLE, is represented this way:
Folder icons represent a directory, and the document icons represent actual files in those directories.C:\DEMO\DOS&WIN\SAMPLES\SAMPLE
or, to mimic a graphic representation,

   C:\
     DEMO\
        DOS&WIN\
           SAMPLES\
               SAMPLE

So what C:\DEMO\DOS&WIN\SAMPLES\SAMPLE means is that the file SAMPLE is on the internal hard disk, four levels deep (inside several nested directories). The list of directories (\DEMO\DOS&WIN\SAMPLES\) is referred to as a pathname (following the path of directories will get you to the file). The name of the file itself (SAMPLE) is referred to as the filename.

Directory

If you need more help in orienting yourself, it sometimes helps to take a look at the files and directories available where you are by using the DIR command (short for directory).
C:\>dir
This will give you a listing of all the files and directories contained in the current directory in addition to some information about the directory itself. You will see the word volume in this information. Volume is simply another word for a disk that the computer has access to. Your hard disk is a volume, your floppy disk is a volume, a server disk (hard disk served over a network) is a volume. Now you know fancy words for all the parts of the format DOS uses to represent a file.
Volume: C:
Pathname: \DEMO\DOS&WIN\SAMPLES\
Filename: SAMPLE
Here are some helpful extensions of the DIR command:

  • C:\>dir | more
    (will display the directory one screen at a time with a < more> promptÑ--use control-C to escape)

  • C:\>dir /w
    (wide: will display the directory in columns across the screen)

  • C:\>dir /a
    (all: will display the directory including hidden files and directories)

Now that we have a grasp on where we are in DOS and how to find out, let's take a look at how we manage the files.

Return to the Table of Contents


File Management

Before we get started with perhaps the most fundamental aspect of the operating system, file management, let's make sure we are at the root directory, a sort of home base.

Many commands in the DOS environment follow a certain format. In order to tell DOS to perform a function, at the command prompt, you would type the command followed by arguments which specify what you want DOS to do. For example:

C:\>copy practice.txt a:
"COPY" is the command that you want DOS to perform. "PRACTICE.TXT A: " is an example of an argument which specifies what will be affected by the command. In this case, DOS will copy the file practice.txt from the C: drive to the A: drive. Commands such as edit, del, rename, and many other commands require arguments similar to the example listed above. You will see more examples of these arguments throughout this documentation.

Change Directory

To move to a different directory, use the command "cd" (for "change directory") followed by the directory you wish to move to. The backslash by itself always represents the root directory.
C:\>cd \
Now let's create a file. At this point it is important to mention that DOS requires that filenames be no longer than eight characters with the option of a three character extension for descriptive purposes. Also, no spaces or slashes are acceptable. Again, some of this harkens back to the limitations of earlier days. Since it is going to be a simple text file, let's call our file "practice.txt".
  • C:\> edit practice.txt
  • Type your name or some other message.
  • Then press the Alt key, followed by the f key to display the File menu.(You can also use the mouse.) Press [ALT] + [F]
  • Then press the s key to save the file. Press [S]
  • To exit, press the Alt key, followed by the f key followed by the x key. Press [ALT] + [F] + [X]

If we take a look at the root directory, the PRACTICE.TXT file will be included.


C:\dir

 Volume in drive C is TC_PC
 Volume Serial Number is 1843-17E5
 Directory of C:\

SYSTMP       <DIR>   07-07-94   3:03P
PRACTICE TXT          07-07-94   3:39P
DOS sees the new file as C:\PRACTICE.TXT.

Make Directory

Now, let's make a couple of directories so we can put our file away in a place that makes sense to us. The command for making a directory is "md" (for "make directory") and is followed by the name of the directory you wish to make.
  • C:\> md dosclass
    (to make the directory DOSCLASS)
  • C:\> dir
    (to view the directory with the new DOSCLASS subdirectory)
  • C:\> cd dosclass
    (to change to the DOSCLASS directory)
  • C:\DOSCLASS> md samples
    (to make the directory "samples" inside the DOSCLASS directory)
  • C:\DOSCLASS> dir
    (to view the directory with the new SAMPLES subdirectory)

Note that as soon as we changed our directory, (cd dosclass) the prompt changed to represent the new directory.

Remember, if you want to get your bearings, you can take a look at the command prompt or display a directory list of the current directory (dir).

Copy

Now that we have created the directories, we can put the practice file we created into the new directory, SAMPLES (C:\DOSCLASS\SAMPLES).

To keep things simple, let's "cd" back to the root directory where the practice file is.

C:\>cd \
And now let's copy that file to the SAMPLES directory which is inside the DOSCLASS directory. In order to copy something, you must first issue the command (copy), then identify the file to be copied (source), and then the directory to which you wish to copy the file (destination).
C:\>copy practice.txt dosclass\samples
A somewhat unfriendly yet useful diagram of the command format would look something like this (where things in brackets are optional).
copy [volume+pathname+]filename [volume+pathname+]directory
What this means is that you don't have to include the volume and pathname of the source file and the destination directory (we didn't in the first example). This is because DOS assumes that any filename or directory included in the copy command is in the current directory. Because we had moved to the root directory, both PRACTICE.TXT and DOSCLASS were in the current directory.

But the nice thing about command-line interfaces is that you don't have to be in the directory of the files you wish to act on. The command-line interface makes it possible for the user to use one command to copy any file anywhere to any other location. From any directory (within volume C:), we could have used the following command to copy the same file to the same directory:

C:\DOSCLASS>copy \practice.txt \dosclass\samples
This command would perform the same function as the first command. We just told the computer where to find the source file since it wasn't in the current directory by placing a backslash in front of the filenames (which told the computer that the file was in the root directory). This applies to copies between volumes as well. All you have to do is specify the volume:
Z:\ANYWHERE>copy c:\practice.txt c:\dosclass\samples
or, a very common and useful example:
C:\>copy practice.txt a:\backup\dosclass
This command copied the file to a floppy disk in the PC's floppy drive (which already had the directories, BACKUP\DOSCLASS).

Delete and Undelete

There is a slight problem now. The PRACTICE.TXT file was copied into the SAMPLES directory, but there is no reason to have two copies of PRACTICE.TXT. To delete a file, use the DEL command (from "delete") followed by the name of the file.
C:\>del practice.txt
Again, you can delete the file from any directory by including the full pathname.
Z:\>del c:\practice.txt
If you accidentally delete something, there is a possibility of retrieving it using the "undelete" command. This, however, will only work for files just deleted.
C:\undelete
A list of any files that can be undeleted will appear. You will need to replace the first character of the file because DOS removes the first letter of a deleted file (that's how it keeps track of what can be written over).

Rename

Like the above commands, you needn't be in the same directory as the file you wish to rename provided you include the pathname of the file you wish to change. But the second argument of this command, the new filename, will not accept a pathname designation. In other words, the second argument should just be a filename (with no pathname):
C:\>ren \dosclass\samples\practice.txt prac.txt
Note: Being able to designate a new path would in effect allow the user to move a file from one place to another without having to copy and delete. A common complaint about DOS is that there is no "move" command. Therefore, the only way to move files from one location to another is first to copy them and then to delete the originals.

Extras

Parent directory (..)
If you wish to move up one level in the hierarchy of the file structure (change to the parent directory), there is a shortcut--two consecutive periods: ".."
C:\DOSCLASS\SAMPLES>cd ..
This works in a pathname as well:
C:\DOSCLASS\SAMPLES>ren ..\practice.txt prac.txt
If the file PRACTICE.TXT were in the directory above SAMPLES (the DOSCLASS directory), the above command would change it to PRAC.TXT.

F3
The F3 function key can be a time saver if you're prone to typos. Pressing the F3 button will retype the last command for you.

Breaking
Sometimes, you may start a procedure such as a long directory listing and wish to stop before it is completed. The Break command often works when running batch files and other executable files. To stop a procedure, press [CTRL] + [BREAK]. [CTRL] is located in the lower right-hand corner of the keyboard. [BREAK] is located in the upper right hand corner of the keyboard and is also labeled [PAUSE].

Wildcards (*) and (?)
Another benefit of the command-prompt interface is the ability to use wildcards. If you want, for example, to copy only files with the .txt extension, you employ a wildcard:

C:\>copy *.txt a:\backup\txtfiles
This command would copy all of the files with the .txt extension onto a floppy disk inside the TXTFILES directory which is inside the BACKUP directory. To copy all files from the C drive to the A drive, you would type:
C:\>copy *.* a:
The wildcard is often used when retrieving a directory of similarly named files such as:
C:\>dir *.txt
This command would display all files ending with the .txt extension. To list all files that begin with the letter g, you would type the following:
C:\>dir g*.*
Additionally the ? can be used to substitute for individual letters. If there are many similarly named files that end with the letters GOP but begin with letters A through G, then you can type the following to list those files:
C:\>dir ?gop.*
The following command would list all similar files beginning with the letters REP and ending with A.
C:\>dir rep?a.*
The ? wildcard can be used to replace any letter in any part of the filename.

Wildcards such as * and ? can be useful when you do not know the full name of a file or files and wish to list them separately from the main directory listing.

Return to the Table of Contents


Working with the Files

Understanding how to manage your files on your disk is not the same as being able to use them, thought it's a start. If you've ever taken a look inside a folder of a freshly installed commercial package (such as WordPerfect), you'll have seen a large number of files with many different kinds of extensions. It can be rather daunting.

But, to DOS (and most operating systems), there are only two kinds of files, binary files and text files (ASCII). Text files are basic files that can be read or viewed very easily. Binary files, on the other hand, are not easily viewed. As a matter of fact, most binary files are not to be viewed but to be executed (like a full program such as WordPerfect or simple commands such as "copy"). When you try to view these binary files (such as with a text editor), your screen is filled with garbage and you may even hear beeps.

While there are only two kinds of files, it is often difficult to know which kind a particular file is. For files can have any extension! Fortunately, there is a small set of extensions that have standard meanings:
Text Binary
.txt .exe
.bat com
.dat

Executing

Binary files ending in .exe are usually "executed" by typing the filename as if it were a command. The following command would execute the WordPerfect application which appears on the disk directory as WP.EXE:
C:\APPS\WP51>wp
Binary files ending in .com often contain one or more commands for execution either through the command prompt or through some program.

Viewing

Text files, on the other hand can be viewed quickly with the type command:
C:\>cd dosclass\samples
C:\DOSCLASS\SAMPLES>type practice.txt | more

Editing

Or you can view the file in the provided text editor (just as we did when we first created practice.txt):
C:\DOSCLASS\SAMPLES>edit practice.txt

Printing

If you want to send a text file to the printer, there is the print command. But there are two steps:
C:\DOSCLASSES\SAMPLES>print practice.txt
Name of list device [PRN]: lpt2
If you wish to print to a networked printer, usually lpt2 is the correct response. For local printers, the correct response is usually lpt1.

Return to the Table of Contents


Configuration

As mentioned earlier, many PC users/administrators design menu-driven interfaces to the most used applications allowing the user to avoid dealing with the command-prompt. Further, there are many ways to make DOS look and feel the way you want it to--to a degree of course. Unfortunately, such modification includes a bit of editing of files and is not within the scope of this course.

It is important, however, to have one thing set right if you're trying to get comfortable with DOS. In the AUTOEXEC.BAT file on your PC, if it isn't there already, you will want to have the following line included so that your prompt includes the current directory:

prompt $p$g
The AUTOEXEC.BAT file can be edited to include this command by using the EDIT command which was discussed earlier in the documentation. Batch files are text files that contain a series of DOS commands that will be executed in order as listed in the file. You can create batch files that will perform a wide variety of commands. For example, to list a directory page by page, we would normally type:
C:\>dir | more
Instead, if you are used to using the "ls" command on UNIX, you can create a new batch file named LS which will perform the directory command instead of "dir".

Now, when you press [D] + [ENTER], the operating system will run the D.BAT batch file which in turn will provide a page by page directory.

Return to the Table of Contents


Coded by The AIM Lab
August 6, 1995