Command Prompt (cmd) is a command-line interpreter on Windows systems that allows users to execute commands to perform various basic tasks. Below are some common tasks that can be performed in cmd, along with examples:
1. Navigating the File System
-
Changing Directories:
Changes the current directory to
C:\path\to\directory
. -
Listing Files and Directories:
Lists the files and directories in the current directory.
2. Managing Files and Directories
-
Creating a Directory:
Creates a new directory named
newfolder
. -
Deleting a Directory:
Deletes the directory
newfolder
and its contents. The/s
flag removes all directories and files in the specified directory, and the/q
flag runs the command quietly without asking for confirmation. -
Copying Files:
Copies
file.txt
from theC:\source
directory to theD:\destination
directory. -
Renaming Files:
Renames
oldfile.txt
tonewfile.txt
. -
Deleting Files:
Deletes
file.txt
.
3. Viewing and Managing System Information
-
Viewing IP Configuration:
Displays the current network configuration.
-
Viewing System Information:
Provides detailed system information including OS version, hardware details, and network configurations.
4. Managing Processes
-
Viewing Running Processes:
Lists all currently running processes.
-
Killing a Process:
Terminates the process with the Process ID (PID)
1234
. The/F
flag forces the process to terminate.
5. Networking Commands
-
Pinging a Server:
Sends ICMP Echo Request packets to the specified host and displays the response.
-
Tracing Route to a Server:
Traces the route packets take to the specified host.
6. Batch File Scripting
- Creating and Running a Simple Batch File:
- Create a file named
example.bat
with the following content: - Run the batch file:
- Create a file named
7. Environment Variables
-
Viewing Environment Variables:
Displays all current environment variables and their values.
-
Setting an Environment Variable:
Sets an environment variable
MYVAR
with the valueHello
.
8. Disk Operations
-
Checking Disk Usage:
Checks the file system and file system metadata of the C: drive for logical and physical errors.
-
Formatting a Disk:
Formats the D: drive with the NTFS file system.
9. Echoing Messages
- Displaying a Message:
Prints
Hello, World!
to the console.
10. Redirecting Output
- Redirecting Command Output to a File:
Redirects the output of the
dir
command tooutput.txt
.
These examples illustrate some of the basic functionalities of Command Prompt. While cmd is less powerful compared to PowerShell, it remains useful for simple file system navigation, file management, and running legacy scripts.
This version organizes the information into clear sections, making it easy to read and understand.