Now I know how to open
a command prompt in Microsoft Windows, how do I perform common tasks in a command
prompt? Can you show me some command prompt basics and perhaps something cool I can do to impress my friends?
You already know how to
open
a command prompt, which is required in order to run certain commands and prompts in
Windows.
When you think about the Windows command prompt, just imagine that you’re traveling back in time and are working on a computer that was state of the art back in, oh, the early 1990s, maybe, or even a bit earlier. No mouse, no icons to click on, no windows, no pretty pictures. Just text. You type, the computer responds. That’s it.
Here, let me remind you of what it looks like…
Here are some tips and tricks to help you get more comfortable with the command
prompt environment.
First, read how to
copy
and paste in a command prompt window, which was worth a separate article unto itself.
You can’t be comfortable with a Windows utility until you know how to copy and paste with it.
Here’s a simpler trick: Re-entering a command without having to type it again.
Type the command “ipconfig” in a command prompt and you’ll see this
output, which includes your computer’s IP address:
To enter the command “ipconfig” a second time, without having to type the command again,
hit the up-arrow key on your keyboard, and the word “ipconfig” will reappear in the command
prompt.
The command prompt has a memory of all the recent commands that you typed in (up to 50 commands, by
default), so that you can iterate back through your recently entered commands by hitting
the up-arrow key repeatedly. For example, after typing “ipconfig” and hitting Enter, try
typing “ver” and hitting Enter. (You should see
“Microsoft Windows XP [Version 5.1.2600]” or something similar depending on your version
of Windows.) Hit the up-arrow key, and the “ver” command will re-appear since it was
the last command you entered. But hit the up-arrow key again, and the “ipconfig” command
will re-appear. (This buffer of recently-typed commands gets erased when you close the
command prompt, so if you close the command prompt window and open another one, hitting
the up-arrow key will not recall commands that were entered in the previous command
prompt window.)
By default, a new command prompt window opens with a “working directory” of
C:\Documents and Settings\<username>
where <username> is the username that you used to sign in to Windows —
on my Hewlett Packard computer, this is HP_Administrator, as seen in the command
prompt pictures above, where my working directory is
C:\Documents and Settings\HP_Administrator
If your
computer signs you in automatically every time you start it up, you might have forgotten
that you even have a Windows username, but you do have one! (And by the way,
“C:\Documents and Settings\HP_Administrator”
is known to the hard-core old-schoolers
as a directory, although you might know it as a folder.)
Sometimes, in order to run a command that applies to a specific file on
your computer, you need to change your working directory to the directory containing
that file. For example, consider the “tree” command,
which displays a list of all the directories within a directory, and a list of
sub-directories within each of those directories, etc. I want to display
the tree of all subdirectories within the directory
C:\Program Files\Common Files\Adobe\TypeSupport
There are two ways that I can do this. The first way is to enter the full path
to the directory in the command. “C:\Program Files\Common Files\Adobe\TypeSupport”
is the “full path” to the directory. However, if I try entering “tree” followed
by the full path to the directory:
tree C:\Program Files\Common Files\Adobe\TypeSupport
I get an error that doesn’t make much sense:
This is because the command prompt considers whatever comes after the “tree” command
to be the first argument to the tree command — basically, the thing that
the tree command “operates on” — however, it stops reading at the first space, after
the word “Program”. Then it gets confused by the next glob of characters, “Files\Common”.
In order to get the “tree” command to take the entire full path as an argument, we
need to put quote marks around the full path:
tree “C:\Program Files\Common Files\Adobe\TypeSupport”
and this works:
The second method would be to change the working directory to
C:\Program Files\Common Files\Adobe\
before running the command on the directory “TypeSupport”. In a command prompt,
the command to change directories is “cd”, followed by the directory you
want to change to. As before, when entering the full path to the directory
you want to change to, you have to use quote marks so that the entire path is
treated as a single argument:
Once you have changed the current directory to
C:\Program Files\Common Files\Adobe\
you can enter the command:
tree TypeSupport
Because you are already in the “Adobe” directory, the word “TypeSupport”
by itself automatically
refers to the “TypeSupport” directory that is inside the “Adobe”
directory, and so the full path is not needed:
One final note about changing directories using “cd”. If you want to switch
to a directory that begins with a different drive letter — for
example, if your working directory is “C:\Documents and Settings\” but
you want to change to the directory “D:\” — then the “cd” command won’t work:
Instead, to change to a different drive,
just type the drive letter by itself, followed by a colon:
That will switch your working directory to a new drive letter.
And that’s it! With these basics, if you encounter any instructions page telling
you to run a certain command “within a command prompt”, but that doesn’t
explain the basics of navigating inside a command prompt,
these tips will probably take care of 90%
of the situations that you’ll run into.
Bennett Haselton is a technology blogger who will gladly buy you a latte if you
let him talk to you about how to bypass K9
Bluecoat web filters.
Hi Dave,
I want to improve my computer’s performance. How do I check the registry on command prompt?
O how I love the DOS command prompt, the geek that I am.
These days the only use I have for it for looking up a mac address for a wireless card.
ipconfig / all
I’m glad Microsoft has kept the DOS command prompt in all the windows versions for us old school people.