If you still aren't completely
clear on the various commands of DOS, don't worry. You'll be navigating
through DOS in no time!
The dir command
First, open the command prompt; we went over
that on the previous page Introduction to DOS. Once you get to the
command prompt, type in dir and
press enter. You should have seen a whole bunch of text scroll down the page. What dir
does is display all the files and directories that are inside the current directory you are in.
Below is a description of the listing dir generates.
The cd command
Notice that directories are listed with
the word <DIR>. You can change your current directory into any
of the directories listed. To change your current directory, type cd and the
name of the directory you want to change to. Make sure you separate the cd
command and the directory name with a space. This is called giving a command a parameter.
Many commands take parameters that allow for extra functionality and specific data to operate on.
If you are at all unsure about a command, just type the command, a space then /?.
This displays information about the particular command.
If you didn't notice, one of the directories in the
listing is named "..". It's near the top of the listing. This is a common directory
that exists in every single directory on your computer. It stands for the directory directly above
the current one. For example, let's say you were in the C:\WINDOWS\Desktop directory.
Then ".." would refer to the C:\WINDOWS directory. If you were in the C:\WINDOWS
directory then ".." would refer to the C:\ directory. It's all a big hierarchy.
Let's try out the cd command now.
Type cd .. and press enter. This should have changed your directory to the one currently
above it. Do this until you're in the C:\ directory. This is as high as you can go
in the directory hierarchy. Now type cd WINDOWS\Desktop and press enter. Notice you can
skip multiple directories by separating their names with a back-slash. Above, we told the cd
command to change to the WINDOWS directory and from there, change to the Desktop
directory all in one line. Using the cd command is a basic way of life in DOS. It's
your key to navigating through your hard drive, cd-rom, floppy, etc.
The mkdir command
Now let's make our own directory. Make sure you're
in the C:\WINDOWS\Desktop directory. Now type mkdir myfolder and
hit enter. What we just did is create a directory called myfolder inside the Desktop
directory. Now let's change to myfolder.
The edit program
Next we'll make a file to put into our newly created directory.
We can create a basic text file using the edit program. To start it, type
edit and hit enter. The command prompt should have been replaced by a primitive
graphical user interface complete with a menu bar. If you're running DOS in a Window, which is
probably the case, you can use your mouse in this program. This program is not very different from
Notepad. Now type, "Look, I can create stuff in DOS!" or
something like that. Now go to File->Save to open the save screen. Type in a name for
the file you just created such as "myfile.txt" and hit enter. A quick word about file extensions. They
are used to help users and programs understand what the file contains. In this case, "txt" stands
for text. Now exit edit by selecting File->Exit.
The type command
Now if you were to type dir, you'd see the newly
created text file. Pretty cool, huh? Well, what if you wanted to just take a look at the file and not
have to open edit to do it? That's where the type command comes in.
This commands displays the contents of a file to the command prompt. Let's try it out. Type
type myfile.txt or whatever you named your file and hit enter. It should have
printed out the contents of the file to the command prompt.
The copy command
The copy command is a powerful command that allows
you to make a copy of a file with different file name. This command takes two parameters, (remember
that parameters are separated by spaces), the original file name and the new file name. For example,
type copy myfile.txt mycopy.txt and press enter. What this does is takes the contents
of myfile.txt and copies it into another file named mycopy.txt. They are
the exact same except for the file names.
The del command
The del command, possibly one of the most useful and
dangerous commands covered here. This is what you use to delete your files and directories. Why is this
so dangerous? Well when DOS deletes something, it's really gone, for good! There's no recycling bin that
you can magically resurrect your file from. Let's test it out by deleting our copied file. Type
del /p mycopy.txt and press enter. Then it asks if you're sure you want to delete it.
Type Y and press enter to confirm the deletion. Now mycopy.txt is
gone forever. You may be asking, "What's with the '/p'?" Well, that is called a switch. Most commands
have certain switches that, when used, alter the way the command executes. In this case, the /p
tells the del command to prompt the user before each deletion. Remember the /?
parameter that prints out the command's information, well that's a switch. You can find more information
about specific command switches by using the /? switch.
If you want to delete the directory we made in this
tutorial, first change up to the desktop directory. You can't be in the directory you're going to
delete. Now type del myfolder and press enter. If you left a file in the directory,
it should alert that there are files in it. Just type Y, hit enter and you're all cleaned up.
Head on to:
Introduction to DOS
Basic DOS Commands
Redirecting And Piping
Back to Tutorial Menu
Back to Webmaster Main Page
Back To HTML Stuff Main Page