Complete List of MS-DOS Commands with Examples
What is MS-DOS?
MS-DOS (Microsoft Disk Operating System) is a command-line operating system that dominated personal computing from 1981 through the mid-1990s. Unlike modern graphical interfaces where you click icons, DOS requires you to type text commands to manage files, run programs, and control your computer. Even though Windows replaced DOS decades ago, the Command Prompt in Windows still uses many DOS commands, making this knowledge surprisingly relevant for system administration, batch scripting, and troubleshooting.
Think of DOS commands as direct conversations with your computer's file system. Instead of dragging files to folders, you type COPY source.txt destination.txt. This directness gives you precise control and helps you understand what's actually happening under the hood when you perform everyday tasks.
Why It Matters
- System administration: Windows Command Prompt and PowerShell still support legacy DOS commands for file management and system diagnostics
- Batch automation: You can write
.batscripts using DOS commands to automate repetitive tasks across Windows systems - Troubleshooting: When graphical interfaces fail, the command line often remains accessible for system recovery
- Understanding fundamentals: Learning DOS teaches you how operating systems manage files, directories, and processes at a basic level
- Legacy system support: Many industrial and embedded systems still run DOS or DOS-compatible environments
File Management Commands
These commands handle the bread-and-butter operations of working with files—copying, moving, deleting, and viewing.
The DIR command lists directory contents, while COPY and XCOPY duplicate files. The difference? XCOPY handles subdirectories and has more options. DEL (or ERASE) removes files, and REN renames them. TYPE displays file contents directly in the console.
REM Display all files in current directory
DIR
REM Copy a single file
COPY report.txt C:\backup\report.txt
REM Copy entire directory structure
XCOPY C:\projects D:\backup\projects /E /I
REM Delete a file
DEL oldfile.txt
REM Rename a file
REN draft.doc final.doc
REM Display text file contents
TYPE readme.txt
| Command | Purpose | Example |
|---|---|---|
| DIR | List directory contents | DIR /P (pause after each screen) |
| COPY | Copy one or more files | COPY *.txt D:\backup |
| XCOPY | Copy files and directory trees | XCOPY /S /E source dest |
| DEL / ERASE | Delete files | DEL *.tmp |
| REN / RENAME | Rename files | REN old.txt new.txt |
| TYPE | Display file contents | TYPE config.sys |
Directory Navigation Commands
Moving between folders requires different commands than graphical browsing. CD (Change Directory) is your primary navigation tool—use CD.. to move up one level or CD\ to jump to the root. MD (Make Directory) creates new folders, while RD (Remove Directory) deletes empty ones. The TREE command shows you a visual map of your directory structure.
REM Show current directory
CD
REM Change to specific directory
CD C:\Users\Documents
REM Go up one level
CD..
REM Go to root directory
CD\
REM Create new directory
MD NewProject
REM Remove empty directory
RD OldProject
REM Display directory tree
TREE C:\Projects /F
Disk and System Commands
These commands interact with your storage devices and system configuration. FORMAT prepares disks for use (warning: destroys all data), CHKDSK scans for errors, and LABEL sets volume names. VOL displays the current volume label, while DISKPART in modern systems offers advanced disk management.
REM Check disk for errors
CHKDSK C: /F
REM Display volume label
VOL C:
REM Set volume label
LABEL C: SYSTEM_DRIVE
REM Format a floppy disk (A: drive)
FORMAT A: /Q
REM Display disk information
DIR C:\
REM Clear the screen
CLS
| Command | Purpose | Caution Level |
|---|---|---|
| FORMAT | Prepare disk for use | ⚠️ HIGH - Erases all data |
| CHKDSK | Check disk integrity | Low - Read-only by default |
| LABEL | Change volume name | Low |
| VOL | Display volume info | None - Read-only |
File Attribute and System Configuration
DOS assigns attributes to files: Read-only, Hidden, System, and Archive. The ATTRIB command modifies these. Hidden files don't appear in normal DIR listings, read-only files can't be modified, and system files are critical OS components.
REM View file attributes
ATTRIB myfile.txt
REM Make file read-only
ATTRIB +R important.doc
REM Remove read-only and make visible
ATTRIB -R -H secret.txt
REM Hide all text files in directory
ATTRIB +H *.txt
REM Display system configuration
SET
REM Show DOS version
VER
REM Display system time
TIME
REM Display/set system date
DATE
Batch File and Automation Commands
Batch files (.bat extension) let you chain DOS commands together. Control flow commands like IF, FOR, and GOTO add logic. ECHO displays messages, PAUSE waits for user input, and REM adds comments.
@ECHO OFF
REM This is a backup script
ECHO Starting backup process...
IF EXIST C:\backup (
ECHO Backup folder found
) ELSE (
MD C:\backup
ECHO Created backup folder
)
FOR %%F IN (*.doc) DO COPY %%F C:\backup
ECHO Backup complete!
PAUSE
Redirection and Piping
You can redirect command output to files or chain commands together. The > symbol writes output to a file (overwriting), >> appends, < reads input from a file, and | (pipe) sends one command's output to another.
REM Save directory listing to file
DIR > filelist.txt
REM Append to existing file
DIR *.exe >> programs.txt
REM Display file page by page
TYPE longfile.txt | MORE
REM Find specific text in file
FIND "error" logfile.txt
REM Sort directory listing
DIR | SORT
REM Count lines in a file
FIND /C /V "" < document.txt
Quick Cheat Sheet
| Need | Reach for |
|---|---|
| List files | DIR or DIR /P for pagination |
| Navigate folders | CD foldername or CD.. to go up |
| Copy files | COPY for single files, XCOPY /E for directories |
| Delete files | DEL filename or DEL *.ext for patterns |
| Create directory | MD dirname |
| View text file | TYPE filename.txt |
| Search in files | FIND "text" filename |
| Clear screen | CLS |
| Get help | HELP commandname or commandname /? |
| Run program | Just type the .exe name or full path |
Common Mistakes
-
Forgetting
/Swith XCOPY: Without the/Sswitch,XCOPYwon't copy subdirectories. You'll copy only the top-level files and wonder where everything else went. -
Using DEL . without caution: This deletes EVERYTHING in the current directory. Always double-check your location with
CDbefore running wildcard deletions. -
Not checking if FORMAT is destructive:
FORMATerases all data on a drive. There's no "Are you sure?" in classic DOS—it just does it. Modern systems add warnings, but the command remains dangerous. -
Mixing forward and backslashes: DOS uses backslashes (
\) for paths, not forward slashes (/). Forward slashes are for command switches like/Por/S. -
Forgetting ECHO OFF in batch files: Without
@ECHO OFFat the start of your.batfile, every command displays before executing, cluttering your output with the command itself. -
Assuming commands are case-sensitive: DOS commands ignore case (
DIR=dir=DiR), but this habit can bite you when moving to Linux systems where case matters.
💡 Think Like a Programmer: DOS commands are the foundation of modern command-line interfaces—master these patterns, and you'll feel at home in PowerShell, Terminal, and Bash across any operating system.
Keep Reading
C++ STL Containers: Which One Should You Actually Use?
The C++ Standard Template Library gives you a toolkit of pre-built data structures called **containers**.
Pointers in C: The Mental Model That Finally Makes Them Click
A pointer is a variable that stores a memory address instead of a regular value like a number or character. Think of it like this: your house number isn't your house—it's just a way to find your house.
JavaScript Closures Explained With Real Examples
A closure is a function bundled together with its surrounding state — the lexical environment in which it was created.
