|
DOS 101
(specifically MS-DOS however it may relate other versions of DOS)
by Ian Rochat (ianr@rnrtech.com)
Introduction
This article is here to help those that want to learn DOS or learn how to get around on a
computer running DOS.
DOS is a command-line Operating System. If you are on a DOS system, you know by now that
it sure doesn't look like Windows 95 or GNOME. Instead of a fancy looking graphical
interface where you can use your mouse to click on icons and such, instead you just have
a black screen, with a prompt on it. DOS is not a multi-tasking system, it can only perform one
task at a time however it will generally seem much faster than a system that allows you to perform
many tasks at once (such as Windows or GNOME). Instead of using your mouse, you must type in commands
on the keyboard. A command is just a combination of letters (or numbers) which let's the
computer know what you would like to do. Each command is followed by the Enter (or Return)
key.
DOS is NOT case sensitive. This means that typing an uppercase 'A' is the same as typing a lowercase 'a'.
This of course is not the true if you are in a text editor. But as far as DOS is concered you can type any
commands or program names in all uppercase, all lowercase, or mixed case and it will treat them all the same.
DOS Commands - Quick Reference
Some of the more common commands to use:
(these are built-in commands that most DOS systems should have)
| dir | | Get a directory listing |
| cd | | Change directories |
| md | | Make a directory |
| mkdir | | Make a directory |
| rd | | Remove a directory |
| rmdir | | Remove a directory |
| ren | | Renames a file from one name to another |
| copy | | Creates an exact copy of a file |
| del | | Deletes a file |
| path | | Shows your search path |
| ver | | Displays the version of DOS you are using |
| type | | Display the contents of a file (will scroll off the screen if it's larger than a screen) |
Other useful commands:
(these are not built in, so they may not work if you are working off of a floppy disk or an old version of DOS)
| xcopy | | Creates exact copies many files at a time |
| move | | Moves a file from one place to another |
| deltree | | Deletes an entire directory and all of it's subdirectories and files. |
| edit | | Edits a text file |
File names
In DOS file names are a maximum of 8 characters plus an extension of 3 characters (11 characters total).
Filenames are extensions are seperated by a period '.' (or as some say "dot") for display purposes. A quick
way to refered to this is 8.3, from here on I will use the term 8.3 or 8.3 format to describe an 8 character
filename with a 3 character extension. Filenames in DOS do not retain case. In otherwords you cannot have a
file with a name of "Test.txt" and another one with the name "test.txt", in DOS that would be the same file.
Notes on windows version of DOS:
If you are using a windows version of DOS you can actually use longer filenames, however the long file names
are kept in a translation table by windows, they are still actually stored in the 8.3 format. So you will
notice lots of weird looking filenames. The 8.3 format of files with long filenames will have the same first
six characters of the long filename followed by a ~1, if there are no other long filenames with the same
first six characters, and will have the same first 3 characters of the extension. For example the long
filename 'thisisalongfilename.txt' would become 'thisis~1.txt'. If there are more than one file with the
same first six characters in the same directory then each additional file with increase the number after the
tilde '~'. So the second file would have ~2, the 3rd ~3, etc.. For example if there were also a file
called 'thisisanotherfile.txt' in the same directory as the previous file it would become 'thisis~2.txt'.
This allows DOS programs to function by using the standard 8.3 format. However DOS programs may not keep
track of the long filename that windows uses, so a file may lose it's long filename after being used by a
DOS program, text editing programs for example may do this. Also if you are using a windows version of DOS
becareful when you rename or move files if you are using the short filename you may lose the long filename
used by windows.
Programs and batch files
In DOS you may run programs or batch files simply by typing their filename (the extension is optional). The
file must be in the directory you are currently in or in your Search Path (PATH).
There are only 3 extensions that DOS will see as a program or batch file and will actually execute. These
extensions are: '.COM', '.EXE', and '.BAT'.
It can sometimes help to know what these extensions stand for:
COM stands for Command
EXE stands for Executable
BAT stands for Batch
For example if there is a file called 'SAMPLE.EXE' in your current directory you could type 'SAMPLE' to run
the program.
The files themselves are all slightly different, however we won't go into detail. Except I will mention that
COM and EXE files are not readable by human eyes. These will just look like a bunch of garbage if you were
to try to view the files, however the computer understands these files. Batch files (files with the '.BAT'
extension) can be read and written by a human in a text editor. These files just contain a series of commands
to do and/or programs to run. They are very limited in what they can do, they are by no means a way of
programming, but they can help automate running many programs in a row or can simply allow you to use a
shorter name to run a program.
We will not discuss how to write batch files in this article. Perhaps we will write a second article on some
more advanced topics such as writing batch files.
Editing and viewing text files
Most of the later versions of DOS included EDIT. This is a text editing program. To use it just type 'EDIT'
followed by a space and the file to view or edit. If you get a "Bad command or file name" message try typing
'C:\DOS\EDIT' followed by a space and the file to view or edit. If that still doesn't work you may not have
EDIT so you should get it or another text editor from somebody if you can. You can always download a DOS text
editor from Simtel.net or another large download site.
For example to edit or view a file called 'README.TXT' you would type 'EDIT README.TXT'.
Other common extensions
Extensions are generally used to tell what type of file something is. However other than the 3 extensions
mentioned above DOS really doesn't care what the contents of a file are. So nobody has to follow any
particular way of naming files so you may not get what you expect on occasion.
Generally the only other types of files somebody cares about are text files (or documents). As far as plain
text goes the file should usually have a '.TXT' extension so you know you can open it with a text editor. If
a program was written for DOS there is a good chance that text files (or documents) that come with the program
may be in plain text but may have an extension of '.DOC'. This use to be a common way to signify that a file
was a text document (like an instruction manual) which could be opened in a text editor. However since then
MicroSoft has decided to use a '.DOC' extension for it's files which are NOT just plain text. So if you open
a '.DOC' file and it has text with a bunch of garbage intermixed with it, it is probably a MicroSoft Word
file and not a text file which of course means you need MicroSoft Word to read it.
You may try to open other files if you feel the need, however '.TXT' and '.DOC' will cover most DOS text
files. You may run into files such as 'README.1ST' or other clever names which are generally text as well.
Start-up files (AUTOEXEC.BAT and CONFIG.SYS)
There are two files which your computer will read when DOS starts up.
First it will read the file CONFIG.SYS off of the drive you are booting up on (if it's a floppy disk this
generally A:\CONFIG.SYS and a hard drive is generally C:\CONFIG.SYS). This file contains statements which
tell DOS what memory manager and what device drivers to use. This is NOT a batch file.
And next it will run the file AUTOEXEC.BAT from the same directory as CONFIG.SYS. This is a batch file (as
the extension shows you) and it consists of programs to run when DOS starts up. It will also set any
environment variables, these will not be discussed in this article, but just know some programs may depend on
certain environment variables which they should set up (or tell you how) when you install the program.
There is one environment variable which we will discuss in this article; the PATH variable.
Search Path
In your AUTOEXEC.BAT file there should be a line which sets up the environment variable 'PATH'. This is the
search path that DOS will use to search for a program if you try to run one that is not found in the current
directory. This will make life MUCH easier on you. Instead of having to remember where all your programs
are located you can just type the program name from any directory and it will run the program if it is in a
directory in the search path.
To set the search or add to it you need to edit your AUTOEXEC.BAT file. In it you should find a line (or
create one) which as "SET PATH=" followed by some directory names. It may also just be "PATH=", however if
you are creating this line yourself (since there isn't one) add a new line to the file and use "SET PATH=".
The rest of the line is a list of directories separated by semi-colons ';'. Add any directories you would
like here, they should be the full path and directory, and separate them with semi-colons ';'. Generally
your SET PATH statement will atleast look like:
SET PATH=C:\DOS
I usually have a directory called UTILS (directly off of C:\) where I put most of my commonly used utilities.
So I would want to add that to the path, by adding that to the end of the SET PATH statement, like so:
SET PATH=C:\DOS;C:\UTILS
Of course if you make changes to AUTOEXEC.BAT be sure and save the changes. You will have to reboot (or run
AUTOEXEC.BAT) before your new PATH will get set. With the last path statment I showed you, if I tried to run
a program by typing 'UNZIP' on my system now it would first search the current directory for a program or
batch file called UNZIP then it would search the search path.
Search path, search order example:
First DOS would look in the current directory for:
UNZIP.COM
UNZIP.EXE
UNZIP.BAT
If it was not found DOS would then look for:
C:\DOS\UNZIP.COM
C:\DOS\UNZIP.EXE
C:\DOS\UNZIP.BAT
If it was not found DOS would then check for:
C:\UTILS\UNZIP.COM
C:\UTILS\UNZIP.EXE
C:\UTILS\UNZIP.BAT
If it was still not found it would display the error "Bad command or file name". If it were found at any
point along the way, DOS would run the first one it came across.
Some Questions & Answers
Q: What does DOS stand for?
A: Well, if you must know it stands for Disk Operating System.
Q: I'm still totally confused, what should I do?
A: Find a DOS manual at your local used book store or second-hand store for a few dollars.
|