Open In App

39 Windows CMD Commands for Everyone (2025 Updated)

Last Updated : 10 Feb, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The Windows Command Prompt (CMD) is a powerful tool that allows users to interact with their operating system through text-based commands. Whether you're a beginner exploring CMD for the first time, an expert troubleshooting advanced issues, or just looking for utility-focused tasks, this guide has you covered.

In this guide, we will provide you with some of the most useful commands for the following:

  • CMD Commands for Beginners
  • CMD Commands for Experts
  • CMD Commands for Utility
  • CMD Commands for Troubleshooting
  • CMD Commands for Students
  • CMD Commands for Programmers

CMD Commands for Beginners

These commands are essential for users who are new to CMD and provide basic functionalities to help them navigate and perform simple tasks.

1. View Directory 'dir'

  • Function: Displays the contents of the current directory.
  • How to use: Type dir and press Enter. Use dir /s to include subdirectories.
  • Use case: Quickly view files and folders in your current location.
Syntax: dir

2. Change Directories 'cd'

  • Function: Lets you navigate between folders.
  • How to use: Type cd [folder_name] to move into a directory. Use cd .. to go up one level.
  • Use case: Navigate to specific directories to manage files or execute commands
Syntax: cd [folder name]

3. Create a New Directory 'mkdir' or 'md'

  • Function: Allows you to create a new directory
  • How to use: Type mkdir [file_name]- Here the new directory name is GFG
  • Use case: When you need a new directory for any separate work, you may create a new directory
Syntax: mkdir [GFG]

4. Rename a File 'ren'

  • Function: Helps in renaming any file or directory.
  • How to use: Type ren or rename [old_name] [new_name] and press Enter.
  • Use case: Discover new method of renaming file or any directory.
Syntax: ren xyz.txt newxyz.txt

5. Delete a File 'del'

  • Function: Lets you to remove one or more files
  • How to use: Type del [file_name]- This will erase the provided file name
  • Use case: This function allows you to erase any file if you're unable to fetch
Syntax: del[file_name]

6. Close 'exit'

  • Function: Closes the Command Prompt window.
  • How to use: Type exit and press Enter.
  • Use case: Ends your session with CMD.
Syntax: exit

7. Clear Screen 'cls'

  • Function: Clears all text from the CMD window.
  • How to use: Type cls and press Enter.
  • Use case: Removes clutter after multiple commands
Syntax: cls

8. View Available Command 'help'

  • Function: Lists all available commands and their descriptions.
  • How to use: Type help and press Enter.
  • Use case: Discover new commands and learn their functions.
Syntax: help

9. Display or Set the System time 'time'

  • Function: Lets you set the system time or display the current time.
  • How to use: Type time [new_time] and press Enter.
  • Use case: Allows the user to set their system's time without additional navigation
Syntax: time [new_time]

10. Copy Files 'copy'

  • Function: Lists all available commands and their descriptions.
  • How to use: Type copy [source1] [destination2] and press Enter.
  • Use case: Discover new commands and learn their functions.
Syntax: copy file.txt Backup\
CommandDescriptionSyntaxExample
dirView the contents of a directorydirdir C:\Users\Documents
cdChange the current working directorycd [directory_name]cd Downloads
mkdirCreate a new directorymkdir [directory_name]mkdir NewProject
renRename a fileren [old_name] [new_name]ren draft.txt final.txt
delDelete a filedel [file_name]del unwanted.txt
exitClose the Command Promptexitexit
clsClear the Command Prompt screenclscls
helpView available CMD commands and their descriptionshelphelp
timeDisplay or set the system timetimetime 14:30:00
copyCopy files from one location to anothercopy [source] [destination]copy report.docx D:\Backup\

CMD Commands for Experts

These commands are more advanced and suitable for users comfortable with troubleshooting and system management tasks.

1. System File Checker 'sfc'

  • Function: Scans and repairs corrupted system files.
  • How to use: Type sfc /scannow in CMD (run as administrator).
  • Use case: Fix system errors related to missing or corrupted files.
Syntax: sfc /scannow

2. Disk Error 'chkdsk'

  • Function: Scans the hard drive for bad sectors and file system errors.
  • How to use: Type chkdsk [drive letter]: /f (e.g., chkdsk C: /f) in CMD.
  • Use case: Identify and fix disk issues.
Syntax: chkdsk C: /f

3. View Running Processor 'tasklist'

  • Function: Displays all running processes and their details.
  • How to use: Type tasklist to list processes. Use tasklist /fi "imagename eq [process name]" to filter.
  • Use case: Identify resource-heavy or unresponsive processes.
Syntax: tasklist /fi "imagename eq [process name]

4. Restart 'shutdown'

  • Function: Allows you to shut down or restart the computer via CMD.
  • How to use:
    • Shutdown: shutdown /s /f /t [seconds].
    • Restart: shutdown /r /f /t [seconds].
  • Use case: Automate shutdown or restart tasks
Syntax: 
Shutdown: shutdown /s /f /t [seconds].
Restart: shutdown /r /f /t [seconds].

5. Network Statistics 'netstat'

  • Function: Displays active connections and listening ports.
  • How to use: Type netstat to view all active connections.
  • Use case: Diagnose network-related issues or monitor network activity.
Syntax: netstat

6. Kill a Running Process 'taskkill'

  • Function: Lets you terminate a process using its process ID (PID)
  • How to use: Type taskkill /[PID] /F to terminate
  • Use case: Can be helpful for terminating any dedicated PID.

Example (PID: 1124)

Syntax: taskkill /PID 11234 /F

7. View Saved Passwords 'netsh wlan show profiles'

  • Function: Retrieve the password of a saved Wi-Fi network.
  • How to use: Type netsh wlan show profile name="WiFi-Name" key=clear
  • Use case: Discover new commands and learn their functions.
Example: netsh wlan show profile name="MyHomeWiFi" key=clear
CommandDescriptionSyntaxExample
sfcSystem File Checker - Scans and repairs system filessfc /scannowsfc /scannow
chkdskCheck Disk - Scans and fixes disk errorschkdsk [drive]: /f /rchkdsk C: /f /r
tasklistView running processestasklisttasklist
shutdownShutdown or restart the systemshutdown /r /t [seconds]shutdown /r /t 10 (Restart in 10 seconds)
netstatView network statistics and active connectionsnetstat -anetstat -an (Show all connections numerically)
taskkillKill a running process using its process ID (PID)taskkill /PID [PID] /Ftaskkill /PID 4567 /F (Kill process with ID 4567)
netsh wlan show profilesView saved Wi-Fi network namesnetsh wlan show profilesnetsh wlan show profiles

CMD Commands for Utility

These commands are focused on specific tasks and utilities to enhance productivity and system performance.

1. Network Configuration 'ipconfig'

  • Function: Displays IP address, subnet mask, and gateway information.
  • How to use:
    • Basic: Type ipconfig.
    • Detailed: Type ipconfig /all.
  • Use case: Troubleshoot internet connectivity issues.
Syntax: ipconfig

2. Network Connectivity 'ping'

  • Function: Sends packets to test communication with another device or website.
  • How to use: Type ping [destination] 
  • Use case: Check if a device or website is reachable.
Syntax: ping geeksforgeeks.org

3. System Information 'systeminfo'

  • Function: Displays detailed information about your computer.
  • How to use: Type systeminfo.
  • Use case: Quickly access system specifications for troubleshooting or reporting.
Syntax: systeminfo

4. Trace Route 'tracert'

  • Function: Shows the path packets take to reach a specific destination.
  • How to use: Type tracert [destination]
  • Use case: Identify network bottlenecks or connectivity issues.
Syntax: tracert geeksforgeeks.org

5. Manage Drives 'diskpart'

  • Function: Opens a command-line utility for managing disk partitions.
  • How to use: Type diskpart to enter the disk management interface.
  • Use case: Create, delete, or modify partitions on your drives.
Syntax: diskpart

6. Delete a Directory 'rmdir'

  • Function: Removes directory from the origin
  • How to use: Type rmdir [directory_name] and press Enter.
  • Use case: Discover new commands and learn their functions.

Example: GFG - Directory name

Syntax: rmdir GFG

7. View 'rmdir'

  • Function: Removes directory from the origin
  • How to use: Type rmdir [directory_name] and press Enter.
  • Use case: Discover new commands and learn their functions.
Example: GFG - Directory name

8. Manage User Account 'net user'

  • Function: To list all the user accounts
  • How to use: Type net user and press Enter.
  • Use case: Discover new commands and learn their functions.
Syntax: net user username password /add

9. View Startup Programs 'wmic startup get caption,command'

  • Function: To check what programs launch on startup.
  • How to use: Type wmic startup get caption,command, and press Enter.
  • Use case: Discover new commands and learn their functions.
Syntax: wmic startup get caption,command
CommandDescriptionSyntaxExample
ipconfigView network configuration, including IP address, subnet mask, and gatewayipconfigipconfig /all (Displays detailed network info)
pingTest network connectivity by sending packets to a hostping [host or IP]ping google.com (Check connection to Google)
systeminfoDisplay detailed system information, including OS version, installed memory, and processorsysteminfosysteminfo
tracertTrace the route packets take to a network destinationtracert [hostname or IP]tracert google.com (View network path to Google)
diskpartManage disk partitions, including creating, formatting, and deleting partitionsdiskpartdiskpart → list disk → select disk 1 → create partition primary
rmdirDelete a directory (folder)rmdir [directory_name]rmdir /s /q OldFolder (Delete a folder and its contents without confirmation)
dirView contents of a directorydirdir C:\Users\Documents (List files in a specific directory)
net userManage user accounts, including adding, modifying, or deleting usersnet usernet user John password123 /add (Create a new user account)
wmic startup get caption,commandView startup programs and their commandswmic startup get caption,commandwmic startup get caption,command

CMD Commands for Troubleshooting

1. File Comparison 'fc'

  • Function: Compares two files and highlights differences.
  • How to use: Type fc [file1] [file2] to compare files.
  • Use case: Detect changes or errors in files
Syntax: fc 1 2

2. Advanced Network Diagnostics 'pathping'

  • Function: Combines ping and tracert functionalities to provide detailed network path diagnostics.
  • How to use: Type pathping [destination]
  • Use case: Troubleshoot complex network issues.
Syntax: pathping geeksforgeeks.org

3. Registry Editor 'regedit'

  • Function: Launches the Windows Registry Editor.
  • How to use: Type regedit to open the registry.
  • Use case: Modify registry keys for advanced configuration or troubleshooting.
Syntax: regedit

4. View MAC 'getmac'

  • Function: Displays the MAC address of your network adapter.
  • How to use: Type getmac to view the MAC address.
  • Use case: Identify your device's hardware address for network configurations
Syntax: getmac

5. Power Configuration 'powercfg'

  • Function: Displays and manages power settings.
  • How to use: Type powercfg /[option] 
  • Use case: Optimize power usage and troubleshoot battery issues.
Syntax: powercfg /energy for a detailed power usage report

6. Enable Boot Manager 'bcdedit'

  • Function: Used to modify boot configuration settings
  • How to use: Type bcdedit / set current
  • Use case: Discover new commands and learn their functions.
Syntax: bcdedit /set {current} bootmenupolicy standard

7. Format a Drive 'format'

  • Function: To erase any specific drive.
  • How to use: Type format [drive]: /FS:NTFS and press Enter.
  • Use case: Discover new commands and learn their functions.
Syntax: format D: /FS:NTFS
CommandDescriptionSyntaxExample
fcCompare two files and highlight differencesfc [file1] [file2]fc file1.txt file2.txt (Compare two text files)
pathpingPerform advanced network diagnostics with packet loss detailspathping [destination]pathping google.com (Analyze network route to Google)
regeditOpen the Windows Registry Editor (GUI)regeditregedit (Opens the registry editor – use with caution!)
getmacDisplay the MAC (Media Access Control) address of your network adaptersgetmacgetmac /v /fo list (View MAC addresses in detailed format)
powercfgManage and analyze power configurationspowercfg /[option]powercfg /batteryreport (Generate a battery usage report)
bcdeditEnable, disable, or modify Windows Boot Configurationbcdedit /set {current} [option]bcdedit /set {current} bootmenupolicy standard (Enable boot menu in Windows 10/11)
formatFormat a drive (erase all data)format [drive]: /FS:[filesystem]format D: /FS:NTFS (Format drive D: with NTFS file system)

CMD Commands for Students

Students can use these commands to manage files, perform simple calculations, and even help with tasks like coding and studying.

1. Calculator 'calc'

  • Function: Opens the Windows Calculator application.
  • How to use: Type calc and press Enter.
  • Use case: Quickly open the calculator for
Syntax: calc

CMD Commands for Programmers

Programmers often use CMD to automate tasks, compile code, and test network functionality. These commands can be especially useful for developers working in command-line environments.

1. Compile Java Code 'javac'

  • Function: Compiles Java source files into bytecode.
  • How to use: Type javac [file name].java to compile Java code.
  • Use case: Compile and test Java programs directly from the command line.
Syntax: javac

2. Version Control 'git'

  • Function: Interacts with Git repositories from the command line.
  • How to use: Type git [command]
  • Use case: Manage version control, clone repositories, or push commits from the command line.
Syntax: git clone [repository URL]

3. Execute Python Script 'python'

  • Function: Runs Python scripts in the command prompt.
  • How to use: Type python [script.py] to execute a Python program.
  • Use case: Test and run Python code directly in the command line.
Syntax: python [script.py]

4. Run Node.js Scripts 'node'

  • Function: Executes Node.js scripts.
  • How to use: Type node [script.js] to run a JavaScript file using Node.js.
  • Use case: Run backend scripts and test JavaScript programs in the command line.
Syntax: node [script.js]

5. Node Package Manager 'npm'

  • Function: Installs and manages JavaScript packages.
  • How to use: Type npm install [package] to install a package.
  • Use case: Manage dependencies and libraries in Node.js applications.
Syntax: npm install [package]
CommandDescriptionSyntaxExample
javacCompile Java source code into bytecode (.class files)javac [filename].javajavac HelloWorld.java (Compile a Java file)
gitVersion control system for tracking changes in filesgit [command]git clone https://github.com/user/repo.git (Clone a repository)
pythonExecute a Python script or enter interactive modepython [script.py]python script.py (Run a Python script)
nodeExecute JavaScript code using Node.jsnode [script.js]node app.js (Run a Node.js script)
npmManage Node.js packages and dependenciesnpm [command]npm install express (Install the Express.js package)

Bonus: CMD Tricks and Tips

To make CMD usage even more efficient, here are some bonus tips:

1. Save CMD Output to a File

Use the > operator to save the output of a command to a text file.

2. Open CMD in a Specific Directory

Instead of navigating manually, you can directly open CMD in a folder by typing cmd in the File Explorer's address bar.

3. Use && for Multiple Commands

You can run multiple commands sequentially:

ipconfig && ping google.com

Conclusion

Mastering the most useful CMD commands in Windows can empower you to perform tasks more efficiently, troubleshoot problems, and gain deeper control over your system. By familiarizing yourself with these essential CMD commands, you’ll be better equipped to handle a variety of situations, from simple file management to advanced system configurations. Whether you're a beginner or an experienced user, these commands are invaluable tools to have at your disposal.


Next Article

Similar Reads