25 best Command Prompt (CMD) commands you should know

tutorial
25 best Command Prompt (CMD) commands you should know
If you like working in a command-line environment and you're just starting to explore Command Prompt, there are some commands you should get to know right away. CMD has commands for almost everything, from working with files and directories to managing your system and network connections. Some are faster than using the graphical interface, while others unlock tools you won't easily find anywhere else. In this guide, I'll walk you through twenty-five of the most useful Command Prompt commands, show you what they do, and give you examples you can try right now.

System commands

Some of the best commands in Command Prompt are those that let you gather information, and control and manage your computer. These are commands that you may call system commands, and the next ones are the best, in my opinion:

1. Logoff

Although signing out of Windows is an easy thing to do from the graphical interface, you might prefer the command line sometimes. And Command Prompt has a simple command just for that:
logoff
The logoff command
The logoff command Run it, and you're out. Logged out of Windows. 🙂

2. Shutdown

Maybe one of the most useful commands in Command Prompt. You can use it to shutdown, restart, log a user out, reboot into UEFI (BIOS), and you can even schedule after how much time any of these happen. To shut down your PC from CMD, run:
shutdown /s
The shutdown command
The shutdown command TIP: For another interesting use of the shutdown command, read this guide: Shortcuts for the UEFI BIOS & Windows Recovery Environment.

3. Tasklist

You probably know and sometimes use Task Manager to see processes running on your Windows computer. But did you know that you can also view processes in Command Prompt? There's a simple CMD command for that:
tasklist
Use tasklist to view processes
Use tasklist to view processes TIP: Here's how to use the tasklist command to print the list of running processes in Windows.

4. Taskkill

In addition to the tasklist command, CMD also has another one that works in conjunction with it: taskkill. This command lets you kill (or stop, or terminate, if you prefer) processes. You'll need to get the process name or process ID you want to kill using the previous command (tasklist), and then you can just run:
taskkill /f /im [process name]
or
taskkill /f /pid [process ID]
Use the taskkill command to end processes
Use the taskkill command to end processes Here are more details about the tasklist and taskkill commands: How to get system info, view, and kill processes in CMD.

5. Chkdsk

Is your hard-disk drive or SSD misbehaving, and you suspect data is corrupted? Then one of the best tools you can use to check your drive for errors and attempt repairing them is the chkdsk command. Open CMD as administrator, switch to the drive you need to verify and repair, and run:
chkdsk /f
Run chkdsk to check your drives
Run chkdsk to check your drives For more information on repairing drive errors, including with the chkdsk command, read: How to use Check Disk (chkdsk) to test and fix hard drive errors in Windows.

6. Sfc /scannow

While the previous command helps check errors on drives, when it comes to scanning the integrity of system files and repairing them, you should use the command: sfc. Not only that it checks all essential files in the operating system, but it also replaces incorrect versions of them with the right ones. In Command Prompt, to scan your system drive, run:
sfc /scannow
You can use the sfc command to verify the system files
You can use the sfc command to verify the system files For more details on how to use sfc in CMD, check out this guide: How to use SFC to repair missing or corrupt Windows files in CMD.

7. Format

In need to format a drive? Regardless of whether it's a hard-disk drive, an SSD, or a USB memory stick, Command Prompt has you covered. Just use the following CMD command:
format [drive letter]: /fs:[file system] /q
… replacing [drive letter] with the letter of the drive you want to format, and [file system] with the type of file system you prefer. The /q argument allows you to do a quick format, but you can leave it out if you want to run a regular format. For example, here's the command I ran to quickly format a USB portable SSD with the drive letter E: using the NTFS file system:
format e: /fs:ntfs /q
How to format a drive from command line
How to format a drive from command line Check the next command for more advanced formatting and drive partitioning options.

8. Diskpart

One of the most powerful tools in CMD is:
diskpart
Among others, it allows you to see, manage, create, and delete partitions from your drives. For example, you can enter diskpart and then run the list disk and list volume commands to see all the drives and volumes on your PC:
Diskpart is a powerful tool for managing drives
Diskpart is a powerful tool for managing drives For all the details on how to use diskpart in Command Prompt, read: How to use disk management commands (diskpart, chkdsk, defrag) in Windows. This is a useful tool if you need to work with Command Prompt to manage your drives, and especially so if you need to do it on a Windows computer that doesn't boot.

9. Ver

Want to find out what version of Windows you use? Let Command Prompt help you identify the exact version and build of Windows. One of the easiest ways to get this information is to run this CMD command:
ver
Find out what version of Windows you have with the ver command
Find out what version of Windows you have with the ver command If you have Windows 11, you'll need to understand what the version numbers shown by the ver command translate into. For that, check this article: How to check the Windows 11 version and edition.

10. Systeminfo

Another CMD command that can be quite useful in certain situations is:
systeminfo
It collects and displays information about your computer hardware (like the processor, RAM, and network cards installed) and Windows installation (version, install date, hotfixes applied, etc.).
Gather information about your system with the systeminfo CMD command
Gather information about your system with the systeminfo CMD command

File commands

Some of the most basic commands you must know are the file commands. They're essential if you want to navigate through the directories on your computer and be able to work with files and folders. I've covered file commands in this tutorial already: CMD: 13 basic commands you should know (cd, dir, mkdir, etc.). I recommend you to read it from start to finish, as the next couple of commands are just the tip of the iceberg:

11. Dir

If you need to work with files and folders in Command Prompt, the dir command is essential. Use it to list the contents of a directory so that you know what files and folders are in it:
dir
See what's inside a folder with the dir command
See what's inside a folder with the dir command

12. Cd

Cd is a basic CMD command that allows you to change the current directory. In other words, you use it to navigate to another folder on your PC. Its basic syntax is:
cd [path to folder]
Navigate through folders with the cd CMD command
Navigate through folders with the cd CMD command

13. Copy

Another basic command that fulfills a basic need in Command Prompt is copy. At some point or the other, while working in the command line, you will get to the point where you need to copy a file, two, or more, from one directory to another. Command Prompt has more than one command that helps you achieve that, but the main one and the one to start from is copy. Its syntax is simple:
copy [path\file.ext] [path\newfile.ext]
For example, I wanted to copy a file called digitalcitizen.txt to the same folder but bearing a different name: test.txt. For that, I had to run this command:
copy digitalcitizen.txt test.txt
How to copy files in Command Prompt
How to copy files in Command Prompt For more details on how to copy files and folders in CMD, don't forget to read the tutorial I shared at the beginning of this section.

14. Del

What if you want to erase a file you no longer need? Easy as pie: use the del command. In Command Prompt, all you need to do is type:
del
… followed by the name of the file you want to remove. Or you can specify a folder's name if you want to erase all the files in it.
How to delete files in CMD using the del command
How to delete files in CMD using the del command

Network commands

Some of the most interesting and useful CMD commands are the ones that help you manage and gather information about your network devices and connections. Out of all the network commands you should know, these are the best ones:

15. Ipconfig

In Windows, there are many ways to find details about your network cards and connections. And one of the best methods is using the ipconfig CMD command. Ipconfig gets its name from Internet Protocol Configuration, and it's a command designed to show and manage the IP addresses of your computer. In Command Prompt, run it like below, and you'll get a full array of useful information like the IP, subnet mask, default gateway, hostname, MAC address, and DNS servers used by your PC:
ipconfig /all
Get NIC info with ipconfig in CMD
Get NIC info with ipconfig in CMD

16. Ping

Ping is the basic network-related CMD command you should use to test whether your PC can reach a destination device through the network and/or the internet. In Command Prompt, enter:
ping
… followed by the IP address or hostname of the target device, website, or internet resource. For example, type:
ping digitalcitizen.life
… to check whether our website is up and running. 🙂
Ping a website or network resource from Command Prompt
Ping a website or network resource from Command Prompt TIP: For more details on what ping is and how to use it, read this article: What is ping? How do you use ping commands in Windows?.

17. Tracert

Sometimes, using ping is not enough to gather the information you need for troubleshooting network connectivity. In such cases, the more advanced command tracert (trace route) allows you to trace the path Internet Protocol packets take to their destination. This helps you identify where the problem is with more accuracy. The basic syntax for the CMD command tracert is:
tracert [IP address or hostname]
For example, if you want to trace the path of packets sent between your PC and our website, you'd run this command:
tracert digitalcitizen.life
Trace the path to a website or network resource from CMD
Trace the path to a website or network resource from CMD

18. Netsh wlan show profiles

The last network-related CMD command on our list is more specific, and it's actually not just one but two commands, which you should run one after the other:
netsh wlan show profiles
and
netsh wlan show profile name=WiFi_SSID key=clear
The purpose is to help you find the password of a wireless network to which you've previously connected. Run the first command to see the list of known Wi-Fi networks. Note the name of the Wi-Fi for which you want to find the password, and run the second command replacing the WiFi_SSID with that network's name. Once you press Enter, Command Prompt displays details about the network, including its password. Neat, right?
Find the password of your Wi-Fi in CMD
Find the password of your Wi-Fi in CMD TIP: Here are some other ways to find out what password you've set for a Wi-Fi network.

CMD commands

Next, I'll continue this article with two commands that are useful for working with Command Prompt: a command that clears the screen and one that helps you understand what other commands do.

19. Cls

If you've tried at least a couple of the previous commands, your Command Prompt window is now full of information. You're in dire need of a clean slate to start over, right? Say hi to cls, Command Prompt's very own blackboard cleaner and one of the simplest commands in CMD. Run it, and the Command Prompt resets its window, clearing previous commands and their output.
cls
CLS resets the Command Prompt
CLS resets the Command Prompt

20. Help

Another useful CMD command you should know is help. Run it just like that, and you get a list of essential commands you can run in Command Prompt and short descriptions for each of them. Type help followed by the name of a command you want to know more about, and Command Prompt will show you its syntax, use, and detailed description. So whenever you find yourself in need of help, run:
help
or
help [command]
Get help in Command Prompt
Get help in Command Prompt

Extra CMD commands worth knowing

Here are five more that come in handy often.

21. Tree

The tree command shows a structured view of all folders and subfolders inside a location. It's like a map of your drive's directory structure.
tree C:
How to use the tree command
How to use the tree command For example, if you run the command above, you'll see a visual hierarchy of everything on the C: drive.
What you get when running tree in CMD
What you get when running tree in CMD This is especially useful when you're trying to understand how folders are organized or when you're cleaning up a messy drive and want to see the structure at a glance.

22. Assoc

Windows uses file associations to decide which program opens a certain file type. The assoc command lets you see or change those associations. In this example, the command shows you which program is set to open .pdf files:
assoc .pdf
How to use the assoc command
How to use the assoc command This can help if you've accidentally set the wrong app for a file type or if you just want to confirm the current association.

23. Powercfg

The powercfg command can adjust your computer's power settings, but one of its most useful features is generating battery health reports for laptops.
powercfg /batteryreport
When you run this, Windows creates an HTML file with detailed information about your battery's condition, capacity, and charge cycles.
The powercfg command can give you insight on your battery
The powercfg command can give you insight on your battery It's a great way to troubleshoot fast battery drain or to check how much your battery has degraded over time.

24. Cipher

The cipher command is used for encrypting files and folders, but it can also securely wipe free space on a drive so deleted files can't be recovered.
cipher /w:C
The /w argument wipes all unused space on the C: drive without touching files you still have.
Use the cipher command to permanently erase free space
Use the cipher command to permanently erase free space This is useful if you're selling or giving away your computer and want to protect your old data. Be aware that it can take a long time, especially on larger drives.

25. Robocopy

Robocopy stands for Robust File Copy and is much more capable than the standard copy command. It's great for making backups because it can preserve folder structures, copy only changed files, and handle errors better.
robocopy “D:\Digital Citizen” D:\backup /E
In this example, every file and subfolder from D:\Digital Citizen is copied to D:\backup, including empty folders.
You can copy entire folders with the robocopy command
You can copy entire folders with the robocopy command It's an excellent tool if you need a reliable and repeatable backup method for important projects.

Which CMD command is your favorite?

You've now seen 25 useful Command Prompt commands, each with examples and ideas for how you might use them in real life. Some are simple tools for navigating folders or checking system info, while others give you powerful control over your files, backups, and even your computer's power settings. The more you use these commands, the more natural they become, and you'll find yourself reaching for them instead of clicking through menus. Do you already have a go-to CMD command that you use all the time? Or is there one you think should have made this list? I'd love to hear what's in your personal toolbox.
Discover: Productivity Apps CMD Recommended Tutorials Windows

Discussion (0)

Be the first to comment.