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.
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.
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:
| 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.
C:\>dirThis 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:Here are some helpful extensions of the DIR command:
Pathname: \DEMO\DOS&WIN\SAMPLES\
Filename: SAMPLE
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
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:
If we take a look at the root directory, the PRACTICE.TXT file will be included.
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).
To keep things simple, let's "cd" back to the root directory where the practice file is.
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:
F3
Breaking
Wildcards (*) and (?)
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
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:
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.
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
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:\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
(to make the directory DOSCLASS)
(to view the directory with the new DOSCLASS subdirectory)
(to change to the DOSCLASS directory)
(to make the directory "samples" inside the DOSCLASS directory)
(to view the directory with the new SAMPLES subdirectory)
Copy
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.
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
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
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
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.
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.
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].
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.
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.
| Text | Binary |
|---|---|
| .txt | .exe |
| .bat | com |
| .dat | |
C:\APPS\WP51>wpBinary files ending in .com often contain one or more commands for execution either through the command prompt or through some program.
C:\>cd dosclass\samples
C:\DOSCLASS\SAMPLES>type practice.txt | more
C:\DOSCLASS\SAMPLES>edit practice.txt
C:\DOSCLASSES\SAMPLES>print practice.txtIf you wish to print to a networked printer, usually lpt2 is the correct response. For local printers, the correct response is usually lpt1.
Name of list device [PRN]: lpt2
Return to the Table of Contents
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:
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
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.
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".
Coded by The AIM Lab
August 6, 1995