- Master CMD with basic, network, and maintenance commands for Windows 10 and 11.
- Learn about operators, variables, deferred expansion, and autocompletion in cmd.exe.
- Use shortcuts (F1–F9), pipes, and redirects to work faster.
The Command Prompt (CMD) remains a key component in Windows for quick, accurate, and advanced tasks that would sometimes take longer in the graphical interface. Although its appearance is reminiscent of MS-DOS, it's not the same: CMD is the Windows command interpreter , and its usefulness today is enormous for diagnostics, automation, and administration.
In this guide, we've compiled and rewritten the most useful basic and advanced commands for Windows 10 and Windows 11 , covering everything from browsing and file management to networking, maintenance, the syntax of cmd.exe itself, environment variables, shortcuts, and less obvious tricks. Everything is explained with examples , warnings, and best practices so you can navigate the command line with ease.
What is CMD and what is it used for?
CMD, also called Command Prompt , is a text-based console that allows you to interact directly with the operating system. It lets you run individual commands or command strings that are very effective for managing files, diagnosing networks, automating tasks, or accessing options that the GUI doesn't provide as quickly.
Although it shares some similarities with MS-DOS, CMD is not MS-DOS . It's an administrative tool for Windows NT (Windows 7/8/10/11 and Server), capable of running system utilities, .bat scripts , and many .exe files. Furthermore, its commands also work in Windows 11 , so what you learn here will be useful in modern versions of the system.
How to open the console and when to use administrator privileges
There are several ways to open CMD, depending on what's most convenient for you. The most direct is to open the Start menu and type cmd to open the Command Prompt . You can also right-click and choose Run as administrator if you need elevated privileges.
Other practical methods: Windows + R and type cmd; Windows + X and select “Command Prompt” (or Windows PowerShell depending on the version); and from Task Manager (Ctrl + Shift + Esc) under File > Run new task, typing cmd. If you want it to run as elevated privileges, open the shortcut's location , go to Properties > Shortcut > Advanced options, and check “Run as administrator.”
To navigate and find your way around folders, the essential commands are very simple. `CD` changes the directory: `cd Path` or `cd..` to go up one level. `DIR` lists the current contents with files and subfolders, and `TREE Folder` displays the directory tree of a specific path.
When the screen becomes full, CLS clears the console to start over; when you're finished, EXIT closes the window . And if you don't remember the syntax of a command, HELP displays the available list with a brief description, while adding /? to a command (for example, dir /?) shows its parameters.
To create and organize, MD (or MKDIR) FolderName creates a new folder. RENAME renames a file (and its extension if included), though it doesn't magically convert formats. DEL deletes files or folders (be careful not to use it carelessly; if you can't delete them, see how to delete undeletable files ), and FORMAT formats an entire drive, so use it with extreme caution.
Copy, move and advanced utilities
To duplicate files, use COPY Destination File ; if you want to move them, use MOVE Destination File to move them without leaving a copy. When working with large volumes, ROBOCOPY is the Swiss Army knife: fast and robust copying, automatic retries, the ability to resume, and a progress indicator.
If you need to compare, FC shows differences between two files or sets of files. ASSOC reveals which program opens a specific extension, useful for diagnosing file associations. And CIPHER can overwrite free space to make it harder to recover deleted files.
System diagnostics and maintenance
To learn more about your computer, SYSTEMINFO provides details such as hostname, exact Windows version, processor, RAM, motherboard, and storage, among other information. VER returns the numerical system version, and TIME displays or changes the current time, in case you suspect any issues.
In case of errors, CHKDSK checks the disk surface, detects bad sectors, and corrects file system inconsistencies. SFC /scannow examines the integrity of system files and replaces corrupted ones with cached copies (requires CMD as administrator). For additional tasks, it uses the DISM interface.
To free up space, CLEANMGR opens the classic Disk Cleanup tool. If you receive space warnings, you can dismiss the low space alert . If you want to evaluate performance, WINSAT FORMAL runs a general benchmark; you can use variants like CPUFORMAL, MEMFORMAL, GRAPHICSFORMAL , or DISKFORMAL to measure specific components.
Other tasks: DEFRAG defragments the drive; DISKPART manages disks and partitions (LIST DISK, LIST VOLUME for inventory); SHUTDOWN -s -t schedules a shutdown in a few seconds (or -r to restart), and LOGOFF logs you off without turning off the computer. If you need the classic Control Panel, CONTROL PANEL opens it instantly. If you need to merge partitions, see how to merge two NTFS partitions for specific cases.
Networks and connectivity
To begin, IPCONFIG displays IP configuration, subnet mask, gateway, DNS, and much more, ideal for a quick overview of your network. PING checks connectivity to a host; if you need more detailed routing information and hop-to-hop latency, TRACERT and PATHPING are your best friends.
When investigating active connections and ports in use, NETSTAT lists statistics, routing tables, and TCP/IP status. GETMAC gives you the MAC address of the computer's network card, and NSLOOKUP is used to validate DNS resolution of names and IPs. For further analysis, NETSH allows you to modify and diagnose network configurations in depth.
cmd.exe syntax, operators, and colors
The cmd interpreter itself supports very useful parameters: /c executes a command and exits, /k executes it and keeps the console open, /q disables echo, /d disables AutoRun, /a and /u force ANSI or Unicode output, /e:on|off controls command extensions, /f:on|off activates name completion, and /v:on|off enables delayed variable expansion.
To change colors, /t:bf adjusts the background and foreground using hexadecimal digits. These are the valid values:
| Price | Color |
|---|---|
| 0 | Black |
| 1 | Blue |
| 2 | Green |
| 3 | Water |
| 4 | Red |
| 5 | Purple |
| 6 | Yellow |
| 7 | Blanco |
| 8 | Grey |
| 9 | Light Blue |
| a | Light green |
| b | Clear water |
| c | Light red |
| d | Light purple |
| e | Light yellow |
| f | Bright white |
Operators make all the difference: | pipes the output of one command to the input of another; || executes the next one only if the previous one fails; > redirects the output to a file; & chains commands; and && executes them in sequence only if they are successful.
With special characters and paths containing spaces, double quotes are mandatory, and you often need to escape symbols like & , <, >, ( ), |, ^, =, !, +, ~, and spaces. There are peculiarities when combining quotes with /c or /k : if certain conditions aren't met (for example, a single pair of quotes without special characters inside), cmd removes the first and last quotes and processes the rest accordingly.
Environmental variables and deferred expansion
The command prompt environment consists of system and user variables that control the behavior of the shell and Windows itself. To view them, use `set` (in PowerShell, `Get-ChildItem Env: `), and to query a specific variable, use `set VariableName`.
To create or change values, use `set Name=value` ; to delete it, use `set Name= `. If the value contains special characters (>, |, &, ^), you must escape it with ^ or enclose it in double quotes (these are retained as part of the value). For example: `set Name=New^&Name` or `set Name="New&Name"`.
To replace the contents of a variable inline, use %VARIABLE% in commands and scripts: cmd expands it only once (not recursively). If you need to evaluate values after changes within a block, enable delayed expansion (/v:on) and use !VARIABLE!.
Autocomplete files and directories
Name completion is not enabled by default, but you can enable it with cmd /f:on . Additionally, it's possible to configure keys in the Registry at these paths: HKLM\Software\Microsoft\Command Processor\CompletionChar and PathCompletionChar , and their equivalents in HKCU , using REG_DWORD values (for example, 0x9 for TAB or 0x08 for BACKSPACE).
With completion enabled, CTRL+D completes directories and CTRL+F completes files and directories . Repeating these combinations iterates through matches; Shift+the corresponding key moves backward. If you edit the string, the match list is recalculated, and paths with spaces are enclosed in quotation marks to prevent errors.
Shortcuts and time-saving tricks
The function keys speed up working with the history. F1 rewrites the last command character by character; F2 prompts for a character and pastes from the beginning to its first occurrence; F3 rewrites the last command completely; F4 deletes from the cursor to the specified character.
F5 cycles through previous commands (without autocomplete enabled), F6 inserts the EOF flag (^Z), F7 displays a history menu, F8 rewrites previously used commands, and F9 re-executes by number from the F7 menu. You can also use the up arrow to retrieve the previous command with the cursor at the end.
To run multiple commands in succession, chain them together with && or separate them with & if you're not relying on success. If something gets stuck, CTRL+C cancels execution (and if an application freezes, see how to close a frozen application in Windows ). Too much output? Add | more to paginate, | find "text" to filter lines with a specific word, | clip to copy to the clipboard, or > file.txt to save it.
Practical examples and small “recipes”
To clear the screen, `cls` returns the console to a clean state. If you want a plain text listing of everything in a folder, `dir /b > listado.txt` creates a file with the names of the files and subdirectories in the current path.
If you prefer to copy the output to the clipboard, you can type dir | clip and then paste it with Ctrl + V. To type the pipe symbol on many Spanish keyboards, remember that it usually comes out with AltGr + 1.
To repair system files, `sfc /scannow` scans and repairs any corrupted files it finds using local caches. If a large number of errors appear, it might be time to replace the disk before you lose data.
As a curiosity, you can embed a file within an image with: copy /b documento.docx+foto.png salida.pngWhen you open the image, you'll see the photo; when you open the resulting file with the appropriate app (for example, Word), you'll be able to access the hidden document content.
To audit software, `wmic product get name` lists installed programs. There is an uninstallation option using `wmic product where "ExactName" call uninstall /nointeractive` , although it's not the most convenient method because it requires the exact name, so it's not usually the best way to uninstall a large number of programs.
If you would like to change the window title To differentiate instances, use CMD: title MiConsolaTo learn more about controllers, driverquery /fo list /v shows location, status, size and date of each driver (see How to find out which drivers I have installed).
With listings, `dir` supports sorting: for example, `dir /os` (by size) or date options like `dir /od` to view from oldest to newest. Experiment with the `/o` modifier and its sub-options to achieve the desired order based on your criteria.
To inventory the equipment, systeminfo It displays everything on screen (you can combine it with > info.txt to save it). If keeping your software up to date is your thing, winget upgrade –all It detects and updates available apps from the command line, and it is also possible update a specific app with: winget upgrade NOMBRE_PROGRAMA.EXTENSION.
For a quick malware scan with Microsoft antivirus, you can run a quick scan using the Windows Defender command-line utility, for example: mpcmdrun.exe -Scan -1 from its corresponding route.
If you need to see the exact version of Windows your computer is running, type winver . A window will appear showing the edition, build number, and, if the license is linked to your Microsoft account, that association will also be reflected.
Common problems and how to solve them
If CMD displays "Access denied ," you probably lack permissions: reopen the console as administrator. When the message says it can't find the file, check paths, quotation marks, and spaces , as these are often the cause.
If you see "Syntax error ," check the parameters or use /? to recall command options. When a command is "not responding," press Ctrl+C to break execution and check if it needs additional parameters. If you suspect encoding issues, try chcp 65001 (UTF-8) or run the command from PowerShell.
CMD vs PowerShell: Key Differences
Visually they're similar, but they're not in the same league . CMD works with plain text and is ideal for basic tasks, simple .bat scripts, and quick operations. PowerShell works with objects , has its own scripting language, modules, conditionals, loops, and many more advanced automation and management capabilities.
In day-to-day use, CMD remains incredibly convenient for pings, listings, backups, maintenance, and quick diagnostics. If you're looking for complex automation, integrated output, and structured data manipulation, PowerShell is the tool that will give you that extra edge.
Quick FAQ
Are CMD and PowerShell the same thing?
No, they serve different roles : CMD is simpler and more direct for basic tasks; PowerShell is more powerful, flexible, and geared towards complex automation.
What advantages does CMD offer over the graphical interface?
Speed, direct access and automation : you can access options not visible in the GUI and chain commands to save time.
Will CMD still be available in future versions of Windows?
Microsoft maintains support for CMD, although it promotes PowerShell as the primary environment. There is no official announcement of its retirement.
Can I run PowerShell commands in CMD?
Not directlyThey are different languages, although you can open PowerShell from CMD by typing powershell and launch their commands there.
Is it safe to run any command?
It depends on the command . Avoid copying and pasting without understanding it, especially if it modifies the system (formatting, registry changes, deletions).
How do I view the CMD version?
Type ver for system version or cmd /? for command interpreter information on your installation.
Can the window appearance be customized?
Yes, in Properties (right-click on the title bar): colors, fonts, window size, and more.
What happens if a command doesn't exist?
Permissions may be missing or the command may not be available in your edition . Try running as administrator and confirm that it's not a PowerShell-exclusive command.
Can changes made using CMD be undone?
Not always : Deleting without a backup is irreversible. For configuration settings, look for the opposite command or restore from a backup.
With all of the above, you now have a complete repertoire for mastering CMD : from navigating folders, copying or comparing files, and managing the system, to exploring the network, chaining commands with operators, maximizing variables and autocomplete, or using little-known shortcuts. Used wisely , the Command Prompt becomes a productivity booster and a lifeline when the interface falls short.