19 Basic Windows Command Prompt Commands (A Quick Guide)

Welcome to a quick tutorial on the basic Windows command prompt commands. Today, we have the convenience of the graphical user interface (GUI), and most people will shy away from the command line.

Little do people know that the “true hacker stuff” can only be done in the command line… So congratulations on choosing to pick up the command line. Even though we are not going into the “hacker stuff” in the guide, it will still make you look cool enough. Read on!

 

 

QUICK SLIDES

[web_stories_embed url=”https://red-dot-geek.com/web-stories/basic-windows-command-prompt-commands/” title=”Basic Windows Command Prompt Commands” poster=”https://red-dot-geek.com/wp-content/uploads/2022/06/story-cover-640×853.webp” width=”360″ height=”600″ align=”center”]

 

TABLE OF CONTENTS

Getting Started Basic Commands Summary & Links
The End

 

GETTING STARTED WITH THE COMMAND PROMPT

Before we dive into the commands, let us start with the raw basics of “how to open the command prompt” in Windows.

 

HOW TO LAUNCH THE COMMAND PROMPT

  • Press windows + R to open the run window.
  • Type in “cmd” and hit “OK”.

 

A NOTE ABOUT SECURITY

By default, launching the command prompt in Windows 10 will be in “restricted access mode”. That is, you cannot mess with the critical system stuff. If you want the full unrestricted command prompt:

  • Press windows > search for “command prompt”.
  • Right-click on it, and run as administrator.

But beware, this can potentially do irreversible damage if you do not know what you are doing.

 

 

BASIC WINDOWS COMMANDS

Now that you have launched the command line, here are some of the basic commands to know.

 

BASIC NAVIGATION

1) CHANGING THE CURRENT DRIVE

Microsoft Windows [Version 10.0.19044.1706]
(c) Microsoft Corporation. All rights reserved.

C:\Users\W.S. Toh>d:
D:\>e:
E:\>

When the command prompt is launched, all that is staring back is a C:\Users\NAME. This should pretty self-explanatory, it is your “current directory”. That is, the current location is at the C:\ drive, inside the default Users\NAME folder. If you want to change the current directory to another drive, simply enter the drive letter – For example d: or e:.

 

2) LIST CONTENTS OF THE CURRENT DIRECTORY

D:\>dir
 Volume in drive D is DATA
 Volume Serial Number is CATE-DOGE

 Directory of D:\
11/02/2018  03:42 PM    <DIR>          Documents
12/13/2018  10:06 PM    <DIR>          http
12/15/2018  09:11 PM    <DIR>          NetBeans 8.2
06/17/2017  08:53 PM    <DIR>          obs-studio
06/17/2017  02:18 PM    <DIR>          Rainmeter
05/28/2018  01:58 PM    <DIR>          xampp
               0 File(s)              0 bytes
               6 Dir(s)  46,296,956,928 bytes free

To list the contents of the current folder, use the dir command.

 

3) CHANGE THE CURRENT DIRECTORY

D:\>cd http
D:\http>

Next, we have the cd command… Should be Captain Obvious, changes the current directory. There is one trick here – We don’t actually need to type out the full folder name. For the above example, we can just type out cd h and press tab to cycle through the list of folders starting with “h”.

D:\http>cd d:\Documents\eBooks
D:\Documents\eBooks>

Another way to use the cd command is to enter a full file path.

D:\Documents\eBooks>cd..
D:\Documents>

D:\Documents\eBooks>cd/
D:\>

Lastly, use cd.. to go up one level, or cd/ to go all the way back to the root of the current drive.

 

 

4) CLEAR SCREEN

D:\>cls

When the screen gets too messy, use cls to clear the screen.

 

5) LAUNCHING APPLICATIONS

D:\>notepad
D:\>calc

From the command prompt, we can also launch various apps.

 

6) EXIT

D:\>exit

Captain Obvious to the rescue again. Hit exit when done, and this will close the current session.

 

FILE ACTIONS

7) COPYING FILES

D:\http>copy README.txt d:\http\temp
        1 file(s) copied.

To copy a file, simply specify the source file and destination – copy SOURCE DESTINATION.

D:\http>copy *.* d:\http\temp
ALT-dummy.php
ALT-retrieve.php
ALT-stats.php
ALT-store.php
JSON-retrieve.php
JSON-store.php
README.txt
sql-fav-color.sql
sql-people.sql
        9 file(s) copied.

To copy all the files in the current directory, use copy *.* DESTINATION.

 

 

8) X-COPY

D:\http\test>xcopy *.* d:\http\temp /e
D:ALT-dummy.php
D:ALT-retrieve.php
D:ALT-stats.php
D:ALT-store.php
D:JSON-retrieve.php
D:JSON-store.php
D:README.txt
D:sql-fav-color.sql
D:sql-people.sql
9 File(s) copied

Now, the problem with copy is that it only copies files, but not the folders within. So if you want to copy everything, including the folders within, use the slightly more advanced xcopy *.* DESTINATION /e instead.

 

9) MOVING FILES

D:\http\test>move README.txt d:\http\temp
        1 file(s) moved.

D:\http\test>move *.* d:\http\temp
D:\http\test\ALT-dummy.php
D:\http\test\ALT-retrieve.php
D:\http\test\ALT-stats.php
D:\http\test\ALT-store.php
D:\http\test\JSON-retrieve.php
D:\http\test\JSON-store.php
D:\http\test\sql-fav-color.sql
D:\http\test\sql-people.sql
        8 dir(s) moved.

Don’t think this one needs explanation, move is the cousin of copy and the usage is the same – move SOURCE DESTINATION.

 

10) REPLACING FILES AND FOLDERS

D:\http\test>replace READLATER.txt d:\http\temp
Replacing D:\http\temp\READLATER.txt

By default, copy and move will prompt if you want to replace existing files. This can get irritating when moving a large number of files, so use replace SOURCE TARGET if you just want to replace everything.

 

 

11) RENAMING FILES AND FOLDERS

D:\http>ren README.txt READLATER.txt

Self-explanatory, ren FROM TO.

 

12) CREATING A NEW FOLDER

D:\http>mkdir myNewFolder 

 

13) DELETING FILES

D:\http>del READLATER.txt

To delete a single file.

D:\http>del *.*

To delete all the files in the folder.

 

14) REMOVING FOLDERS

D:\http>rmdir myNewFolder /S
myNewFolder, Are you sure (Y/N)? y

Please take note that the previous del command will only delete files, but not remove the folder itself. To remove a folder, we have to use the rmdir command instead. If you want to remove the folder entirely (all the files and folders contained within), add a /S option at the end.

 

 

15) FILE COMPARE

D:\http>comp doge.txt cate.txt /A
Comparing doge.txt and cate.txt...
Compare error at OFFSET A
file1 = D
file2 = C
Compare error at OFFSET B
file1 = o
file2 = a
Compare error at OFFSET C
file1 = g
file2 = t
Compare error at OFFSET 10
file1 = G
file2 = E
Compare error at OFFSET 11
file1 = o
file2 = v
Compare error at OFFSET 12
file1 = o
file2 = i
Compare error at OFFSET 13
file1 = d
file2 = l
Compare more files (Y/N) ? n

Finally, this is a not-so-useful command that compares 2 files and shows you the differences between them.

 

MISC

16) REPEAT COMMANDS

Want to repeat a previous command? Press the up and down arrow keys to scroll through your previous commands – No need to retype everything.

 

17) COLOR

C:\>color 0a

Is the default black-and-white color scheme too boring for you? You can change the colors with the color command. It takes 2 alphanumeric characters from 0 to F. The first one is the background color, and the second one is the text color.

 

18) SHUTDOWN

C:\>shutdown /s

This is the “swag way” to shut down a computer.

  • The /s option will do a full shutdown.
  • Use /r to do a reset instead.

 

19) GETTING HELP

C:\>replace /?
Replaces files.

REPLACE [drive1:][path1]filename [drive2:][path2] [/A] [/P] [/R] [/W]
REPLACE [drive1:][path1]filename [drive2:][path2] [/P] [/R] [/S] [/W] [/U]

Need help with a command? Simply append /? to the end, or you can use the help command to get a full list of available commands.

C:\>help
For more information on a specific command, type HELP command-name
ASSOC          Displays or modifies file extension associations.
ATTRIB         Displays or changes file attributes.
BREAK          Sets or clears extended CTRL+C checking.
BCDEDIT        Sets properties in boot database to control boot loading.

 

USEFUL BITS & LINKS

That’s all for the examples, and here is the summary/cheat sheet of all the basic commands plus some links that may be useful to you.

 

ALL THE COMMANDS

Basic Navigation
c: d: e: Change the current drive.
dir Display the contents of the current directory.
cd Change the current directory.
cls Clear the screen.
exit Closes the current session.
File Actions
copy Copy files from one place to another.
xcopy The slightly more advanced version of copy.
move Move files from one place to another.
replace Copy and automatically replace target file(s).
ren Rename a file or folder.
mkdir Create a new folder.
del Delete a file or files.
rmdir Remove a folder
compare Compare 2 files.
Extras
Up and down arrow keys Scroll through the previous commands.
Tab key Autocomplete a file or folder name; Cycles between the files and folders.
color Change the color scheme of the command line.
shutdown Shut down the computer.
help Display all available commands, and get more details on the options of a specific command.

 

LINKS & REFERENCES

 

THE END

Thank you for reading, and we have come to the end of this guide. I hope this has helped you to better understand the command line and make you look a little more like a legit hacker. If you have anything to share with this guide, please feel free to comment below. Good luck and happy computing. May the cyber force be with you.

2 thoughts on “19 Basic Windows Command Prompt Commands (A Quick Guide)”

  1. I read your post now and I felt as if I have not seen any such post till date, so thank you for posting and yes I have got a lot of information from this post of yours.
    thank you for posting like this

  2. Thank you for this post! I would like to suggest a full red-pen edit, though, there were a couple places where it looks like there was some residual/improperly edited wording that appears to change the meaning of the text. ex. the missing word “not” in “do not want” inverting the content within the surrounding context. For a beginner to cmd this could be a fatal misunderstanding.

Leave a Comment

Your email address will not be published. Required fields are marked *