How to Use Command Prompt: A Beginner’s Guide to Windows CMD

Command Prompt is a text window where you type commands and Windows runs them. You can open folders, copy files, check your internet connection and fix system problems without clicking through menus. This guide shows you how to open it, the commands you will use most, and how to avoid the mistakes that trip up beginners.
Short answer: Press the Windows key, type “cmd” and press Enter. Then type a command and press Enter to run it. Start with dir to list files, cd foldername to open a folder, cls to clear the screen and help to see a list of commands.
Best Terminal for Claude Code on Mac: Setup, Comparison and Tips
What Command Prompt Is
Command Prompt, also called CMD or cmd.exe, is a command-line tool built into Windows. Instead of clicking icons, you type short instructions. Windows reads each line, runs it and shows the result as text.
People use it because it is fast and precise. Renaming 200 files, checking why Wi-Fi is not working or repairing damaged system files can take seconds in CMD and many clicks without it. It is also a good first step toward scripting and IT work.
This guide is for Windows 10 and Windows 11. On a Mac or Linux computer, the equivalent tool is called Terminal and many commands are different.
How to Open Command Prompt
Use whichever method suits you.
- Start menu search. Press the Windows key, type
cmdand press Enter. - Run box. Press Windows key + R, type
cmdand press Enter. - Right-click the Start button (or press Windows key + X) and choose Terminal or Windows Terminal. On Windows 11 this may open PowerShell by default. Click the small down arrow next to the tab bar and choose Command Prompt.
- From a folder. Open the folder in File Explorer, click the address bar, type
cmdand press Enter. CMD opens already pointed at that folder, which saves you from typing the path. - Task Manager. Press Ctrl + Shift + Esc, choose File, then Run new task, type
cmdand press Enter.
How to Open Command Prompt as Administrator
Some commands change system settings or repair Windows, and these need administrator rights.
- Press the Windows key and type
cmd. - Right-click Command Prompt in the results.
- Choose Run as administrator.
- Click Yes if Windows asks for permission.
The title bar will say “Administrator: Command Prompt”. Only use this mode when a command needs it.
Reading the Prompt
When CMD opens, you see something like this:
C:\Users\Rahim>
Here is what each part means:
C:is the drive you are on.\Users\Rahimis the folder you are in, called the current directory.>means CMD is waiting for you to type.
Every command you type works relative to this location unless you give the full path.
Basic Navigation Commands
These commands help you move around.
See what is in the current folder:dir
You will see file names, sizes, dates and folders marked <DIR>. Useful options:
dir /ashows hidden files toodir /slists files in all sub-foldersdir /wshows a compact, wide list
Open a folder:cd Documents
Go up one level:cd ..
Go straight to the top of the drive:cd \
Open a folder with spaces in its name. Use quotation marks:cd "My Projects"
Switch to another drive. Type the drive letter and a colon:D:
Or switch drive and folder together:cd /d D:\Photos
Clear the screen:cls
Show a list of commands:help
See how one command works:help dir or dir /?
Using /? after any command shows what it does and which options it takes. It is the quickest way to learn.
Working with Files and Folders
| Task | Command | Example |
|---|---|---|
| Create a folder | mkdir or md | mkdir Invoices |
| Create a nested folder | mkdir | mkdir Work\2026\October |
| Create a text file with content | echo | echo Hello > note.txt |
| Show a text file | type | type note.txt |
| Copy a file | copy | copy note.txt D:\Backup |
| Copy a whole folder | xcopy /s /e | xcopy Photos D:\Backup\Photos /s /e |
| Move a file | move | move note.txt Documents |
| Rename a file | ren | ren note.txt report.txt |
| Delete a file | del | del report.txt |
| Delete an empty folder | rmdir | rmdir OldFolder |
| Delete a folder and everything in it | rmdir /s | rmdir /s OldFolder |
| Show folder structure | tree | tree |
Warning about deleting. del and rmdir /s do not send files to the Recycle Bin. They are gone. Always check the folder with dir before you delete, and read the path twice.
Tip: Press the Tab key while typing a file or folder name and CMD completes it for you. Press Tab again to cycle through matches. This saves typing and prevents spelling errors.
Network Commands
These help when your internet is slow or not working.
Show your IP address and network details:ipconfig
For fuller information, including your MAC address and DNS servers:ipconfig /all
Test whether you can reach a website or server:ping google.com
Four replies with times in milliseconds mean the connection works. “Request timed out” means the reply did not arrive. Press Ctrl + C to stop a continuous ping started with ping -t google.com.
See the route your connection takes:tracert google.com
Look up the address behind a domain name:nslookup minciter.com
Clear the DNS cache. This helps when a website has moved or will not load:ipconfig /flushdns
Refresh your IP address:ipconfig /release
thenipconfig /renew
See active connections:netstat -an
Show the saved password of a Wi-Fi network you have used (needs administrator mode):netsh wlan show profile name="NetworkName" key=clear
Look for “Key Content”. Use this only for your own networks.
A simple troubleshooting order for “no internet”: ping your router (its address is next to “Default Gateway” in ipconfig), then ping 8.8.8.8, then ping a domain name such as google.com. If the address works but the name does not, the problem is DNS. If the router does not answer, the problem is local.
System and Troubleshooting Commands
| Task | Command | Notes |
|---|---|---|
| Show Windows version | ver | Short version line |
| Show detailed system info | systeminfo | Takes a few seconds |
| Show your computer name | hostname | |
| Show your user name | whoami | |
| List running programs | tasklist | |
| Close a program by name | taskkill /IM notepad.exe /F | /F forces it to close |
| Close a program by ID | taskkill /PID 1234 /F | Get the ID from tasklist |
| Scan and repair system files | sfc /scannow | Needs administrator mode and can take several minutes |
| Check a disk for errors | chkdsk C: | Add /f to fix errors, which may need a restart |
| Shut down now | shutdown /s /t 0 | |
| Restart now | shutdown /r /t 0 | |
| Cancel a scheduled shutdown | shutdown /a | |
| Show the date or time | date /t and time /t |
Let sfc /scannow finish. Closing the window halfway can leave the scan incomplete.
Time-Saving Shortcuts
- Up and down arrow keys bring back commands you typed before.
- F7 shows a list of recent commands to pick from.
- Tab completes file and folder names.
- Ctrl + C stops a running command.
- Ctrl + V or right-click pastes text. In current versions of Windows, Ctrl + C and Ctrl + V also work for copy and paste inside the window.
- Drag a file or folder from File Explorer into the window to paste its full path.
- Alt + Enter switches full-screen mode in the classic console window.
exitcloses the window.
Redirection, Pipes and Wildcards
These three ideas turn single commands into powerful ones.
Redirection sends output to a file instead of the screen.ipconfig /all > network.txt saves the result to network.txt. Use >> to add to the end of a file instead of replacing it.
Pipes send the output of one command into another.tasklist | find "chrome" shows only the lines that contain “chrome”.
Wildcards match many files at once. The * stands for any characters and ? stands for one character.
dir *.jpglists all JPG filesdel *.tmpdeletes all files ending in .tmpcopy *.docx D:\Backupcopies all Word documents
Be careful with wildcards in delete commands. Run the same pattern with dir first to see exactly what will be affected.
Command Prompt Cheat Sheet
| Goal | Command |
|---|---|
| List files | dir |
| Open a folder | cd foldername |
| Go back one folder | cd .. |
| Change drive | D: |
| Clear screen | cls |
| Make a folder | mkdir name |
| Copy a file | copy file destination |
| Rename a file | ren old new |
| Delete a file | del filename |
| Show IP address | ipconfig |
| Test connection | ping address |
| List running programs | tasklist |
| Close a program | taskkill /IM name.exe /F |
| Repair system files | sfc /scannow |
| Get help on a command | command /? |
| Close the window | exit |
Common Errors and How to Fix Them
“is not recognized as an internal or external command.”
You mistyped the command, or the program is not installed or not on your system path. Check the spelling. Try command /? to confirm it exists.
“The system cannot find the path specified.”
The folder name is wrong or the folder is on another drive. Use dir to see what is in the current location. Use cd /d to change drives.
“Access is denied.”
You need administrator rights, or the file is in use. Reopen CMD as administrator, or close the program that is using the file.
“The syntax of the command is incorrect.”
A space or quotation mark is wrong. Put paths with spaces in quotation marks.
The command does nothing after you press Enter.
Some commands take time. Wait, or press Ctrl + C to stop it.
You changed to the wrong folder.
Type cd \ to go to the top of the drive, or cd %userprofile% to return to your user folder.
Staying Safe
Command Prompt does exactly what you type and rarely asks you to confirm. A few habits will protect your files.
- Never run a command you found online if you do not understand it. Search the command name or add
/?first. - Be extra careful with
del,rmdir /s,formatanddiskpart, which can erase files or whole drives. - Do not run CMD as administrator unless a task requires it.
- Back up important files before bulk changes.
- Be suspicious of messages or websites that tell you to paste a command into CMD to “fix” something. Scammers use this trick to install malware.
Command Prompt vs PowerShell
Windows has two command-line tools. Command Prompt is older and simpler, and it is good for basic file work and network checks. PowerShell is newer, works with objects instead of plain text and is better for automation and system administration.
Most beginners can start with CMD. If you later want to manage many computers or write advanced scripts, learn PowerShell next. In Windows Terminal you can use both in separate tabs.
For official documentation, Microsoft lists every Windows command at https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands and explains the modern terminal app at https://learn.microsoft.com/en-us/windows/terminal/.

Frequently Asked Questions
How do I open Command Prompt on Windows 11?
Press the Windows key, type cmd and press Enter. You can also right-click Start and open Terminal, then choose Command Prompt from the tab menu.
How do I change directories in Command Prompt?
Use cd foldername to go into a folder, cd .. to go up one level and cd /d D:\Folder to switch to a folder on another drive.
How do I see all files in a folder?
Type dir. Add /a to include hidden files.
How do I copy and paste in Command Prompt?
In current Windows versions, use Ctrl + C and Ctrl + V. You can also right-click to paste.
How do I stop a command that is running?
Press Ctrl + C.
How do I run Command Prompt as administrator?
Search for cmd, right-click Command Prompt and choose Run as administrator.
What does cd .. do?
It moves you up one folder level.
How do I clear the screen?
Type cls and press Enter.
Can Command Prompt harm my computer?
It can if you run destructive commands or follow instructions from untrusted sources. Basic commands such as dir, cd, ipconfig and ping are safe.
Is Command Prompt the same on Mac?
No. On macOS and Linux you use Terminal, and commands such as ls and pwd replace dir and cd without arguments.


