Web Analytics


The Windows Command Prompt

Previously, we asked you if you use the Windows command prompt and many of you answered and stated you do not; for those that do use the command line interface (CLI), many use it infrequently. In this guide, we’ll go through the basics of the command prompt, show you examples of how you can use it, and show you how to customize it.

Familiarize Yourself with the Command Prompt

Before you start using the command prompt, I recommend you learn the basic shortcuts and commands. The first guide, listed below, shows you how to access the command prompt. If you’re familiar with how to get to the command prompt already, you can skip this guide.

Basic Commands

Now you have the command prompt in front of you, let’s go through a series of commands to help you navigate:

Unless you changed your home or working directory, you’ll see you start in your home folder (usually something like C:\Users\Rich)

  1. Type cls to clear the command prompt
  2. Type ver to view the Windows version you are currently using
  3. Type dir to view the contents of the directory (folder) you are currently in
  4. Type cd .. to change directory to the parent (folder above) i.e. from C:\Users\Rich to C:\Users
  5. Press the up arrow twice to list your second from last command (dir) and press Enter. You’ll now be viewing the contents of the C:\Users folder
  6. Type cd Public to change to the Public folder
  7. Type md test to create a “Test” directory in C:\Users\Public (optionally type dir again to view it in the listing)
  8. Type ren test test2 to rename the test folder to test2
  9. Type rd test2 to remove the directory you just created and renamed
  10. Type copy “C:\Windows\System32\Bubbles.scr” BubblesCopy.scr to copy the bubbles screensaver from the Windows directory to your Public directory (note: If you don’t specify a path for the file, the directory you are currently working in is used)
  11. Type dir to view the contents of the public folder again. Do you see the Bubbles.scr file?
  12. Type del BubblesCopy.scr to delete the bubbles screensaver from your Public folder
  13. Type echo All Done! to print “All Done!” on the command line interface

To recap, you used the following commands:

  • cls – Clears the screen so you are left with an empty prompt
  • ver – Show the Windows version
  • dir – List the contents of the directory you’re currently working in
  • cd – Change directory i.e. cd C:\Users\Rich; cd .. etc.
  • md – Create a directory (mkdir also performs the same)
  • ren – Renames a file or directory
  • rd – Remove a directory (rmdir also performs the same)
  • copy – Copies a file from the source to the destination i.e. copy C:\sample.text copied-C:\sample.txt
  • del – Deletes a specified file
  • echo – Echoes the string (text) specified i.e. echo Hello

Add Command Switches

Switches give you a greater degree of control over your commands and give you more options. You can add them after the command to change the behavior of that command.

We used the dir command a number of times in the previous example, let’s look at the available switches. The easiest way to see what’s available is to open a command prompt and type:

dir /?

The /? is a switch that returns the help text and available switches for each command. In this case, you got a response that’s something similar to:

C:\Users\Public>dir /?
Displays a list of files and subdirectories in a directory.

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sortorder]] [/P] [/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

[drive:][path][filename] Specifies drive, directory, and/or files to list.

/A          Displays files with specified attributes.
attributes
D  Directories                R  Read-only files
H  Hidden files               A  Files ready for archiving
S  System files               I  Not content indexed files
L  Reparse Points             –  Prefix meaning not
/B          Uses bare format (no heading information or summary).
/C          Display the thousand separator in file sizes.  This is the default.  Use /-C to disable display of separator.
/D          Same as wide but files are list sorted by column.
/L          Uses lowercase.
/N          New long list format where filenames are on the far right.
/O          List by files in sorted order.
sortorder
N  By name (alphabetic)       S  By size (smallest first)
E  By extension (alphabetic)  D  By date/time (oldest first)
G  Group directories first    –  Prefix to reverse order
/P          Pauses after each screenful of information.
/Q          Display the owner of the file.
/R          Display alternate data streams of the file.
/S          Displays files in specified directory and all subdirectories.
/T          Controls which time field displayed or used for sorting
timefield
C  Creation
A  Last Access
W  Last Written
/W          Uses wide list format.
/X          This displays the short names generated for non-8dot3 file
names.  The format is that of /N with the short name inserted
before the long name. If no short name is present, blanks are
displayed in its place.
/4          Displays four-digit years

Here you see the list of switches you can add to your dir command. Now, in C:\Users (cd C:\Users), type:

dir /W

This displays the contents in “Wide” format, which is particularly helpful if you’re listing out a large directory as you need to scroll less to see all the output.

Let’s try another one:

dir /Q

Now you see the owners of each folder listed. Understanding these switches and knowing how to use them will come with practice and time. Feel free to explore the switches of other commands i.e. del /?

Additional Commands

As you become more familiar with the basic commands, you can add more to your artillery by learning some shortcuts that will save you of time if you come to rely on the command prompt more frequently:

Command Prompt Usage Examples

Once you’re familiar and comfortable with the command prompt, I recommend you try some of the other commands and tools available:

Customize the Command Prompt

console03 Customize the Appearance of the Command Prompt in Windows [How To]

For those that want a custom look with the dated looking command prompt, you are in luck. You can customize the native command prompt’s color scheme or you can use a third party command prompt that provides further customization like transparency:

You can also customize the default working directory when you launch the command prompt. For example, I use my scripts directory:

What else can you do with the command prompt? Are you a beginner and are you struggling to find use for or understanding of the command prompt? Let us know in the comments and we’ll be happy to help.

About Rich

Rich is the owner and creator of Windows Guides; he spends his time breaking things on his PC so he can write how-to guides to fix them.

Free PC tips by email

Search Windows Guides




Comments

3 thoughts on “The Windows Command Prompt—Beginner’s Guide”

  1. InfoDave says:

    This is the 21st century…

    I am an occasional Windows user. I use the CLI to make up for the inadequacies of the GUI:

       ipconfig /all

       msconfig 

    Can anybody else add some USEFUL commands.

    1. Dm Hunt says:

       Press F1 to enter the last command one letter at a time.
       Press F3 to enter the last command totally.

      1. Rich says:

        Thanks Dm Hunt!!

Comments are closed.


Computer tips in your inbox
Sign up for the Windows Guides newsletter to get PC tips and access to free Windows books (More details)

Subscribe now
Popular Guides

See which sites have been visited on your PC (even if private browsing mode is used)

Create a Windows 7 System Repair Disc

Best Free Anti-malware

Hibernate vs. Sleep vs. Shut-Down

i3, i5, and i7; Dual, Quad, Hexa Core Processors. How to they Differ?

Intel's Ivy Bridge Processor: new Features

Windows Guides on Facebook