Windows Command Prompt (CMD) Lab
Hands-on exercises for mastering basic Windows CMD operations
Lab Overview
This lab will teach you essential Windows Command Prompt commands for navigating the file system, managing files and folders, and performing basic operations. Complete each exercise in order.
Prerequisites: Windows 10/11 with Command Prompt access
Part 1: Opening Command Prompt
Methods to Open CMD:
- Windows Key + R → Type
cmd
→ Press Enter - Windows Key + X → Select "Windows Terminal" or "Command Prompt"
- Search Bar → Type "cmd" or "command prompt" → Press Enter
- File Explorer → Type
cmd
in address bar → Press Enter
Tip: For administrator privileges, right-click and select "Run as administrator"
Part 2: Navigation Commands
Essential Navigation Commands:
Command | Description | Example |
---|---|---|
cd | Display current directory | cd |
cd [folder] | Change to specified folder | cd Documents |
cd .. | Go up one directory level | cd .. |
cd \ | Go to root of current drive | cd \ |
cd /d [drive:] | Change to different drive | cd /d D:\ |
dir | List files and folders | dir |
dir /w | Wide format listing | dir /w |
dir /p | Paginated listing | dir /p |
tree | Display folder structure | tree |
cls | Clear screen | cls |
Exercise 1: Navigation Practice
Part 3: File Management Commands
File Operations:
Command | Description | Example |
---|---|---|
echo [text] > file.txt | Create file with text | echo Hello World > test.txt |
type nul > file.txt | Create empty file | type nul > empty.txt |
type [file] | Display file contents | type test.txt |
copy [source] [dest] | Copy file | copy test.txt backup.txt |
move [source] [dest] | Move/rename file | move test.txt newname.txt |
ren [old] [new] | Rename file | ren oldfile.txt newfile.txt |
del [file] | Delete file | del test.txt |
del *.txt | Delete all .txt files | del *.txt |
attrib [file] | View file attributes | attrib test.txt |
find "[text]" [file] | Search text in file | find "hello" test.txt |
Exercise 2: File Operations Practice
Setup: First, let's create a practice workspace and multiple files to work with
Step 1: Create Your Workspace
Step 2: Create Multiple Files
Step 3: Organize with Folders
Step 4: File Operations
Step 5: Advanced Operations
Step 6: Cleanup (Optional)
Great job! You've created multiple files and folders, organized them, and practiced essential file management operations. These are real-world skills you'll use frequently!
Part 4: Folder Management Commands
Folder Operations:
Command | Description | Example |
---|---|---|
mkdir [folder] | Create new folder | mkdir NewFolder |
md [folder] | Create folder (short) | md TestFolder |
mkdir [path\folder] | Create nested folders | mkdir Parent\Child\Grandchild |
rmdir [folder] | Remove empty folder | rmdir OldFolder |
rd [folder] | Remove folder (short) | rd TestFolder |
rmdir /s [folder] | Remove folder and contents | rmdir /s FullFolder |
rmdir /s /q [folder] | Remove without confirmation | rmdir /s /q TempFolder |
move [folder] [dest] | Move/rename folder | move OldName NewName |
xcopy [source] [dest] /e | Copy folder with contents | xcopy SourceDir DestDir /e |
robocopy [src] [dest] | Robust folder copy | robocopy Source Dest /e |
Exercise 3: Folder Management Practice
Part 5: Advanced Commands & Tips
Useful Advanced Commands:
Command | Description | Example |
---|---|---|
help | List all commands | help |
help [command] | Get help for specific command | help dir |
[command] /? | Command help | dir /? |
tab | Auto-complete paths | Type partial name + Tab |
↑ ↓ | Command history | Arrow keys |
F7 | Display command history | Press F7 key |
command > file.txt | Redirect output to file | dir > listing.txt |
command | more | Page through output | dir | more |
command1 && command2 | Run if first succeeds | mkdir test && cd test |
start [program] | Launch program | start notepad |
Pro Tips:
- Use
Tab
key for auto-completion of file and folder names - Use quotes for paths with spaces:
cd "Program Files"
- Use
*
as wildcard:dir *.txt
shows all .txt files - Chain commands with
&&
:mkdir test && cd test
- Use
cls
to clear screen when it gets cluttered - Drag and drop files into CMD to auto-paste their paths
- Right-click title bar → Properties to customize CMD appearance
Part 6: Final Challenge
Complete Project Structure Challenge
Create the following project structure using only CMD commands:
MyProject/ ├── src/ │ ├── main.txt │ └── config.txt ├── docs/ │ ├── readme.txt │ └── notes.txt ├── backup/ └── temp/
Solution Steps:
Congratulations!
You've completed the Windows CMD basics lab! You now have the fundamental skills to navigate and manage files and folders using the command line. Practice these commands regularly to build muscle memory and efficiency.
Quick Reference Card
Navigation
cd
- Show current directorycd [folder]
- Change directorycd ..
- Go up one leveldir
- List contentscls
- Clear screen
File Operations
echo text > file
- Create filetype file
- View filecopy src dest
- Copy filemove src dest
- Move filedel file
- Delete file
Folder Operations
mkdir folder
- Create folderrmdir folder
- Remove empty folderrmdir /s folder
- Remove with contentstree
- Show folder structurexcopy src dest /e
- Copy folder
Helpful Shortcuts
Tab
- Auto-complete↑ ↓
- Command historyF7
- History listCtrl+C
- Cancel command/?
- Command help