What is cmd.exe (Command Prompt)? Let's Learn Its History and Basic Uses
When you're involved in web development or PC troubleshooting, you're almost certain to encounter the "black screen." For Windows users, the prime example of this black screen is the Command Prompt (cmd.exe). You might have an image of it as a mysterious tool used by hackers, but its true identity is a very straightforward and reliable companion that has been part of Windows for a long time.
In recent versions of Windows, the more feature-rich "PowerShell" is taking center stage, but the Command Prompt is still in active service. You'll find it's still frequently used in web development for things like old manuals and batch files.
This article will answer beginner questions like, "What exactly is Command Prompt?" and "How is it different from PowerShell?" while explaining its historical background and the basic ways to use it that are worth knowing today. Understanding the Command Prompt leads to a deeper understanding of how Windows works. Now, let's explore the world of this tool, which could be called an "elder" of Windows!
The History of Command Prompt - The Bloodline from MS-DOS
To understand the Command Prompt, taking a short trip back in time is the quickest way.
Once upon a time, computers existed in a CUI (Character User Interface) world, operated solely by text, without mice or icons. MS-DOS, an OS developed by Microsoft, was one of them, and users operated their PCs by typing commands from the keyboard. The program that served as the "interpreter" for MS-DOS was COMMAND.COM.
Later, even when graphical operating systems (GUIs) like Windows 95/98 appeared, this COMMAND.COM was carried over for compatibility. Then, with the advent of the more robust Windows NT family (the lineage leading to Windows 2000, XP, and the current Windows 10/11), a new 32-bit native command-line interpreter was born. And that was none other than this very cmd.exe.
In other words, the Command Prompt is a venerable Windows shell, born from the historical necessity of making old batch files (discussed later) from the MS-DOS era work as much as possible in the new Windows environment.
Why Learn Command Prompt Now?
It's natural to think, "If there's a new tool like PowerShell, why bother with the old Command Prompt?" However, there are still definite advantages to learning cmd today.
- Maintaining Compatibility: There are tons of tools and programs out there written in "batch files" with a
.batextension. These are written in Command Prompt syntax, and knowledge of cmd is indispensable for reading or maintaining them. - Simplicity: For very simple, routine tasks like checking network connectivity with
pingor checking your own IP address withipconfig, the simple and fast-to-launch cmd can sometimes be more convenient than the feature-rich PowerShell. - Acquiring Fundamental Knowledge: You can gain a deeper appreciation for why PowerShell introduced the concept of "objects" by knowing the "inconvenience" of the text-based cmd. It's like how knowing history helps you understand the value of new technology.
Let's Try Some Basic Commands
To get a feel for operating the Command Prompt, let's try a few basic commands. Search for "cmd" in the Windows Start Menu to launch it, then copy and paste the following commands into the window that appears and press Enter.
dir - List the contents of a directory
This is the equivalent of Bash's ls command. It lists the files and folders in the current location.
C:\Users\YourName> dir
Adding the /b option displays just the file and folder names simply.
C:\Users\YourName> dir /b
Desktop
Documents
Downloads
...
cd - Change directory
Just like other shells, you use cd (Change Directory) to move between directories.
C:\Users\YourName> cd Documents
To go back up one level, you type cd ...
C:\Users\YourName\Documents> cd ..
type - Display the contents of a text file
This is the equivalent of Bash's cat. It outputs the contents of a file to the screen.
C:\> type C:\Windows\System32\drivers\etc\hosts
Network-Related Commands
Even now, the Command Prompt is often used for simple tasks like checking an IP address or network connectivity because it's so convenient.
To check your own IP address and other details:
ipconfig
To check the connection to a specific server:
ping google.com
Introduction to Batch Files - Automating Simple Tasks
A "batch file" is a file that contains a series of commands to be executed. It has a .bat extension. For simple tasks, you can achieve sufficient automation just by creating one of these.
For example, let's create a batch file that creates a folder named "backup" on the desktop and copies the `report.docx` file from the Documents folder into it, with today's date appended.
Paste the following content into a text editor and save it with the name simple_backup.bat.
@echo off
rem --- A simple backup batch file ---
rem Store the date in a variable (YYYY-MM-DD format)
set TODAY=%date:~0,4%-%date:~5,2%-%date:~8,2%
rem Create the backup destination folder
mkdir "%USERPROFILE%\Desktop\backup"
rem Copy the file with the date appended
copy "%USERPROFILE%\Documents\report.docx" "%USERPROFILE%\Desktop\backup\report_%TODAY%.docx"
echo Backup complete.
pause
@echo off is a magic spell to prevent the commands themselves from being displayed when executed, and rem is for comments. Just by double-clicking this file, the series of processes will be executed automatically. The pause command is to wait for a key press so the window doesn't close immediately after the process is finished.
Conclusion
This time, we've explained the historical background of the traditional Windows shell, Command Prompt (cmd.exe), its basic usage, and even simple automation.
- Command Prompt is a venerable Windows shell that exists to maintain compatibility from the MS-DOS era.
- Unlike PowerShell, it handles output as "text," so it's not good at flexible data processing.
- However, it's still actively used for simple command execution and for running old batch files.
If PowerShell is the modern, multi-functional tool, then Command Prompt is the simple, straightforward "old-school tool." If you can understand the characteristics of both and use them according to the situation, your work on Windows will become more comfortable and profound.
For those thinking, "So, how do I actually launch Command Prompt?" or "I want to learn from even more basic operations!", the next article will explain its launch methods and the very first steps in more detail.
How to Launch and Use Command Prompt: A Super-Beginner's Guide [for Windows]