Most of us rely on the Graphical User Interface (GUI) as it’s more convenient than memorizing the traditional command lines. But one thing is certain—you can’t perform every task in the Windows GUI, and that’s when Command Prompt can be at your service.
This built-in command line interface can produce immediate outputs using simple commands with fewer computer resources. This way, you do not have to navigate through different windows just to get a single task done. With this program, you can perform advanced administrative functions or troubleshoot different Windows issues on your own!
In this article, I will discuss 50 commands you must know to master Command Prompt. But if you’re relatively new to this utility, I advise checking our beginner’s guide first.
Before deep diving into the major commands, I’ll start with the basic ones. Whether you’re planning to use Command Prompt extensively or just for general purposes, these are going to be useful.
|Clears the Command Prompt screen
|Quits Command Prompt
|Provides help with a certain command
|Moves you from one directory/drive to another
|Copies the content to Windows Clipboard
|Displays your present Windows version
This command simply clears the Command Prompt screen. If you feel to clear up the working space after executing too many commands, it can be extremely helpful. All you have to do is type
cls and hit Enter.
If you’re planning to close the Command Prompt application, you do not require moving the cursor to press the Close button. Simply run the exit command and the program quits.
You can also use the
/b parameter to exit from the loaded batch script. This way, the main window remains open and only the batch file is exited. However, if you use the parameter outside the script, it will close the CMD app.
where error code specifies a certain number
This command comes in handy if you come across any command and wish to know its function. It provides you with the syntax along with the different parameters (switches).
If you simply execute help, it displays a list of the common commands used in Command Prompt.
However, not all commands support this utility. In that case, you may use the
/? parameter and this should work for every command.
CD or CHDIR
It simply means ‘Change Directory’ and as the name suggests, it switches you from the current directory based on the specified path.
If you simply execute cd, it will just display the name of your current directory. Therefore, it’s important to learn the different parameters along with their functions and syntax:
|Displays the drive along with the last directory location
|Takes you to the directory as per the specified location
|cd /d [drivename]:
|Takes you to the previous/root directory
This command copies the output executed from a certain command into the Windows clipboard. In this way, you can directly copy the data into any other program.
It’s extremely useful to directly copy the text or script files without opening them. Here are the parameters associated with it:
|Copies the output of a certain command to the Windows clipboard
|<command> | clip
|Copies the content of a certain file
|clip < filename
Command Prompt offers the quickest way to view the version number of Windows using a simple command. This way, you can determine whether the latest Windows version is installed on your computer.
Whether you’re trying to learn about your computer or perform some system-related tasks, the following commands can come in handy:
|Controls power system settings
|Logs off, restarts, or shuts down your computer
|Displays all the installed drivers
|Displays the name of the computer’s host
|Displays detailed information about your system
This Command Prompt utility allows you to control the overall power settings of your computer. Note that if you use it without the appropriate parameters, you’ll encounter an “Invalid parameters” error.
While there are plenty of parameters available, I’m only going to discuss the most common ones below. If you want to learn more, simply execute
|/list or /l
|Displays all the available power schemes
|powercfg /list or powercfg /l
|Delete a specific power setting
|powercfg /deletesetting <sub_guid> <setting_guid>
|Makes a scheme active
|powercfg /setactive <scheme_guid>
|Fetches your current power scheme
|/hibernate or /h
|Used to enable/disable hibernation
|powercfg /hibernate [parameter]
|/availablesleepstates or /a
|Displays the available sleep states on your computer
|powercfg /availablesleepstates or powercfg /a
|Displays those devices that meet the specified criteria (query flag)
|powercfg /devicequery <queryflag>
|Allows the specified device to wake the computer from sleep
|powercfg /deviceenablewake <devicename>
|Disables the device to wake the computer from sleep
|powercfg /devicedisablewake <devicename>
|Displays the activity that last woke your system from sleep
To learn the above commands in detail, I recommend executing the
powercfg /? <parameter> command.
For example, if you wish to know more about the
/list parameter, you can execute
Interestingly, you can turn off your computer using a single command on Command Prompt. Also, it’s possible to schedule the shutdown process as you desire.
Here are some common parameters that might be useful:
|Opens up the Remote Shutdown dialogue
|Logs you out
|Restarts your computer
|Cancels the shutdown operation
|Hibernates your computer
|Sets the time-out period before the shutdown
|shutdown /r /t xxx
|Ends all the applications and signs you out of the computer
Moving on, device drivers are integral components of a computer. If you seek information on them, we already have the Device Manager utility on Windows GUI.
However, if you wish to display detailed driver information while working on the command-line interface, you may simply type
driverquery and hit Enter.
Along with that, you can utilize the following parameters each having individual functions:
|Specifies the name and IP address of your computer
|driverquery /s [system]
|/u <domain> <username>
|Specifies the user’s credentials and can only be used after /s is specified
|driverquery /s [system] /u [username]
|Specifies the user’s password and can only be used after /u is specified
|driverquery /s [system] /u [username] /p [password]
|Displays the output in the specified format–table, list, or csv
|“No header”, meaning the header is not displayed (doesn’t work for /fo list)
|driverquery /fo [table/csv] /nh
|Displays signed drivers
|Displays verbose output (doesn’t work for signed drivers)
This command prints the device name. If you’re unsure about yours or you’re trying to identify it on another computer, simply typing hostname and pressing Enter in the Command Prompt will display the result.
Unlike the hostname command, this will print detailed information about your computer. Basically, it’s like launching the System Information application to check your PC specs.
Moreover, you can use the same parameters used in
devicequery (/s, /u, /p, /fo, /nh, /si, and /v) to print the output in your desired format.
Windows Troubleshooting Commands
If you’re facing a Windows-related issue, there could be several causes for it—corrupted drive, system files, images, or more. Usually, running useful troubleshooters and commands can fix the problem, and that’s exactly what I will cover in this section.
|Checks your disk drives to identify and fix possible errors or bad sectors
|Scans the system files to determine corrupted ones and replaces them with a cached copy
|Manages Windows images
|msdt.exe -id DeviceDiagnostic
|Starts Hardware and Devices troubleshooter
This command checks for the local disks on the computer and informs users about logical and physical errors. Note that fixing errors is only possible if you use the following parameters wisely.
Here, I have only discussed the common ones. But if you want to learn more, here’s a complete guide on how to run CHKDSK to repair and fix a hard drive.
|Scans the specified volume
|Fixes errors on locked disks (otherwise it first asks you to dismount the volume and completes the scan once you restart your PC)
|Displays path and name of every file for FAT/FAT32 disks and cleanup messages on NTFS
|Fixes the physical disk errors and performs all the operations that the /f parameter does
|Forces the volumes to be dismounted before performing the scan
|A quicker way to scan for disk errors for NTFS drives
|Performs offline scans to fix disk errors
The Windows System File Checker (SFC) helps you repair corrupted Windows files. It works by replacing corrupted files, which can even optimize the computer’s performance.
Here are some of the most used SFC commands:
|All system files are scanned and repaired
|All system files are scanned (no repair)
|The user-specified system file is scanned and repaired
|sfc /scanfile=[file path]
|The user-specified system file is scanned (no repair)
|sfc /verifyfile=[file path]
This command starts the Deployment Image Servicing and Management tool to configure the features and packages of Windows images. There are plenty of DISM commands to use when troubleshooting Windows, including FFU, WIM, Imaging, and more. But I will only be discussing the common parameters.
For your comfort, we have already provided a detailed guide on running different DISM commands.
|Targets running OS
|dism.exe /online [parameters]
|Specifies the path of an offline Windows image
|Displays all files and folders in the specified Windows image
|dism.exe /list-image ImageFile:<path_to_image_file>
|Deletes the specified Windows image from the WIM file
|dism.exe /delete-image /ImageFile:<path_to_image_file>
msdt.exe -id DeviceDiagnostic
The Hardware and Devices troubleshooter is no longer available with the other troubleshooters in Windows Settings. However, the utility can find and fix related problems with all hardware components.
In Windows 11, you can launch it using the
msdt.exe -id DeviceDiagnostic command on Command Prompt.
File and Directory Management Commands
Managing files and directories on Command Prompt can be a little tricky. Nevertheless, here are some of the basic commands that can make your tasks a lot easier.
|Displays all the files and folders inside a directory
|Copies files within the directory or from one to another directory
|Transfers files from one directory to another
|Deletes a file or directory
|Creates a new directory
|Changes file name
|Deletes an existing directory
|Displays content of a text file
|Modifies the file type
|Compares two files and displays their differences
|Changes a directory’s attributes
|Graphical representation of a directory structure of a specified path
This command displays all the files and directories/subdirectories from the specified drive/directory.
Most users utilize this command to list the files and directories. This is possible by simply executing the dir command. Along with the listings, it also displays the volume’s label, serial number, and the total number of files and directories.
Apart from that, you can also utilize the following parameters:
|Displays the files inside the specified drive
|Displays the files from the specified location
|Displays just the list of items without any additional information
|Displays all the files inside the directories, their subdirectories, and files
|Lists all the files in a wide format
|Same as /w but sorts them by column
As the name suggests, this command copies the files from one location to another. Note that it will just create a duplicate instead of moving it.
For example, to copy the
example.txt file from the D drive to the Example folder in the same drive, here’s the command I’ll use:
copy example.txt Example
This command functions the same way as
copy. However, the difference is that it actually moves the file from one location to the other. It’s basically the cut-and-paste technique we use in Windows GUI.
For example, to move the
example.txt file from the D drive to the Example folder in the same drive, here’s the command I’ll use:
move example.txt Example
Del or Erase
Both the Del and Erase commands can be used to permanently delete a file. This means that you can’t retrieve the file back from the Recycle Bin.
For example, to delete the
example.txt file permanently, here’s the command I’ll execute:
MKDIR or MD
Both the MKDIR and MD commands are used to create a new directory (folder). You can do this in the present directory or even on another directory directly, meaning you do not require moving to that specific drive/directory to create one.
For example, if I’m in D drive and wish to create a new directory, here’s the command I’ll use:
But if wish to create a new directory in a specific path, here’s what I would execute:
Rename or Ren
Ren or Rename command simply reconfigures the file or directory name. While doing so, make sure you do not duplicate the name with any other file/directory.
Taking the same example as above, here’s how I am going to rename the two files I had created earlier:
ren MyDirectory MyDir
ren C:\Users\bishu\Desktop\MyDirectory MyDir
RMDIR or RD
It stands for ‘Remove Directory’ and that’s exactly what the command does. You may also use a shorter command that performs the same action–RD.
Here are all the parameters for the RMDIR command:
|Deletes the directory as per the specific path
|Deletes the directory along with all the files inside it (asks for confirmation)
|rmdir /s [path]\[dir_name]
|Deletes the directory along with all the files inside it (doesn’t ask for confirmation)
|rmdir /q [path]\[dir_name]
As an example, I’m going to show you how to delete the MyDirectory file that I created earlier:
This command is used to display a text file’s content on Command Prompt. This way, you do not have to navigate to a certain location, open the file, and again close it if not necessary.
You may skip [path] if you’re in the same directory as the text file.
This command is used to display or manage different file name extension associations. Note that you require administrative privilege to modify the associations.
If you simply execute the assoc command, the command-line utility lists all the extensions along with their associated file types.
Also, you can check which file extensions are associated with individual file types. For example, you can find out all the extensions that are associated with ‘sysfile’ as shown in the below example.
assoc | find “sysfile”
It’s possible to modify the associations too. You can associate any file extension to whichever file type you want.
Lastly, you can even delete an association. However, you’ll need to restart your computer to apply the changes.
FC stands for “File Compare” and as it sounds, it’s used for comparing two files so that you can learn about their differences. As shown in the demonstration above, I have compared two text files to know the item difference inside them.
Here are some of the useful parameters for the FC command:
|Comparison in binary mode
|fc <file1> <file2> /b
|Ignores the letter case during comparison
|fc <file1> <file2> /c
|Displays the line number
|fc <file1> <file2> /n
|Comparison of Unicode text files
|fc <file1> <file2> /u
|Ignores consecutive spaces when comparing
|fc <file1> <file2> /w
This command manages the attributes for files and folders. You can set whatever attribute you wish—Hidden, Read-Only, System, and more. To set an attribute, use ‘+’ and to remove, use ‘-’.
|Not content Indexed
If you’re wishing to view the subdirectories inside of a directory or a drive, the tree command will make it look graphically pleasing. It structures the document in an easy-to-view format. All you have to do is run the tree command and specify the path if required.
Below are the two parameters you can adopt with the tree command:
|Displays the lines using text characters instead of graphical representation
|tree <path> /a
|Displays all the items in the drive/directory
|tree <path> /f
Disk/Drive Management Commands
Along with file and directory management, it’s also possible to configure disks and drives in Command Prompt.
Here are the 7 most used commands for this purpose:
|Displays the disk volume’s label and serial number
|Formats a certain drive in the specified file system
|Manages storage drive partitions
|Defragments the specified hard drive
|Displays the amount of used and free space available on the specific disk
This is a command to quickly check the volume name or serial number. All you have to do is execute
vol with the drive letter.
While there already exists easy-to-use GUI applications for formatting your disk drives, it’s never a bad idea to learn this on Command Prompt.
If you want to format a hard drive having just one partition, the format command should work out for you. However, the better option would be using
diskpart, which I shall discuss below.
Here, I’ll only mention the common parameters. Nonetheless, you can go through the other guide that should help you format a hard drive from CMD in detail.
|Specifies the volume label of the drive you’re trying to format
|Performs a quick format
|format <drivename>: /q
|Formats the drive with specific file system
|format <drivename>: /fs:<filesystem>
|Completely wipes the drive
|format <drivename>: /p:<count>
This is a command-line interpreter that offers disk management features on Command Prompt. With this utility, you can assign drive letters, manage the drive attributes, configure partitions, display disk information, format a drive, and much more.
diskpart and this should launch the interpreter. However, you require administrative privilege to use it.
In the table below, I have mentioned the most used commands in Diskpart. If you wish to learn more about disk partitions using the
diskpart command, you can check out our dedicated guides for both HDD and SSD.
|Displays the volumes, disks, partitions, or virtual disks based on the parameter specified
|Selects a volume, disk, partition, or virtual disk based on the parameter specified
|Creates a volume, partition, or virtual disk file based on the parameter specified
|create <partition/disk/vdisk> <parameters>
|Assign a drive letter or mount point to the selected volume
|Formats a disk
|Exits the Diskpart interpreter
Defragmentation simply means reorganizing the data inside an HDD to achieve better performance (not recommended on SSD).
Like any other action, Windows already offers a dedicated utility.
However, if you wish to know this in detail, Command Prompt offers tons of parameters that should help you out. Note that this command requires administrative privilege.
|Defrags the specified drive (traditional defragmentation, default parameter is set to /d)
|Analyzes the selected drive
|defrag <driveletter>: /a
|Performs boot optimization on the selected drive
|defrag <driveletter>: /b
|Runs operations on all the volumes
|defrag <driveletter>: /c
|Runs operations in normal priority
|defrag <driveletter>: /h
|Prints the progress
|defrag <driveletter>: /u
This might not be the most used command but is definitely worth it. You can get the summarized details on the selected disk’s usage in no time.
Simply executing the
diskusage command should do the job (note that you need to open CMD as an administrator). Along with that, you can take a look at the following parameters that might be beneficial:
|Displays the result in CSV format
|diskusage /c <drive>:
|Displays the result in human-readable format
|diskusage /h <drive>:
|Displays size for system files only
|diskusage /s <drive>:
Unlike others, networking commands are widely used mainly for troubleshooting purposes. In fact, fetching IP addresses or configuring network settings is much easier on Command Prompt than using GUI components.
If you’re a networking enthusiast, here are the commands that you need to focus on:
|Manage network and its settings
|Displays detailed information about your network configuration
|Starts the Netsh prompt that lets you manage network configurations
|Displays active network connections
|Verifies IP-level connectivity and reachability
|Checks the computer’s path to connect to the network
|Traces the route to the target and also displays the statistics (combination of ping and tracert)
|Displays the MAC address
|Displays the information about domain names and IP addresses
You can use this command to manage different networking services. It comes with multiple options each performing a specialized task.
Here, I’ve only mentioned the most common ones. You can execute the
net command without a parameter to get more.
|Configures login requirements
|Manages computers in the domain
|Restarts a service
|Starts a networking service
|Stops a networking service
|Displays all the devices in a network
|Displays network statistics
ipconfig without parameters displays the IPv4, IPv6, subnet mask, and default gateway for every adapter. For other purposes, you can adopt the following parameters:
|Displays TCP/IP configuration for all adapters
|Flushses the DNS client resolver cache
|Releases the DHCP configuration for the specified adapter (you can simply execute the /release parameter to release the configuration for all the adapters at once)
|ipconfig /release <adapter>
|Renews DHCP configuration for the specified adapter (if not specified, renews for all the adapters)
|ipconfig /renew <adapter>
This is another essential networking command used for managing network configurations. You can execute
netsh to launch the dedicated shell. After that, you can perform desired networking operations using some of the well-known parameters from the below table:
|Manages the DHCP client service
|Manages DNS client settings
|Manages the Windows firewall service
|Manages physical or virtual network adapters
|Manages LAN settings on your computer
|Manages wireless network settings on your computer
|Manages namespace configurations
|Sets the mode to offline
|Sets the mode to online
|Exits the Netsh shell
|Manages Winsock settings
This command lists the active connections on your computer. It displays the protocol, local as well as foreign address, and the current state. Just executing the
netstat command will list the active TCP connections.
To display other protocols, here are some parameters you can use:
|Displays all the active TCP and UDP connections
|Displays all active connections along with each process (requires admin privilege)
|Displays the interface statistics
This command is widely used for testing host-server reachability and internet connectivity. Executing
ping displays the IP address statistics and the approximate round trips in milliseconds.
Here are a few parameters that I recommend trying out:
|Continues displaying stats until interrupted by pressing CTRL+C
|ping -t <target_name>
|Displays stats based on the specified number of echo Request messages
|ping -n <number> <target_name>
|Displays stats based on the specified length
|ping -l <number> <target_name>
This command traces the route to a certain IP or domain by sending ICMP or ICMPv6 messages with increasing TTL values. It’s extremely useful during network troubleshooting as it informs users about the routing issues and validates the network paths.
tracert command without a parameter traces the route of the specified domain/IP over a maximum of 30 hops.
Nevertheless, you could make use of the following parameters to gain additional networking information:
|Displays results in ‘n’ no. of maximum hops specified
|tracert -h <hops_in_number> <target_name>
|Doesn’t resolve IP address making the results appear much faster
|tracert -d <target_name>
|Specifies the maximum time to wait for echo Reply message (if not, displays *)
|tracert -w <max_time> <target_name>
|Uses IPv4 to trace the route
|tracert -4 <target_name>
|Uses IPv6 to trace the route
|tracert -6 <target_name>
This command is a combination of Tracert and Ping. When executed without a parameter, it traces the route to the target over a maximum of 30 hops and computes statistics for 125 seconds (by default).
Here are some of the most used
|Displays results based on the maximum hops specified
|pathping -h <number> <target>
|Waits between consecutive pings before displaying the stats
|pathping -p <max_period> <target>
|Specifies the maximum time to wait for each reply
|pathping -w <max_time> <target>
|Only uses IPv4
|pathping -4 <target>
|Only uses IPv6
|pathping -6 <target>
If you wish to get the MAC address of your computer, you can execute the
getmac command and this will display the result in no time. The result includes both the physical address and the transport name.
Along with that, I highly recommend trying out the following parameters:
|Displays the results for the specified computer name of IP address
|getmac /s <computer>
|Displays in the specified format
|getmac /fo <table/list/csv>
|Displays in the table or CSV format excluding the column header
This is yet another command-line utility that includes numerous commands to obtain domain name or IP address information. To start the prompt, simply type
nslookup in the Command Prompt and hit Enter.
While there are countless parameters for
nslookup, I’m only going to focus on a few common ones in the table below:
|Connection with finger server
|Displays DNS domain information
|Changes default server to the specified DNS using current server
|Changes server to the specified DNS using default server
|Different parameters (all, class, d2, etc.) are used to set various DNS-related settings
If you have implemented each of the commands I’ve discussed, you should now be proficient enough to use Command Prompt. However, the aforementioned commands are not enough to master this Windows command-line interface.
There are thousands more, and it’s impossible for me to include all of them in this single post.
For now, I would recommend trying out the following commands that could come in handy while you’re on the way to mastering Command Prompt:
|Displays all the currently running processes
|Kills a process
|Starts Windows PowerShell session
|Manages Windows environment variables
|Runs the specified program
|Repairs the boot environment
|Displays today’s date
|Changes the cmd text
|Customizes foreground and background color
You can use this command to display the currently running processes on your computer. Executing
tasklist lists down the name of the process, its PID, session name, session number, and memory usage. Also, you can try out the following parameters:
|Displays all the processes of the specified computer name or IP address
|tasklist /s <computer>
|Displays all the modules of currently running processes
|Displays the results in a specified format
|tasklist /fo <table/csv/list>
|Displays the results in table or CSV format without the header column
|Displays all the services associated with the currently running processes
tasklist command displays the processes,
taskkill kills/ends them. You can use either process ID or image name to do this task. Therefore, you need to utilize any of the following common parameters:
|Kills the process as per the specified process ID
|taskkill /pid <processID>
|Kills the process as per the specified image name
|taskkill /im <imageName>
|Ends the process forcefully
|taskkill /f <pid/im> <processID/imageName>
|Ends the process along with all the child processes
|taskkill /t <pid/im> <processID/imageName>
If you prefer Windows PowerShell over CMD, you can actually run the Command Prompt as a Powershell window. Just type
powershell and hit Enter. You’ll likely get the PS prefix indicating that you can now run all the Powershell cmdlets here.
This command is used for configuring the Windows environment variables. To display all the available ones, you can use the
set command without any parameters. In order to set a new environment variable, you can use a variable name and provide the necessary value.
Likewise, it’s possible to delete any environment variable too. Below is the syntax that should clear your doubt.
set command on Command Prompt has the following two parameters with individual functionality:
|Sets the variable name as a line of input
|set /a <variable>=<expression>
|Sets the value as a numerical expression
|set /p <variable_name>=<promptString>
You can use this command to launch a new Command Prompt window. Without the use of any parameter, it will simply launch the new prompt. However, utilizing the following parameters can help you perform just more than that:
|Launches the CMD window with the specified title
|Starts the CMD window with the specified path
|start /d <path>
|<min> or <max>
|Launches the CMD windows in restored or maximized window
|Starts the application and waits for it to end (meaning you cannot execute further commands in the main prompt)
Most users utilize this command to repair the boot environment from the Windows Recovery Environment. It works by copying the Windows installation files to a system partition. You need to execute
bcdboot with the following parameters:
|Specifies an optional language during BCD store initialization
|bcdboot <source> /l <locale>
|Specifies the system partition’s label where the BCD files will be copied to
|bcdboot <source> /s <partition>
|Preserves the existing default windows boot entry
|bcdboot <source> /d <path>
|Cleans the BCD store
|bcdboot <source> /bcdclean
This is another useful command to quickly check the current date. You can display or set a new date as per your requirement. If you execute just the
date command, the prompt displays the date and asks you to set a new one. But if you quickly want to check the date, use the
This command offers customization of the text that appears in front of the cursor (by default, it’s the current directory path).
You can change this to any character string of your choice or predefined characters (like current date, drive, path, times, windows version, etc.) using special codes. You can check using the
/? Parameter. To switch back to the normal format, execute the prompt without any parameters.
Certainly, you have thought of customizing the Command Prompt. To your surprise, it’s possible to tweak the default black (background) and white (foreground/text) combination. For this, you require specifying two hex digits—the first representing the background and the second corresponding to the text.
As per the above table, let’s say you want a red background with light blue text. So, you’ll have to execute the following command:
While you’re at it, note that you cannot set the same background and foreground colors. Even if you do it, the command will not execute and you’ll be left with the existing combination.
To switch back to default, run the color command without any parameter.