Command Prompt (CMD) Notes: Basic to Advanced
1. Introduction to CMD
CMD (Command Prompt) is a command-line interpreter application available in most Windows operating
systems. It allows users to execute entered commands. Some basic functionalities include file manipulation,
program execution, and troubleshooting Windows issues.
2. Basic CMD Commands
- dir - Lists files and directories
- cd - Changes directory
- cls - Clears the screen
- echo - Displays messages
- exit - Exits the CMD session
- copy - Copies files from one location to another
- del - Deletes one or more files
- mkdir - Creates a new directory
- rmdir - Removes a directory
- type - Displays the contents of a file
3. Intermediate CMD Commands
- ipconfig - Displays IP configuration
- ping - Tests network connectivity
- tasklist - Lists all running processes
- taskkill - Terminates a task by PID or name
- netstat - Displays network statistics
- find - Searches for text in a file
- fc - Compares two files and shows differences
Command Prompt (CMD) Notes: Basic to Advanced
- attrib - Changes file attributes
4. Advanced CMD Commands
- chkdsk - Checks disk for errors
- sfc /scannow - Scans and repairs system files
- regedit - Opens Windows Registry Editor
- gpupdate - Updates Group Policy settings
- shutdown - Schedules a shutdown/restart
- diskpart - Manages partitions on your drives
- schtasks - Schedules tasks to run automatically
- robocopy - Advanced copy utility with robust options
5. Scripting and Batch Files
CMD can be used to write batch scripts (.bat files) for automation:
@echo off
echo Starting backup...
xcopy C:\Data D:\Backup /E /H /C /I
echo Backup complete.
6. Tips and Best Practices
- Use 'help' followed by a command to get more information
- Redirect output using > and >>
- Use | (pipe) to send output of one command as input to another
- Combine commands using && or || for conditional execution