19 Basic Windows Command Prompt Commands

INTRODUCTION
THE LOST ART

Welcome to a beginner’s tutorial on the basic Windows command prompt commands. Once upon a time in the dark ages of computing, there was no graphical user interface (GUI). When we boot up a computer, there is no wallpaper, no windows, no graphics. All we get were lines of “hacker stuff code”, and that is we call the command prompt today.

While many people will shy away from the command prompt, it actually does provide a lot of powerful “hacker” controls that are otherwise not available in the graphical interface. But we are not going there in this guide and will only start with the basics… Which will still make you look cool enough anyway. Read on!

 

NAVIGATION
TABLE OF CONTENTS

Section A
Getting Started

Section B
Basic Commands

Section C
Summary & Links

Closing
What’s Next?

 

 

SECTION A
GETTING STARTED

Before we dive into the commands, here are sort of the prelude and how to launch the command prompt; This guide should be good for most of the modern Windows installations – Windows 7, Windows 8, and Windows 10.

 

HOW TO LAUNCH THE COMMAND PROMPT

  • Press the Windows button + R.
  • Type in “cmd” and hit “OK”.

 

A NOTE ABOUT SECURITY

By default, when you launch the command prompt, it will be in “restricted access” mode. Meaning, it will not allow you to mess with the critical system stuff. If you want an unrestricted command prompt, here is how to do it:

  • Hit the Windows button, search.
  • Find “command prompt”.
  • Right click on it, run as administrator.

But beware – This means that you can mess with the system files, and potentially cause irreversible damage. So avoid opening the command prompt with full administrator access unless you know what you are doing.

 

WHY USE THE COMMAND PROMPT?

As with the introduction, the command prompt will allow you to do several “hacker stuff” with Windows. It allows you to possibly fix a broken copy of Windows in safe mode (with some ninja skills), plus it totally makes you look like a legit hacker.

 

 

SECTION B
BASIC COMMANDS 101

Now that you have launched the command line and have it staring at your face, here is “how to use it” and some of the basic commands.

 

BASIC NAVIGATION

1) CHANGING THE CURRENT DRIVE

When you start the command prompt, there is this C:\Users\NAME staring at you. Just what the heck does it mean? This is your “current location”, which will default to your own user folder. To change the drive, just enter the drive letter.

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

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

 

2) LIST THE CONTENTS OF A DIRECTORY/FOLDER

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

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

 Directory of D:\
11/02/2018  03:42 PM    <DIR>          hMailServer
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

 

3) CHANGE DIRECTORY/FOLDER

If you want to “go into” a folder, use the CD command.

D:\>cd http
D:\http>cd temp
D:\http\temp>

The easy way is not to type the full folder name in, but to type part of the name and press tab to auto-complete/cycle in between. For example, if I type cd h on my PC and press tab, it will cycle in between the http and hMailServer folders. You can also use the tab key to help you complete folder names in the other commands.

To return to the previous folder (up one level), you can use CD.. or to return directly to the base of the drive, use CD/.

D:\http\temp>cd..
D:\http>

D:\http\temp>cd/
D:\>

 

4) CLEAR SCREEN

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

D:\>cls

 

5) LAUNCHING APPLICATIONS

From the command line, you can also launch any application,.exe or.bat files.

D:\>notepad

 

 

6) EXIT

Finally when you are done with the command line session, use the exit command to close the session.

D:\>exit

 

FILE ACTIONS

7) COPYING FILES

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

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

To copy all the files in the folder, you can use copy *.*.

d:\http\test>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.

 

8) X-COPYING FILES

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 instead.

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

 

9) MOVING FILES

To move the files, you guessed it – Use the move command instead.

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.

 

10) REPLACING FILES AND FOLDERS

By default, copy and move will ask you if you want to replace the existing files. So if you do want to be bugged everything, use replace SOURCE TARGET instead.

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

 

11) RENAMING FILES AND FOLDERS

Use ren SOURCE TARGET.

d:\http\test>ren README.txt READLATER.txt

 

12) CREATING A NEW FOLDER

d:\http\test>mkdir dogewonderland 

 

13) DELETING FILES

To delete a single file:

D:\http\temp>del READLATER.txt

To delete all the files in the folder:

D:\http\temp>del *.*

 

 

14) REMOVING DIRECTORIES/FOLDERS

Please take note that del will only delete files, but will not remove the folder. To remove a folder, you need to use the rmdir command instead. You can also add a /S option to automatically remove everything inside the folder.

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

 

15) FILE COMPARE

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

D:\http\test>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

 

EXTRAS

16) REPEAT COMMANDS

Made a typo mistake on your command? You can easily press the up and down arrow keys to scroll through your previous commands – No need to retype everything.

 

17) COLOR

The default black-and-white color scheme too boring for you? You can change the colors with the color command.

d:\http\test>color 0a

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

This is the more “swag way” to shutting down your computer:

d:\http\test>shutdown /s

The /s option will do a full shutdown, and use /r to do a reset instead.

 

19) GETTING HELP

Need more help with the specific commands and options? Simply append a /? at the end of the function.

d:\http\test>replace /?
Replaces files.

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

Or you can use the help command to get a full list of available commands.

d:\http\test>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.

 

 

SECTION C
SUMMARY & 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.
dirDisplay the contents of the current directory/folder.
cdChange the current directory/folder.
clsClear the screen.
exitCloses the current session.
File Actions
copyCopy files from one place to another.
xcopyThe slightly more advanced version of copy.
moveMove files from one place to another.
replaceCopy and automatically replace target file(s).
renRename a file or folder.
mkdirCreates a new directory/folder.
delDelete a file or files.
rmdirRemove a directory/folder
compareCompares 2 files.
Extras
Up and down arrow keysScrolls through your previous commands.
Tab keyHelps you to “autocomplete” the file/folder name, cycles between the files and folders.
colorChanges the color scheme of the command line.
shutdownShutdown the computer.
helpGets a whole list of available commands, or more details on the options of a specific command.

 

LINKS & REFERENCES

 

CLOSING
WHAT’S NEXT?

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.

Leave a Comment

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