كلية هندسة االلكترونيات
قسم هندسة النظم والسيطرة
المرحلة األولى
Computer Science Lab
MS-DOS Commands
2
Learning MS-DOS Basics
In this lab, you will learn the following:
View the contents of a directory
Change from one directory to another
Create and delete directories
Change from one drive to another
Clearing the MS-Dos screen
The Command Prompt
To enter to the MS-DOS screen choose Run then type cmd, you'll see the following:
C:\Users\
your computer name
>
This is called the command prompt or DOS prompt. The flashing underscore
next to the command prompt is called the cursor. The cursor shows where the
command you type will appear.
Typing a Command
This section explains how to type a command at the command prompt and demonstrates
the "Bad command or file name" message.
• To type a command at the command prompt
1.
Type the following at the command prompt (you can type the
command in either uppercase or lowercase letters):
nal
If you make a typing mistake, press the BACKSPACE key to
erase the mistake, and then try again.
2. Press ENTER.
You must press ENTER after every command you type. The following
message appears:
Is not recognized as an internal or external command
3
The "
not recognized command " message appears when you type
something that MS-DOS does not recognize.
3. To display the MS-Dos version, type the following command:
Ver
The following message appears on your screen:
MS-DOS version 6.22
Viewing the Contents of a Directory
In this section, you will view the contents of a directory by using
the dir command. The dir command stands for "directory."
• To view the contents of a directory
Type the following at the command prompt:
dir
A list similar to the following appears:
Volume in drive C is MS-DOS_6.22
Volume Serial Number is lE49-15E2
Directory of C:\
WIND
OWS
<DI
R>
09-08-92 10:27p
TEMP
<DI
R>
05-15-92 12:09p
CONF
IG
SYS
278 09-23-92 10:50a
COMMAN
D COM
53014 09-18-92 6:00a
WINA
20
386
9349 11-11-91 5:00a
DOS
<DI
R>
09-02-92 4:23p
AUTOEXE
C BAT
290 09-23-92 10:54a
7 file(s) 62931 bytes
8732672
bytes free
This is called a directory list. A directory list is a list of all the
files and subdirectories that a directory contains. In this case, you
4
see all the files and directories in the main or root directory of
your drive. All the files and directories on your drive are stored
in the root directory.
Changing Directories
Look at the list on your screen. All the names that have <DIR>
beside them are directories. You can see a list of the files in
another directory by changing to that directory, and then using
the dir command again. In this case, you will change to the DOS
directory.
Before you begin in this section, make sure you have a directory named DOS
by carrying out the following procedure.
o To make sure you have a directory named Windows
If you do not see a line in the directory list indicating that you
have a directory named Windows, type the following at the
command prompt:
dir /s Windows
You will see a message that includes a line such as the following:
Directory of C:\DIRNAME
o To change from the root directory to the WINDOWS directory
To change directories, you will use the cd command. The cd
command stands for "change directory."
- Type the following command:
cd windows
The command prompt changes. It should now look like the
following:
C:\WINDOWS>
5
Next, you will use the dir command to view a list of the files in the
DOS directory.
o To view a list of the files in the WINDOWS directory
- Type the following command:
dir
A list of the files in the WINDOWS directory appears, but scrolls
by too quickly to read. You can modify the dir command so that it
displays only one screen of information at a time.
o To view the contents of a directory one screen at a time
- Type the following at the command prompt:
dir /p
One screen of information appears. At the bottom of the screen, you
will see the following message:
Press any key to continue . . .
o To view the contents of a directory in wide format
-
Type the following at the command prompt:
dir /w
The directory list appears, with the filenames listed in wide
format. Note that only filenames are listed. No information
about the files' size or date and time of creation appears.
Changing Back to the Root Directory
Next, you will change from the DOS directory to the root directory.
The root directory is the directory you were in before you changed to
the DOS directory. Before you begin this section, make sure your
command prompt looks like the following:
C:\DOS>
6
o To change to the root directory
- Type the following command:
cd \
Note that the slash you type in this command is a backslash (\),
not a forward slash (/).
No matter which directory you are in, this command always
returns you to the root directory of a drive. The root directory
does not have a name. It is simply referred to by a backslash (\).
The command prompt should now look like the following:
C:\>
When your command prompt appears similar to this---that is,
when it does not contain the name of a directory---you are in the
root directory.
Creating a Directory
In this section, you will create two directories. Creating a
directory is helpful if you want to organize related files into
groups to make them easy to find. Before you begin this
section, make sure the command prompt looks like the
following:
C:\>
To create a directory, you will use the md command. The
md command stands for "make directory."
o To create and change to a directory named FRUIT
1. Type the following command:
md fruit
You have now created a directory named FRUIT. You won't
see the new FRUIT directory until you carry out the dir
command in the next step.
7
2. To confirm that you successfully created the FRUIT directory,
type the following at the command prompt:
dir
or
dir /p
Look through the directory list. A new entry somewhere in the
list should look similar to the following:
FRUIT <DIR> 09-25-93 12:09p
3. To change to the new FRUIT directory, type the
following at the command prompt:
cd fruit
The command prompt should now look like the following:
C:\FRUIT>
You will now create a directory within the FRUIT directory, named
GRAPES.
To create and work with a directory named GRAPES
1.
Type the following command:
md grapes
You will not see the new GRAPES directory until you carry out the
dir command in the next step.
2.
To confirm that you successfully created the GRAPES directory,
type the following at the command prompt:
dir
The GRAPES directory is a subdirectory of the FRUIT directory. A
subdirectory is a directory within another directory. Subdirectories are
useful if you want to further subdivide information.
8
3.
To change to the GRAPES directory, type the following at the
command prompt:
cd grapes
The command prompt should now look like the following:
C:\FRUIT\GRAPES>
4. To switch back to the FRUIT directory, type the following:
cd ..
The command prompt should now look like the following:
C:\FRUIT>
Deleting a Directory
If you no longer use a particular directory, you may want to delete it to
simplify your directory structure. Deleting a directory is also useful if you
type the wrong name when you are creating a directory and you want to
delete the incorrect directory before creating a new one.
In this section, you will delete the GRAPES directory. Before you begin in
this section, make sure the command prompt looks like the following:
C:\FRUIT>
To delete a directory, use the rd command. The rd command stands for
"remove directory."
o To delete the GRAPES directory
1.
Type the following command:
rd grapes
2. To confirm that you successfully deleted the GRAPES directory,
type the following at the command prompt:
dir
The GRAPES directory should no longer appear in the directory list.
9
Note You cannot delete a directory if you are in it. Before you can
delete a directory, you must make the directory that is one level higher
the current directory. To do this, type cd.. at the command prompt.
Changing Drives
This section describes how to change drives. Changing drives is useful if you
want to work with files that are on a different drive.
So far, you have been working with drive C. You have other drives you can
use to store information. For example, drive D is your hard disk drive.
Before you begin this section, make sure your command prompt looks like
the following:
C:\FRUIT>
o To change to and view files on a different drive
1.
Type the following command:
D:
Note that the command prompt changed to the following:
D:\>
2. Change back to drive C by typing the following at the
command prompt:
C:
Your command prompt should return to the following:
C:\FRUIT>
When you type a drive letter followed by a colon, you change to that
drive. The drive letter that appears in the command prompt shows
which drive is the current drive. Unless you specify otherwise, any
commands you type are carried out on the current drive and in the
current directory.
So far, all the commands you typed were carried out on the current drive and
in the current directory.
10
Clearing the MS-Dos Screen
To clear the MS-Dos screen use the following command prompt:
C:\ cls
The screen now should appears clear.