DOS Command Basics: Essential Windows Command Line Guide
This tutorial covers DOS command fundamentals for Windows CMD, including file operations, system info commands, disk management, wildcards, batch scripting, pipes, and redirection with practical examples.
DOS History
DOS (Disk Operating System) was Microsoft's earliest operating system, shipped with the IBM PC in 1981. There was no mouse, graphical interface, or windows—everything was driven by keyboard commands on a black screen with a blinking cursor. Windows began as a graphical shell on top of DOS and later became independent, but DOS commands were fully preserved and remain the core of CMD (Command Prompt).
Most Common DOS Commands
File and Directory Operations
dir(directory) — List directory contents. Example: dir /w (wide format). cd (change directory) — Change directory. Example: cd \Users. md / mkdir (make directory) — Create directory. Example: mkdir projects. rd / rmdir (remove directory) — Delete directory. Example: rd /s old_folder. copy — Copy files. Example: copy a.txt d:\backup\. xcopy (extended copy) — Advanced copy (can copy directories). Example: xcopy /e /i src dst. move — Move files. Example: move *.txt archive\. del / erase (delete/erase) — Delete files. Example: del *.tmp. ren (rename) — Rename. Example: ren old.txt new.txt. type — Display file contents. Example: type readme.txt.
System Information Commands
ipconfig— View network configuration. Example: ipconfig /all (detailed). ping — Test network connectivity. Example: ping -t 192.168.1.1 (continuous). tracert — Trace route path. Example: tracert www.baidu.com. netstat — View network connections. Example: netstat -ano. tasklist — View running processes. Example: tasklist | findstr "chrome". taskkill — Terminate process. Example: taskkill /f /im notepad.exe. systeminfo — View detailed system information. Example: systeminfo.
Disk Operations
chkdsk— Check disk for errors. Example: chkdsk C: /f. format — Format disk. Example: format D: /fs:ntfs. diskpart — Disk partition management. Example: diskpart (enters interactive mode).
Wildcards: Batch Operation Power Tools
DOS supports two wildcards: *: matches any number of characters ?: matches exactly one character
Examples: dir *.txt: list all .txt files del *.bak: delete all .bak files copy *.jpg D:\photos\: copy all jpg files ren file?.txt: rename file1.txt, fileA.txt, etc.
Analogy: * is like "all similar ones", ? is like "any single one".
Batch Files: Automation Tool
If you have a set of commands to run repeatedly, write them into a .bat file (batch file). Example backup.bat:
@echo off
echo Starting backup...
xcopy C:\Documents D:\Backup\Documents\ /e /i /y
echo Backup completed!
pauseDouble-click the .bat file to execute all commands automatically—the simplest form of scripting.
Pipes and Redirection
>— Output redirection (overwrite). Example:
dir > files.txt>>— Output redirection (append). Example:
echo log >> log.txt<— Input redirection. Example:
sort < unsorted.txt|— Pipe. Example:
tasklist | findstr "chrome"Practical Combinations
# Find and kill all Chrome processes
tasklist | findstr "chrome"
taskkill /f /im chrome.exe
# Check which process occupies a port
netstat -ano | findstr "8080"
# Test network with continuous timestamp
ping -t www.baidu.com
# View saved WiFi password
netsh wlan show profile name="WiFiName" key=clearExam Points (Software Qualification)
Functions and usage of common DOS commands
Wildcard usage ( * and ?)
Batch file (.bat) basic concepts
Pipe and redirection concepts
Summary
Although DOS commands are "ancient," they remain the foundation of Windows command-line operations. Mastering dir, cd, copy, ping, ipconfig and other common commands, plus wildcards and pipes, enables many efficient command-line tasks. Batch files are the entry-level tool for automating repetitive work.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
