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.
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)
- Type cls to clear the command prompt
- Type ver to view the Windows version you are currently using
- Type dir to view the contents of the directory (folder) you are currently in
- Type cd .. to change directory to the parent (folder above) i.e. from C:\Users\Rich to C:\Users
- 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
- Type cd Public to change to the Public folder
- Type md test to create a “Test” directory in C:\Users\Public (optionally type dir again to view it in the listing)
- Type ren test test2 to rename the test folder to test2
- Type rd test2 to remove the directory you just created and renamed
- 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)
- Type dir to view the contents of the public folder again. Do you see the Bubbles.scr file?
- Type del BubblesCopy.scr to delete the bubbles screensaver from your Public folder
- 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:
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:
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.
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.
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
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:
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:
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 /?
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:
- Use Windows commands to manage your PC and improve productivity
- Correct program associations using the command prompt
- Basic networking commands
- Delete persistent files using the command prompt
- Fix corrupted Windows files using the command prompt
- Use xcopy on the command line to transfer large amounts of data
Customize the Command Prompt
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.