| Example MS/DOS Commands
In the following examples of
DOS commands the actual words or letters you type are inclosed in brackets
and highlighted in blue. DO
NOT include the brackets [
] in your command.
Command Menu
The Type
Command From time
to time you will have a requirement to look at the contents of a text
file. Normally you would think the only way to do this is to open a word
processor program and view the contents by opening the file.
While this method is valid, there is a way to do the same from the
MS-DOS command level. The TYPE command tells DOS to display the contents
of a text file.
The steps taken below will display the contents of the Autoexec.bat
file.
The Basic Command Looks Like This
- Type [CD\] and press the
[Enter] Key - This step moves you to the root directory.
(see Change Directory Command)
Then Type [Type] - This is the command
word.
Press the [Space Bar] once - Pressing the space
bar once inserts a space between the command and the file that you want
to display.
Type [AUTOEXEC.BAT] - AUTOEXEC.BAT is the
name of the file you want to display the contents of.
Press the [Enter key] - Pressing Enter confirms
the command.
You will see the
contents of the file Autoexec.bat displayed on the screen. (You may have
different commands in your AUTOEXEC.BAT file.) The TYPE command only displays the contents of
a file. You can not edit the file.
Note: Some files (especially program files) contain
characters that DOS cannot display. You may hear beeps and see strange
characters onscreen if you display this type of file. Press CtrlC to stop
the display.
Copy and Rename the
File - (Internal
Command) The copy
command can be used to copy one file to another file with a different
name. (Make a backup copy of the file) The steps taken below will copy a
file and rename the copy to another name.
The Basic Command Looks Like This
- Type[CD\] and press the [Enter] Key - This step moves you to
the root directory. (see Change Directory Command)
- Then Type [Copy] - This is the command word. The
COPY command tells DOS to make a copy of the file.
- Press the[Space Bar] once. - Pressing the space
bar once inserts a space between the command and the file that you want
to copy.
- Type [AUTOEXEC.BAT] - AUTOEXEC.BAT is the name
of the file you want to copy and rename.
- Press the[Space Bar] once
- Type [AUTOEXEC.old] - AUTOEXEC.OLD is the
name you want to assign the copy of the file. This command makes a copy
of the file AUTOEXEC.BAT and names the file AUTOEXEC.OLD.
- Press the [Enter key] - Pressing Enter confirms
the command. You will see the message 1 file(s) copied appear on the screen. Now
you have two versions of the same file. Each has a different name. To
confirm that a copy has been made follow the next step.
- Type [DIR AUTOEXEC.*] and press [Enter]. This command tells
DOS to display all files with the file name AUTOEXEC and with any
extension. You should see both AUTOEXEC.BAT and AUTOEXEC.OLD.
Copy a File To
Another Directory The
copy command is also used to copy files from one directory to another. The
steps taken below will copy a file to another directory area on the hard
disk.
The Basic Command Looks Like This
- Type [CD\] and press the [Enter] Key - This step moves you to
the root directory. (see Change Directory Command)
- Then Type
[Copy]- This is the
command word. The COPY command tells DOS to make a copy of the
file.
- Press the [Space Bar] once - Pressing the space
bar once inserts a space between the command and the file that you want
to copy.
- Type [Autoexec.old] - AUTOEXEC.old is the
name of the file you want to copy.
- Press the [Space Bar] once
- Type [C:\DATA] - Typing C:\DATA tells DOS to
place the copy in the directory C:\DATA. The file will have the same
name.
- Press the [Enter key] - Pressing Enter confirms
the command. You will see the message 1 file(s) copied appear on the screen. Now
you have two versions of the same file: one in the [ROOT] directory and one in the [DATA] directory. Both files have
the same name.
Copy A Group of Files
To Another Directory The copy command is also used to copy a group of files from one
directory to another. The steps taken below will copy a group of batch
(Bat) files to another directory area on the hard disk.
The Basic Command Looks Like This
- Type [CD\] and press the [Enter] Key
This step moves you to
the root directory. (see Change Directory Command)
- Then Type [Copy]
This is the command word.
The COPY command tells DOS to make a copy of the file.
- Press the [Space Bar] once
Pressing the space
bar once inserts a space between the command and the file that you want
to copy.
- Type [*.bat]
The *.bat is the group of
files you want to copy to another directory. notice we are using on of
the wild cards we spoke of before. By using the Asterix we are saying
search for any combination of letters before the period and include them
if the three letters after the period are [bat].
- Press the [Space Bar] once
- Type [C:\DATA]
Typing C:\DATA tells DOS
to place the files in the directory C:\DATA. Be sure to type a directory
name. If the directory does not exist or is typed incorrectly, DOS adds
all the files together and places them in another file.
- Press the [Enter key
Pressing Enter confirms
the command. You will see the message(#) file(s) copied appear on the screen. The
(#) indicates the actual
number of files copied.
Note: Use these same steps to copy a group of
files to another drive and directory. To do so, type the new drive name
instead of C:\data. If you leave off the file name, DOS uses the same name
for the files copied. As an example the command might look like
this:
Copy All Files to a
Different Drive The copy
command is also used to copy all files from one directory to another
drive. The steps taken below will copy all files in the data directory on
the hard disk to another drive called A: Insert a formatted disk in drive
A.
The Basic Command Looks Like This
- From the Root directory
type [CD\batch] and
press the [Enter] Key
This step moves you to the batch Sub-directory. (see Change Directory
Command)
- Then Type [Copy] - This is the command word. The
COPY command tells DOS to make a copy of a file.
- Press the [Space Bar] once - Pressing the space
bar once inserts a space between the command and the file that you want
to copy.
- Type [*.*] - The *.* is used to specify all
files in the directory.
- Press the [Space Bar] once.
- Type [A:] - Typing A: tells DOS to copy all
the files in the directory C:\batch to the A: drive.
- Press the [Enter key] - Pressing Enter confirms
the command. You will see the message (#) file(s) copied appear on the screen. The
(#) indicates the actual number of files copied. Now you have two
versions of each file: one in the original directory (batch) and one on
(drive A.)
To verify the files have been
copied:
- Type [A:] and press the [Enter] key. This step makes drive A: the current
drive.
- Type [DIR] and press the[Enter]
key - This step displays a directory listing of the contents of the
disk in drive A: so that you can verify that the copies were
made.
Rename A
File Lets assume that
you want to change the name of the Autoexec.old file in the C:\data
directory to a name such as (autoexec.cpy). You would use the RENAME
command as described below.
The Basic Command Looks Like This
- Type [CD\ data]and press the [Enter] Key - This step moves you to
the data Sub-directory. (see Change Directory Command)
- Then Type [Ren] - This is the command word. The Rename
command tells DOS to rename a file or directory.
- Press the [Space Bar]once - Pressing the space
bar once inserts a space between the command and the file that you want
to copy.
- Type [Autoexec.old] - Autoexec.old id the name of
the file you want to rename.
- Press the [Space Bar] once.
- Type [Autoexec.cpy] - Autoexec.cpy is the new name
for the file autoexec.old.
- Press the [Enter key]- Pressing Enter confirms
the command. The name autoexec.old is now changed to autoexec.cpy.
Delete a single
File Lets assume that
you want to delete the autoexec.cpy file from the C:\data directory You
would use the Delete command as described below.
The Basic Command Looks Like This
- Type [Del] - This is the command word. The DEL
command tells DOS you want to delete a file.
Note: In earlier
versions of DOS (before Version 4.0) you could spell out the comand
[Delete]
- Press the [Space Bar] once
- Type [Autoexec.cpy] -
Autoexec.cpy is the name of the file you want to delete.
- Press the [Enter key] - Pressing Enter confirms
the command. The name autoexec.cpy is now deleted from the C:\data
sub-directory. To verify,
- Type [DIR] and press [Enter]. This step displays a directory
listing of the subdirectory C:\data so that you can verify that the file
has been deleted.
To delete all files in a
Subdirectory:
- Type the command Delete *.*The wild cards used
here (*.*) specify all files. Be careful with this command, you can end
up deleting file you will need later.
- Press the [Enter] key- Pressing Enter confirms
the command. You will see the message All files in directory will be deleted! Are you sure
(Y/N)? Answer yes by pressing the [Y] key if you want to delete all
files.
Undelete A File
(External
Command) If for some
reason you accidentally delete the wrong file or directory, don't panic.
There is something you can do to retrieve your files. With MS-DOS versions
5, 6, and 6.2 an Undelete command is included. When files are deleted on a
floppy or hard disk only the first letter of the name is removed. the file
is still on the disk until it is written over by another file.
The Basic Command Looks Like
This
- From the root directory
type [CD\ data] and
press the [Enter] Key -
This step moves you to the data Sub-directory. (see Change Directory
Command)
- Type [UNDELETE] and press the [Enter] key. If you are using MS-DOS
version 6.0 or greater, you will see a screen similar to the following:
UNDELETE - Delete
Protection Facility Copyright (C) 1987-1993 Central Point
Software Inc. All Rights
Reserved
Directory: C:\data File Specification:
*.* Delete sentry not found Deletion tracking file not
found MS-DOS directories contain [#} deleted files: Of Those
Files [#] Files May Be Recovered Using the MS-DOS Directory
Method:
?utoexec.cpy
2100 11-13-95 11:46a ...A Undelete
(Y/N)?
| [#] = Number
of Files
- The blue line shows the first
deleted file that MS-DOS found. The file name, extension, size, date,
and time are listed. The first character of the file name is replaced
with a question mark.
- Press the [Enter] Key - The next line will appear
on the screen. It will say
Please type the First Character
of the file ?utoexec.cpy :
- At this point type an [a] and press the [enter] key. -
your file will be undeleted. Press the [esc] key at any time to stop the undelete
program.
Note: If you don't
know the first letter of the file, assign any letter. Then after you see
what the file contains, use the RENAME command to rename the
file.
CAUTION: Once you delete a
file from your disk, you may not be able retrieve it. Although the
UNDELETE command can recover deleted files, it can do so with certainty
only if no other files have been created or changed on the disk. If you
accidentally delete a file that you want to keep, stop what you are
doing and immediately use the UNDELETE command to retrieve the
file.
MS-DOS Undelete
Protection MSDOS
provides three levels of protection against accidental file deletion
- Delete Sentry - Provides the highest level of protection.
Delete Sentry requires a small amount of memory and disk space.
The UNDELETE Command moves the file from its current location to the
SENTRY directory without changing the record of the file's location in
the file allocation table (FAT). If you undelete the file, MSDOS moves
the file back to its original location.
- Delete Tracker - The next level of protection is Delete
Tracker, which requires the same amount of memory as Delete Sentry, but
minimal disk space. It uses a hidden file named PCTRACKER.DEL to record
the location of deleted files.
When you delete a file, MSDOS changes the file allocation table (FAT)
to indicate that the location of the file is now available for another
file.
You can recover the deleted file provided that another file has not
been placed in that location. If another file has been placed there, you
may be able to partially recover the deleted file.
- Standard - The lowest level of protection, standard,
requires neither memory nor disk space, but still allows you to recover
deleted files, provided that their location on the disk has not been
taken by other files. The standard level of protection is automatically
available when you switch on your computer.
Of the three levels of guarding against accidental file deletion, it
provides the lowest level of protection. However, it does not require
you to load a memoryresident program. It also has the advantage of
requiring neither memory nor disk space.
CAUTION: UNDELETE cannot restore a directory that has
been removed, and it cannot retrieve a file if you have removed the
directory that contained the file.
If the directory was an immediate subdirectory of the root directory,
you may be able to retrieve the directory and its files if you first use
the UNFORMAT command to restore the directory and then use UNDELETE to
retrieve the files.
You must use caution because you can lose data if you use UNFORMAT
incorrectly.
Usually, UNFORMAT can restore only immediate sub-directories of the
root directory. However, when you use UNFORMAT to recover an
accidentally formatted disk, UNFORMAT recovers all rootlevel files and
subdirectory names.
Display a Volume Label There are times when you
might need to know what the volume label is on the disk you are working
on.
The Basic Command Looks Like
This
- Type [VOL]. VOL is the volume command. Volume
is another name for drive.
- Press the [ Enter.] key. Pressing Enter confirms the
command. You see the volume label
(which is the volume name) assigned
to the disk. You also see the volume serial number.
Change The Volume
Label
- From the root directory
type [LABEL]. LABEL is the label command. You use this
command to change the volume label for the disk.
- Press the [Enter] key. Pressing Enter confirms the command. You see the volume label
(which is the name) currently assigned to the disk and the volume serial
number. You also see the prompt Volume label (11 characters, ENTER for
none)?
- Type [new name]. where [new name] is the new volume label you want to
use.
- Press the [Enter] key. Pressing Enter confirms the
new volume label.
- Type [VOL] and press [Enter]key. This step verifies that the volume label
has been changed. You see the volume label listed as[ new name.]
CHECK THE DOS VERSION
- Type [VER]. VER is the version command. You use this command to display the
current DOS version.
- Press [Enter]. Pressing Enter confirms the
command. You see the current DOS version number. The After screen shows
the current version as MSDOS Version 6.20. Your version will be
different from the one that appears in the After screen if you use a
different DOS version.
CHECK DISK SPACE
AND MEMORY
- Type [CHKDSK]. CHKDSK is the check disk command. You use this command to
display some basic information about the disk.
- Press [Enter]. Pressing Enter confirms the command. DOS checks the disk and
displays information in three sections. The first section displays the
following information:
- total disk space (in bytes)
- number of hidden files (and number of bytes)
- number of directories (and number of bytes)
- number of user files (and number of bytes)
- number of bad sectors if any (in bytes)
- number of bytes available on disk
Remember that about 1 million bytes equals one megabyte (M). So if
the display shows 1998848, that number would equal about 2M.
The middle section displays information about how space is allocated
(assigned).
The last section displays the following information about memory:
total bytes memory total bytes free.
Remember that roughly 1 thousand bytes equals one kilobyte (K). So if
the display shows 655360, that number would equal about 640K.
SET THE
DATE
- Type [DATE]. DATE is the command that you use to set the date.
- Press [Enter]. Pressing Enter confirms the command. You see the prompt
Current date is, followed by the current date. You also see the
prompt Enter new date (mmddyy):
- Type [ 090494]. This is the new date you want to enter.
- Press [Enter]. Pressing Enter confirms the new date.
SET THE
TIME
- Type [TIME]. TIME is the command that you use
to set and display the time.
- Press [Enter]. Pressing Enter confirms the
command. You see the prompt Current time is, followed by the current time. You
also see the prompt Enter new
time:
- Type [16:00:00]. This is the new time you want
to set.
- Press [Enter]. Pressing Enter confirms the new
time.
SET THE
PATH
- Type [PATH]. PATH is the command that you use
to tell DOS which directories it should search to find programs. If a
directory is listed in the PATH, you don't have to change to that
directory to use a command or start a program.
- Press the [space bar] once. Pressing the space bar
once inserts a space between the command and the path statement.
- Type [C:\DOS]. DOS is the directory that
contains all the DOS program files. Your DOS directory might be named
differently. If so, type that directory name.
- Press [Enter]. Pressing Enter confirms the path.
- Type [PATH] and press [Enter]. This step displays the new path. Notice that
if you set the path this way, the new path overrides the path in the
AUTOEXEC.BAT file. When you restart the computer, however, the
AUTOEXEC.BAT file overrides the path.
Note: To include more than one directory in the path, separate
the directories by a semicolonfor example, C:\DOS;C:\WORD. Don't include
a space between directory names.
CHECK MEMORY
INFORMATION
- Type [MEM]. MEM is the command to check memory
information.
- Press [Enter]. This step executes the command.
Onscreen you see the total amount of memory your computer has, the
amount that is used, and the amount that is free.
Different types of memory are reported: conventional, upper, adapter
RAM/ROM, extended, and expanded. This information might come in handy if
you are calling for support or if a program requires a certain amount of
memory.
The DIR
Command The Command "DIR"
is the directory command. It tells DOS to list all the files in the
current directory. In this example, the current directory is the root (or
main directory). The Basic Command
Looks Like This
DIR
To use the directory
command:
- Type DIR
- At The C:/> Prompt- type [DIR].
- Press
Enter. Pressing Enter confirms the command. You will see a list
of the files and directories in the root directory. (Your list will
vary, depending on the files and directories you have created. You may
not be able to see all of the directories on your screen at the same
time.) Notice that the following information appears on-screen:
- File name - The root of the file name (up to eight
characters) appears first.
- Extension - The extension is listed in the second
column.
- File Size - The next column lists the size of the file.
The size is measured in bytes. One byte equals about one character. If
the entry is a directory, nothing is listed.
- Directory - If the entry is a directory, you see
in the next column.
- Date - The next column displays the date when the file
was created or last modified.
- Time
- The final column displays the time when the file was created
or modified.
Note: The two lines at
the end of the directory listing display the number of files, bytes
taken, and bytes free (disk space remaining).The DOS prompt appears at
the bottom of the listing so that you can type the next command.
|