
How do I use the Windows command prompt line?
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
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
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:
![]()
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:
![]()
The second method would be to change the working directory to
![]()
Once you have changed the current directory to
![]() 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.
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon
Categorized:
Windows Help
(Article 9150)
Tagged: command prompt, windows 7, windows command line, windows terminal, windows xp Previous: How do I open and change "control panel" settings in Windows? Next: How do I turn off Windows event sounds? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader. 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. Posted by: Rob Abdul at November 10, 2009 3:34 AMHi Dave, I have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
![]()
Search
Find just the answers you seek from among our 2300+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Industry News and Trade Shows Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Book Links
|