cd <directory>
Browse / Windows CMD Essentials (Windows command line)
Windows CMD Essentials (Windows command line)
A comprehensive cheat sheet for Windows Command Line (CMD), designed for beginners and intermediate users. This guide covers essential commands, file management, system administration, networking, and basic batch scripting, with practical examples and pro tips.
Core Fundamentals: Navigation & System Info
NAVIGATION & FILES
|
Change Directory. Navigate to a specified folder. Examples: |
|
List directory contents. Examples: |
|
Display directory structure as a tree. Examples: |
|
Copy files or directories. Examples: |
|
Move files or directories. Examples: |
|
Delete files. Examples: |
|
Rename files or directories. Example: |
Wildcards & Paths |
Absolute Path: Pro Tip: Use |
SYSTEM INFO & TASKS
|
Display detailed system configuration information. Example: |
|
List all running processes. Examples: |
|
Terminate a process by Process ID (PID) or image name. Examples: |
|
Display the name of the host computer. Example: |
|
Display messages or turn command echoing on/off in scripts. Examples: |
|
Display, set, or remove CMD environment variables. Examples: |
Viewing Environment Variables |
Use Example: Pro Tip: For persistent environment variable changes, use |
Network & Disk Management
NETWORKING
|
Display current TCP/IP network configuration. Examples: |
|
Test network connectivity to a host. Examples: |
|
Trace the route packets take to a network host. Example: |
|
Display active TCP connections, listening ports, and associated process IDs. Examples: |
|
Query DNS for domain name or IP address mapping. Examples: |
|
Connects to or disconnects from shared network resources. Examples: Pro Tip: |
DISK & FILE MANAGEMENT
|
Check a disk for errors and fix them. Examples: |
|
Disk partitioning utility. Enters a separate interactive shell. Basic Steps: Warning: Use with extreme caution, as incorrect commands can lead to data loss. |
|
Format a disk or partition. Examples: |
|
Display or change file attributes. Attributes: Examples: |
|
Advanced file copy utility, supports copying directories and subdirectories. Common Switches: Example: |
|
Robust File Copy. More powerful than xcopy, designed for reliable copying, especially over networks. Common Options: Examples: Pro Tip: |
User Management & Automation
USER & PERMISSIONS
|
Manage user accounts. Examples: |
|
Display the current user’s domain and username. Example: |
|
Run a command or program as a different user. Example: Pro Tip: To open an administrative CMD directly, search for “cmd” in the Start Menu, right-click, and select “Run as administrator”. |
Changing User Passwords |
To change a local user’s password: Example: To force a password change at next login: |
Checking User Groups |
Use To check groups for another user (local): Pro Tip: Understanding user permissions and groups is crucial for security. Always follow the principle of least privilege. |
BATCH & AUTOMATION
.bat Scripting Basics |
Batch files ( Syntax:
Example
|
|
Conditional execution. Syntax: Examples: |
|
Iterate over sets of files, directories, or numbers. Syntax (files): Examples: |
|
Pauses the execution of a batch program and displays a message to the user to press any key to continue. Example:
|
|
Directs the batch program to a line identified by a label. Syntax:
Example:
Pro Tip: Use |
|
Schedule commands or programs to run at specified times. Examples: Pro Tip: For complex schedules, the Task Scheduler GUI ( |