How to Use the Command Prompt


What is DOS and MSDOS? You've probably seen DOS in action many times already and not even realized it. When you first boot, (or start), your computer you've probably noticed a screen like the one below. This is your computer's DOS program. DOS stands for "Disk Operating System." MSDOS stands for "MicroSoft Disk Operating System." There isn't a lot of difference between DOS and MSDOS. MSDOS is simply Microsoft's version of DOS. FreeDOS, OpenDOS, and PC DOS, are three other versions of DOS.

Before Windows and the other popular GUI (or Graphical User Interface) operating systems, people HAD to use a program like DOS to work with their computer. Things were not as pretty or friendly then. We can simply click on a few pictures, (or icons), and copy a disk or open a folder now. Things were a little more difficult before this. You had to type in each command in order to get your computer to do what you wanted. If you forgot a command you were in trouble. So why even have DOS now anyway? We don't need it anymore with the power of Windows... Or do we?


What would happen if Windows "crashed" and you couldn't reboot, (or restart), your computer? If every time you tried it simply wouldn't let you? The fact is that this CAN and DOES actually happen. When it does, someone with a basic understanding of DOS can most likely fix things and get you back up and running in no time. You see with DOS, even though it isn't as user friendly, it's MUCH more damage resistant. When Windows runs home to mommy after losing a file or something, leaving you stranded with a computer that doesn't start, DOS can come to your rescue. You don't have to worry about DOS leaving you either because DOS can even be used on a floppy disk to get your computer started. This disk is known as a "boot disk." You should always have a DOS boot disk handy just in case of an emergency. If you don't have a boot disk, I'd start by making one right now! While we're at it, let's do it with DOS.


Before we begin PLEASE get your parent's permission to do this next part. If you don't think they'll want you doing this just skip over it and go on to the next paragraph. We're going to have to format a floppy disk and we DON'T want to format the c: drive by mistake! If we do, Windows and everything else on your computer's hard drive is going to be ERASED! So please ask your parents to follow along with you. Windows shouldn't let you format the c: drive while Windows is running, but we don't want to take any chances. Make sure you follow each step carefully. The picture below is what will happen on your screen as you go through the steps that follow. Look it over carefully.


If you're ready, place a blank 3.5" floppy disk in your computer's a: drive. Click the "Start" button on your task bar. Next click on "Run..." The "Run" dialog box appears. Type in "command" (or "cmd" with Windows NT and 2000) without the quotes and click "OK". A DOS screen should now appear. Your cursor should be at the command prompt. Type "a:" without the quotes and hit enter. This should change the DOS directory to your a: drive. You should see a "A:\>" with your cursor blinking beside it. Make SURE it doesn't say "C:\>" Now type "format a: /s" without the quotes and hit enter. What this does is formats the floppy in your a: drive and copies the necessary system files to it at the same time. Your computer needs these files to boot properly. Without them you'd get a "No OS found" error, (OS means "Operating System"), or something similar if you tried to use that disk to boot, preventing you from starting your computer. After several seconds you'll be prompted for a label. Just hit enter for "NONE." A read out on how things went will appear. Next you'll be asked if you want to format another disk. Just type "n" for no, without the quotes and hit enter. Next type "exit" without the quotes and the DOS screen will magically disappear. :-) CONGRATULATIONS! You've successfully used DOS to create your very first boot disk.


One thing I should point out is that the boot disk we just created is a minimal command boot disk. It will allow you to boot your computer and do certain things, but DOS depends on other commands to help it work. For example, to format a drive like we just did DOS needs a "helper" command called "" The ".com" extension stands for "command." The icons shown below are some of the "helper" commands available. In order to have all of the necessary DOS commands available when an emergency arises, it's very important to have the actual "Startup Disk" Windows provides. If for some reason you don't have one you can make one.

In Windows 95, 98, and ME go to "My Computer" then "Control Panel" then "Add Remove Programs." When the Window appears, Click on the third tab at the top that says "Startup Disk." From there you can make the full Startup Disk needed when you experience problems with Windows. In Windows XP make sure you have a 3.5" floppy disk in the a: drive. Go to "My Computer" and "Right Click" on the a: drive icon. Click on "Format." When the "Format" menu appears put a check in the "Create an MS-DOS Startup Disk" box. Click "Ok." A warning will appear that you are about to erase everything on the a: drive. Click "Ok." This creates the Startup Disk for Windows XP. The Windows XP Startup Disk is quite limited.

One problem using DOS with Windows XP, NT, and 2000 is that these operating systems normally use a different file system called NTFS. NTFS is NOT compatible with DOS unless you use a special helper program to view and work with NTFS files. Without the helper program DOS can not "see" anything on an NTFS formatted drive. You will still be able to boot your computer with a boot disk, but you will not be able to work with or see any of the existing files on your hard drive.


Now that you're a little more familiar with DOS, let's talk about a few commands and how to use them. First, let's open DOS like we did earlier. If you like, often you can find DOS by looking under "Programs" on the "Start" menu. Look for a program called "MS-DOS Prompt" or "cmd." Once you have DOS running, type "dir" without the quotes and hit enter. Whooa! What was all of that? The "dir," (or directory), command displays everything in a directory. You were most likely in the Windows directory. That's why there were so many files.

Now type "dir | more" without the quotes and hit enter. The "|" key is often found above the "\" and looks like a straight up stick with a small break in the middle. Using the "| more" switch you can display one screen at a time, allowing you to see everything in those long directory lists. (The "/p" switch will also display a page at a time.)

Now type "dir /?" without the quotes and hit enter. This is the help screen for the "dir" command. It gives you several optional switches that can be used with the "dir" command. Anytime you are unsure of a switch or parameter you can type the name of the command followed by a space and then type "/?" to receive any available help and/or options for a command. The screen below should look similar to the one you just saw on your computer.


Let's try using one of the switches from the above help file. Type "dir /o:n /b" without the quotes and hit enter. Notice now that the only thing listed is the files. Notice also that now everything is listed in alphabetical order. This is because we used the "/o" switch telling DOS that we wanted to change the "sortorder." We added the ":n" to tell DOS to list the files by "name" in alphabetic order. We also added the "/b" to tell DOS that the sortorder we wanted to see was the "bare format" that doesn't list all of the details.

Look at the picture above. Near the top under "C:\Windows>dir /?" you can see the definition of the "DIR" command. It tells us what the "dir" command does. (Displays a list of files and subdirectories in a directory). Right below the definition of DIR you can see the name of the command (DIR). Beside it is the format of using options with this command. Everything you see inside of brackets is optional. This means you don't have to include it unless you want to. Notice that with "[/O[[:]sortorder]]" the ":" was inside of brackets. In other words, before when we typed "dir /o:n /b" we could have just typed "dir /on /b" leaving the colon out. If you'll also notice "[[:]sortorder]]" is inside its own brackets. We don't even have to type a "sortorder" in. We could just type "/o /b" or "/o" or even no switches at all since all of these are inside of brackets.

Notice that immediately after the "DIR" in the picture above "[drive:]" is listed. If we wanted to check a floppy disk in the "a:" drive, we could type "dir a:" to list files on the floppy disk. Typing "dir" by itself simply displays the directory you're currently in and lists everything with "default" parameters. (Default meaning the "normal" information it's programmed to show us if we don't ask for anything else.) About midway down the picture you'll notice the "/O" switch listed. Beside that it tells us what this switch does. (List by files in sorted order). Right under that is the word "sortorder" and beside it is the different "sortorders." Notice that beside the "N" it says "By Name (alphabetic)." Further down the screen you'll see the "/B" switch. Beside it is its definition as well. (Uses bare format (no heading information or summary).) After you have a pretty good understanding of the help screen, we'll do a few other things with DOS.


Type "cd .." without the quotes and hit enter. (cd means "change directory") (".." tells it to go "up" one directory) If you were in the "C:\WINDOWS>" directory before, now you will be in the "C:\>" directory. If you don't see the "C:\>" prompt keep typing "cd .." and hitting enter until you do, or it says "Invalid directory." The reason it will say "Invalid directory" is because you can only "back out" so far. The "C:" drive is where all of the directories start. It's the "root" directory.

Now let's make our own directory. Type "md myfolder" without the quotes and hit enter. (md means "make directory") Now type "dir | more" without the quotes and hit enter. You should see your new directory listed on the right with " < DIR > " out to the side of it. Now to get into your new folder, (or directory), type "cd myfolder" without the quotes and hit enter. You're now in your very first DOS created folder!

Type "notepad.exe" without the quotes and hit enter. DOS will locate the Windows Notepad program and open it for you. Type something in and save it to your folder. Let's make two copies while we're at it. Save one as "untitled.txt" and another as "trash.txt". To save it to this folder, just locate the folder with Notepad by clicking on "File" at the top, then "Save As..." then beside "Save in" click the arrow and find the "C:" drive and double click on your folder named "myfolder." Name your file by typing in the name beside "File name:" and click the "Save" button. Close Notepad and go back to the DOS screen after you've saved your two files. Type "dir" and you should see your text files listed. They're called "UNTITLED TXT" and "TRASH TXT" unless you named them something else.

Now type "edit untitled.txt" without the quotes and hit enter. Your text file should open with the DOS edit program. You should be able to see what you wrote earlier. The "edit" program should look similar to the picture shown above. You can now make some changes to your file and save it so you can check it out later. To "exit" the "edit" program, click on "File" and then "Exit." Now let's get rid of "trash.txt." At the DOS prompt type "del trash.txt" without the quotes and hit enter. (del means "delete") Type "dir" again without the quotes and hit enter. You'll see that "trash.txt" is now gone.

Type "copy untitled.txt c:\" without the quotes and hit enter. You just made a copy of the untitled text file in the main "C:" directory. To see if it worked, type "cd .." without the quotes and hit enter to go up to the "C:" directory. Type "type untitled.txt" without the quotes and hit enter. This time DOS displayed your file directly to the DOS screen. This is because we used the "type" command that displays the contents of text files. If you have a long file, you might want to use the "| more" switch we discussed earlier to display it one screen at a time.


One other thing I'll mention is the use of "wildcards." Let's say you want to only display the text files in a certain directory. If you type "dir *.txt" you'll get a listing of only the text files in that directory. Using the "*" (or "asterix") will include anything up to that point. For example, if you type "dir a*" everything that begins with "a" will be listed. If you type "a*.txt" all the text files beginning with "a" will be listed since the ".txt" specified only text files. When you're through using DOS and feel that you're pretty comfortable with it type "exit" without the quotes and hit enter to close the DOS program.


This lesson should have you feeling a little more comfortable using DOS. There are many commands that I haven't mentioned here, but these will get you started. To find out about other DOS commands, check out some of the links below. Remember that if you're ever unsure of what options are available with a command, try using the "/?" for help. Another VERY important thing to remember is that some DOS commands might mess up your computer if you're not careful. If you're not 100% sure about a certain DOS command don't try using it until you are. Remember that certain commands like "format" can erase your entire hard drive if used improperly. If you need to break out of a command for some reason, hold down "Ctrl" and "Break" at the same time. CONGRATULATIONS! You have just learned how to use another operating system besides Windows!

Other Commands to Try
mode 40Changes screen to 40
characters across
mode 80Changes screen to 80
characters across
clsClears the screen
dateDisplays date and lets
you change it
timeDisplays time and lets
you change it
verShows version of
DOS you have
vol c:Shows c: drive's
volume label
prompt ?What follows prompt
changes the prompt
ping your loopback
ping Yahoo
tracert the route from
your computer to Yahoo
ipconfig /allShows all information about
your network adapters
net configDisplays your workgroup
netstat -rDisplays routing table
netstat -sDisplays per-protocol

DOS Links

EasyDOS Commands

DOS - Webopedia

MS-DOS Help and Commands





Back to Learn